Fehler mit Wildcards in ASTFactory beheben
This commit is contained in:
parent
89387d2718
commit
272948f70d
@ -17,6 +17,7 @@ import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Statement;
|
||||
import de.dhbwstuttgart.syntaxtree.type.WildcardType;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
/**
|
||||
@ -201,8 +202,19 @@ public class ASTFactory {
|
||||
//Diese entfernen:
|
||||
name = name.split("<")[0];
|
||||
}
|
||||
RefType ret = new RefType(new JavaClassName(name), params, new NullToken());
|
||||
return ret;
|
||||
if(type instanceof java.lang.reflect.WildcardType){
|
||||
java.lang.reflect.WildcardType wildcardType = (java.lang.reflect.WildcardType) type;
|
||||
if(wildcardType.getLowerBounds().length > 0){
|
||||
return new SuperWildcardType(convertType(wildcardType.getLowerBounds()[0]), new NullToken());
|
||||
}else if(wildcardType.getUpperBounds().length > 0){
|
||||
return new ExtendsWildcardType(convertType(wildcardType.getUpperBounds()[0]), new NullToken());
|
||||
}else{//Es handelt sich um den '?'-Typ:
|
||||
return new ExtendsWildcardType(createObjectType(), new NullToken());
|
||||
}
|
||||
}else{
|
||||
RefType ret = new RefType(new JavaClassName(name), params, new NullToken());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,10 @@ public class ExtendsWildcardType extends WildcardType{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "? extends "+innerType.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ASTVisitor visitor) {
|
||||
|
@ -35,6 +35,11 @@ public class SuperWildcardType extends WildcardType{
|
||||
return this.innerType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "? super "+innerType.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtends() {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user