forked from JavaTX/JavaCompilerCore
Bugfix
This commit is contained in:
parent
07b159f9a3
commit
4b44fba421
@ -24,7 +24,7 @@ public class TypeInferenceBlockInformation extends TypeInferenceInformation {
|
|||||||
this.currentClass = currentClass;
|
this.currentClass = currentClass;
|
||||||
}
|
}
|
||||||
public TypeInferenceBlockInformation(TypeInferenceBlockInformation oldScope, TypeScope newScope) {
|
public TypeInferenceBlockInformation(TypeInferenceBlockInformation oldScope, TypeScope newScope) {
|
||||||
this(oldScope.getAvailableClasses(), oldScope.currentClass, oldScope.methodContext);
|
this(oldScope.getAvailableClasses(), oldScope.currentClass, new TypeScopeContainer(oldScope.methodContext, newScope));
|
||||||
}
|
}
|
||||||
public ClassOrInterface getCurrentClass() {
|
public ClassOrInterface getCurrentClass() {
|
||||||
return currentClass;
|
return currentClass;
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package de.dhbwstuttgart.typeinference.result;
|
package de.dhbwstuttgart.typeinference.result;
|
||||||
|
|
||||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||||
import de.dhbwstuttgart.syntaxtree.AbstractASTWalker;
|
import de.dhbwstuttgart.syntaxtree.AbstractASTWalker;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||||
|
|
||||||
import javax.xml.transform.Result;
|
import javax.xml.transform.Result;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -85,11 +87,16 @@ class Resolver implements ResultSetVisitor {
|
|||||||
otherSide.accept(related);
|
otherSide.accept(related);
|
||||||
additionalTPHs.addAll(related.relatedTPHs);
|
additionalTPHs.addAll(related.relatedTPHs);
|
||||||
}else if(resolved instanceof TypePlaceholder){
|
}else if(resolved instanceof TypePlaceholder){
|
||||||
|
RelatedTypeWalker related = new RelatedTypeWalker(null, result);
|
||||||
|
resolved.accept(related);
|
||||||
Set<ResultPair> newResultSet = new HashSet<>(result.results);
|
Set<ResultPair> newResultSet = new HashSet<>(result.results);
|
||||||
newResultSet.remove(p);
|
newResultSet.remove(p);
|
||||||
|
additionalTPHs.add(new GenericInsertPair((TypePlaceholder)resolved, null));
|
||||||
ResolvedType resolvedType = new Resolver(new ResultSet(newResultSet)).resolve((TypePlaceholder) resolved);
|
ResolvedType resolvedType = new Resolver(new ResultSet(newResultSet)).resolve((TypePlaceholder) resolved);
|
||||||
this.resolved = resolvedType.resolvedType;
|
this.resolved = resolvedType.resolvedType;
|
||||||
this.additionalTPHs.addAll(resolvedType.additionalGenerics);
|
this.additionalTPHs.addAll(resolvedType.additionalGenerics);
|
||||||
|
resolved.accept(related);
|
||||||
|
this.additionalTPHs.addAll(related.relatedTPHs);
|
||||||
}else {
|
}else {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@ -130,8 +137,10 @@ class TPHResolver implements ResultSetVisitor {
|
|||||||
|
|
||||||
private final TypePlaceholder tph;
|
private final TypePlaceholder tph;
|
||||||
Set<GenericInsertPair> resolved = new HashSet<>();
|
Set<GenericInsertPair> resolved = new HashSet<>();
|
||||||
|
private final ResultSet resultSet;
|
||||||
|
|
||||||
TPHResolver(TypePlaceholder tph, ResultSet resultSet){
|
TPHResolver(TypePlaceholder tph, ResultSet resultSet){
|
||||||
|
this.resultSet = resultSet;
|
||||||
this.tph = tph;
|
this.tph = tph;
|
||||||
for(ResultPair p : resultSet.results){
|
for(ResultPair p : resultSet.results){
|
||||||
p.accept(this);
|
p.accept(this);
|
||||||
@ -150,7 +159,19 @@ class TPHResolver implements ResultSetVisitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(PairTPHequalRefType p) {
|
public void visit(PairTPHequalRefType p) {
|
||||||
|
TypePlaceholder otherSide = null;
|
||||||
|
if(p.left.equals(tph) && p.right instanceof TypePlaceholder){
|
||||||
|
otherSide = (TypePlaceholder) p.right;
|
||||||
|
}
|
||||||
|
if(p.right.equals(tph)){
|
||||||
|
otherSide = p.left;
|
||||||
|
}
|
||||||
|
if(otherSide != null){
|
||||||
|
resolved.add(new GenericInsertPair(p.left, (TypePlaceholder) p.right));
|
||||||
|
Set<ResultPair> newResultSet = new HashSet<>(this.resultSet.results);
|
||||||
|
newResultSet.remove(p);
|
||||||
|
resolved.addAll(new TPHResolver(otherSide, new ResultSet(newResultSet)).resolved);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user