}
private boolean hasTypeParameterWithConstraintsOutsideScopeResolved(ProducedType type, Scope scope) {
if(type == null)
return false;
TypeDeclaration declaration = type.getDeclaration();
if(declaration == null)
return false;
if(declaration instanceof UnionType){
UnionType ut = (UnionType) declaration;
java.util.List<ProducedType> caseTypes = ut.getCaseTypes();
for(ProducedType pt : caseTypes){
if(hasTypeParameterWithConstraintsOutsideScopeResolved(pt, scope))
return true;
}
return false;
}
if(declaration instanceof IntersectionType){
IntersectionType ut = (IntersectionType) declaration;
java.util.List<ProducedType> satisfiedTypes = ut.getSatisfiedTypes();
for(ProducedType pt : satisfiedTypes){
if(hasTypeParameterWithConstraintsOutsideScopeResolved(pt, scope))
return true;
}
return false;
}
if(declaration instanceof TypeParameter){
// only look at it if it is defined outside our scope
Scope typeParameterScope = declaration.getContainer();
while(scope != null){
if (Decl.equalScopes(scope, typeParameterScope))
return false;
scope = scope.getContainer();
}