forked from JavaTX/JavaCompilerCore
BoundedGenerics werden nun auch mit einbezogen
This commit is contained in:
parent
863f8ec2ec
commit
4000695736
@ -652,8 +652,10 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
||||
//Globale Assumptions anfügen:
|
||||
assumptions.add(globalAssumptions);
|
||||
|
||||
ConstraintsSet oderConstraints = new ConstraintsSet();
|
||||
|
||||
for(Type gparam : this.paralist){
|
||||
if(gparam instanceof GenericTypeVar)((GenericTypeVar)gparam).TYPE(assumptions); //Constraints für die Generischen Variablen erstellen und diese dem AssumptionsSet hinzufügen
|
||||
if(gparam instanceof GenericTypeVar)oderConstraints.add(((GenericTypeVar)gparam).TYPE(assumptions)); //Constraints für die Generischen Variablen erstellen und diese dem AssumptionsSet hinzufügen
|
||||
}
|
||||
|
||||
typinferenzLog.debug("Erstellte Assumptions: "+assumptions);
|
||||
@ -671,7 +673,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
||||
|
||||
//ConstraintsSet oderConstraints = this.TYPE(this.getMethodList(), fieldInitializers, assumptions);
|
||||
|
||||
ConstraintsSet oderConstraints = new ConstraintsSet();
|
||||
|
||||
for(Field f:this.getFields()){
|
||||
oderConstraints.add(f.TYPE(assumptions));
|
||||
}
|
||||
@ -1259,10 +1261,12 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
||||
* @return
|
||||
*/
|
||||
public RefType getType() {
|
||||
/*
|
||||
Vector<Type> parameter = new Vector<Type>();
|
||||
for(Type param : this.get_ParaList()){
|
||||
parameter.add(((GenericTypeVar)param).getTypePlaceHolder());//(TypePlaceholder.fresh()); //Hier ist kein ReplacementListener notwendig. Der Typ soll nie eingesetzt werden. Der TPH wird nur gebraucht, damit das Unifizieren funktioniert.
|
||||
}
|
||||
*/
|
||||
return new RefType(this.getName(), this.get_ParaList(), 0);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
// ino.module.BaseType.8667.package
|
||||
package mycompiler.mytype;
|
||||
|
||||
import mycompiler.IItemWithOffset;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
|
||||
// ino.end
|
||||
// ino.class.BaseType.26435.declaration
|
||||
public abstract class BaseType extends Type
|
||||
@ -76,5 +80,12 @@ public abstract class BaseType extends Type
|
||||
public void setArray(boolean IsArray) {
|
||||
this.IsArray = IsArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type checkType(TypeAssumptions ass, IItemWithOffset parent) {
|
||||
return this; //Die Base-Types müssen nicht nachgeschlagen werden.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -50,7 +50,6 @@ public class BoundedGenericTypeVar extends GenericTypeVar
|
||||
// ino.end
|
||||
// ino.method.BoundedGenericTypeVar.29409.body
|
||||
{
|
||||
//TODO: Dieser Konstruktor muss this.genericConstraint setzen
|
||||
super(s, offset);
|
||||
if(bounds != null)for(Type t : bounds){
|
||||
if(t!=null)this.extendVars.add(t);
|
||||
|
@ -194,8 +194,13 @@ public class GenericTypeVar extends Type
|
||||
|
||||
public ConstraintsSet TYPE(TypeAssumptions ass){
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
if(this.genericConstraint != null)ret.add(new SingleConstraint(this.genericConstraint.TA1, this.genericConstraint.TA2));
|
||||
ass.addGenericVarAssumption(this);
|
||||
//if(this.genericConstraint != null)ret.add(new SingleConstraint(this.genericConstraint.TA1, this.genericConstraint.TA2));
|
||||
if(this.extendVars != null){
|
||||
for(Type ev : this.extendVars){
|
||||
ret.add(new SingleConstraint(ass.getTypeFor(this), ass.getTypeFor(ev)));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class GenericVarAssumption extends Assumption{
|
||||
}
|
||||
|
||||
public Type getAssumedType() {
|
||||
return new RefType(this.getIdentifier(), -1);
|
||||
return genericVar;//new RefType(this.getIdentifier(), -1);
|
||||
}
|
||||
|
||||
public String getIdentifier(){
|
||||
|
@ -0,0 +1,6 @@
|
||||
class BoundedGenericTest<A extends String>{
|
||||
var;
|
||||
<B extends A> B methode(){
|
||||
return var;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class BoundedGenericsTest {
|
||||
private static final String TEST_FILE = "BoundedGenericTest.jav";
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
Vector<String> mustContain = new Vector<String>();
|
||||
mustContain.add("var");
|
||||
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
|
||||
}
|
||||
}
|
@ -8,14 +8,14 @@ public class GenericTypeVarTest {
|
||||
|
||||
private static final String TEST_FILE = "GenericTypeVarTest.jav";
|
||||
private static final String TEST_FILE2 = "GenericTypeVarTest2.jav";
|
||||
/*
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
Vector<String> mustContain = new Vector<String>();
|
||||
mustContain.add("String methode");
|
||||
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void run2(){
|
||||
Vector<String> mustContain = new Vector<String>();
|
||||
|
Loading…
Reference in New Issue
Block a user