forked from JavaTX/JavaCompilerCore
Unnötige GenericVariables nicht mehr einfügen
This commit is contained in:
parent
a579bb964f
commit
03d1727cbf
@ -4,5 +4,5 @@ public enum Section {
|
|||||||
TYPEINFERENCE,
|
TYPEINFERENCE,
|
||||||
PARSER,
|
PARSER,
|
||||||
CODEGEN,
|
CODEGEN,
|
||||||
UNIFY, FINITECLOSURE;
|
UNIFY, FINITECLOSURE, ASSUMPTIONS;
|
||||||
}
|
}
|
||||||
|
@ -328,11 +328,11 @@ public class TypeAssumptions {
|
|||||||
//if(ass.inheritsType(t))return t;
|
//if(ass.inheritsType(t))return t;
|
||||||
if(ass.getIdentifier().equals(t.getName())){
|
if(ass.getIdentifier().equals(t.getName())){
|
||||||
if(! ass.getAssumedType().getParentClass().equals(inNode.getParentClass())){ //hier muss nach der ParentClass von inNode gefragt werden, da die ParentClass von t nicht immer korrekt ist! (TODO: Überprüfen)
|
if(! ass.getAssumedType().getParentClass().equals(inNode.getParentClass())){ //hier muss nach der ParentClass von inNode gefragt werden, da die ParentClass von t nicht immer korrekt ist! (TODO: Überprüfen)
|
||||||
TypeAssumptions.log.debug(t+" ist NICHT in Klasse: "+ass.getAssumedType().getParentClass(), Section.TYPEINFERENCE);
|
TypeAssumptions.log.debug(t+" ist NICHT in Klasse: "+ass.getAssumedType().getParentClass(), Section.ASSUMPTIONS);
|
||||||
//Ist die Generische Variable nicht aus dieser Klasse, so muss sie zu einem TPH umgewandelt werden:
|
//Ist die Generische Variable nicht aus dieser Klasse, so muss sie zu einem TPH umgewandelt werden:
|
||||||
return new ConstraintType(ass.getAssumedType().getTypePlaceHolder(inNode));
|
return new ConstraintType(ass.getAssumedType().getTypePlaceHolder(inNode));
|
||||||
}
|
}
|
||||||
TypeAssumptions.log.debug(t+" ist in Klasse: "+ass.getAssumedType().getParentClass(), Section.TYPEINFERENCE);
|
TypeAssumptions.log.debug(t+" ist in Klasse: "+ass.getAssumedType().getParentClass(), Section.ASSUMPTIONS);
|
||||||
return new ConstraintType(ass.getAssumedType());
|
return new ConstraintType(ass.getAssumedType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@ class GenericVarPatch {
|
|||||||
|
|
||||||
private Vector<GenericVarExtendsDeclarationPatch> genericVarExtendDeclarations = new Vector<GenericVarExtendsDeclarationPatch>();
|
private Vector<GenericVarExtendsDeclarationPatch> genericVarExtendDeclarations = new Vector<GenericVarExtendsDeclarationPatch>();
|
||||||
private Vector<GenericVarDeclarationPatch> genericVarDeclarations = new Vector<GenericVarDeclarationPatch>();
|
private Vector<GenericVarDeclarationPatch> genericVarDeclarations = new Vector<GenericVarDeclarationPatch>();
|
||||||
|
private Vector<TypePlaceholder> usedTPHs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fügt eine generische Variable in Form eines Pairs an.
|
* Fügt eine generische Variable in Form eines Pairs an.
|
||||||
@ -111,6 +112,20 @@ class GenericVarPatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getInsertString(ResultSet rs){
|
public String getInsertString(ResultSet rs){
|
||||||
|
//Alle Generische Einsetzungen verwerfen, welche nicht benötigt werden:
|
||||||
|
/*
|
||||||
|
* Dies geht mit der momentanen Variante nur für die genericVarDeclarations.
|
||||||
|
* Es kann passieren, dass bei den genericVarExtendDeclarations extend-Verknüpfungen enthalten sind,
|
||||||
|
* welche nicht im eingesetzten Typ auftauchen, aber dennoch notwendig sind.
|
||||||
|
*/
|
||||||
|
Vector<GenericVarDeclarationPatch> tmpGenVars = new Vector<>();
|
||||||
|
for(GenericVarDeclarationPatch gv : this.genericVarDeclarations){
|
||||||
|
if(this.usedTPHs.contains(gv.genericVar)){
|
||||||
|
tmpGenVars.add(gv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.genericVarDeclarations = tmpGenVars;
|
||||||
|
|
||||||
//Hier sollten TPHs nicht aufgelöst sondern in Generische Variablen umgewandelt werden:
|
//Hier sollten TPHs nicht aufgelöst sondern in Generische Variablen umgewandelt werden:
|
||||||
String ret = "";
|
String ret = "";
|
||||||
Iterator<GenericVarDeclarationPatch> it1 = this.genericVarDeclarations.iterator();
|
Iterator<GenericVarDeclarationPatch> it1 = this.genericVarDeclarations.iterator();
|
||||||
@ -151,6 +166,19 @@ class GenericVarPatch {
|
|||||||
public void addPairs(Vector<Pair> pairs) {
|
public void addPairs(Vector<Pair> pairs) {
|
||||||
for(Pair pair : pairs)this.add(pair);
|
for(Pair pair : pairs)this.add(pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeUnusedTPHs(Vector<TypePlaceholder> usedTPHs) {
|
||||||
|
this.usedTPHs = usedTPHs;
|
||||||
|
return;
|
||||||
|
/*
|
||||||
|
for(TypePlaceholder tph : usedTPHs){
|
||||||
|
//Zuerst alle extends Typen kontrollieren und entfernen:
|
||||||
|
for(GenericVarExtendsDeclarationPatch p : this.genericVarExtendDeclarations){
|
||||||
|
if(p.definesGenericVar(tph))return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,6 +191,11 @@ class GenericVarExtendsDeclarationPatch {
|
|||||||
|
|
||||||
private Pair genericPair;
|
private Pair genericPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kontrolliert ob der T1 mit tph übereinstimmt im Constraint: T1 extends T2
|
||||||
|
* @param tph
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean definesGenericVar(TypePlaceholder tph){
|
public boolean definesGenericVar(TypePlaceholder tph){
|
||||||
if(genericPair.TA1.equals(tph))return true;
|
if(genericPair.TA1.equals(tph))return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -119,6 +119,9 @@ public class TypeInsertSet {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//Nur Generische Variablen einsetzen, welche auch verwendet werden:
|
||||||
|
gPatch.removeUnusedTPHs(tip.getInsertType().getInvolvedTypePlaceholder());
|
||||||
|
|
||||||
GenericTypeInsertPoint gip = new GenericTypeInsertPoint(tip.getGenericTypeVarInsertNode(), gPatch, resultSet);
|
GenericTypeInsertPoint gip = new GenericTypeInsertPoint(tip.getGenericTypeVarInsertNode(), gPatch, resultSet);
|
||||||
typinferenzLog.debug("Erstellter GenericTypeInsertPoint: "+gip, Section.TYPEINFERENCE);
|
typinferenzLog.debug("Erstellter GenericTypeInsertPoint: "+gip, Section.TYPEINFERENCE);
|
||||||
tpj.add(tip);
|
tpj.add(tip);
|
||||||
|
@ -7,13 +7,3 @@ class OverloadingInMethod{
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class OverloadingInMethod2{
|
|
||||||
|
|
||||||
<ABM, T11702297201, ABL extends ABM, R1702297201 extends ABL, C extends T11702297201> Fun1<? extends Fun1<? extends ABM, ? super Fun1<R1702297201, T11702297201>>, ? super C> m () {
|
|
||||||
Fun1<? extends Fun1<? extends ABM, ? super Fun1<R1702297201, T11702297201>>, ? super C> op;
|
|
||||||
op = (m) -> (f) -> f.apply(m);
|
|
||||||
return op;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
class OverloadingInMethod2{
|
||||||
|
|
||||||
|
<ABM, T11702297201, ABL extends ABM, R1702297201 extends ABL, C extends T11702297201> Fun1<? extends Fun1<? extends ABM, ? super Fun1<R1702297201, T11702297201>>, ? super C> m () {
|
||||||
|
Fun1<? extends Fun1<? extends ABM, ? super Fun1<R1702297201, T11702297201>>, ? super C> op;
|
||||||
|
op = (m) -> (f) -> f.apply(m);
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package plugindevelopment.TypeInsertTests;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class OverloadingInMethod2 {
|
||||||
|
|
||||||
|
private static final String TEST_FILE = "OverloadingInMethod2.jav";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void run(){
|
||||||
|
Vector<String> mustContain = new Vector<String>();
|
||||||
|
|
||||||
|
//mustContain.add("Fun0<Fun1<java.lang.String, Fun2<AH, LambdaTest, java.lang.String>>> op");
|
||||||
|
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user