private int declaringElementKind = UNKNOWN; | private int declaringElementKind = UNKNOWN; | ||||
private TypeVariableDeclaringElement declaringElement; | private TypeVariableDeclaringElement declaringElement; | ||||
// whether or not the bounds of this type variable have been resolved | // whether or not the bounds of this type variable have been resolved | ||||
private boolean isResolved = false; | |||||
public boolean isResolved = false; | |||||
// Is this type variable in the process of being resolved (allows for something self-referential like Enum) | // Is this type variable in the process of being resolved (allows for something self-referential like Enum) | ||||
private boolean beingResolved = false; | private boolean beingResolved = false; | ||||
// only used when resolving | // only used when resolving | ||||
public void setAdditionalInterfaceBounds(UnresolvedType[] superInterfaces) { | public void setAdditionalInterfaceBounds(UnresolvedType[] superInterfaces) { | ||||
if (isResolved) { | |||||
throw new IllegalStateException("Why set this late?"); | |||||
} | |||||
// if (isResolved) { | |||||
// throw new IllegalStateException("Why set this late?"); | |||||
// } | |||||
this.firstbound = null; | this.firstbound = null; | ||||
this.superInterfaces = superInterfaces; | this.superInterfaces = superInterfaces; | ||||
} | } |
} | } | ||||
public TypeVariable getTypeVariable() { | public TypeVariable getTypeVariable() { | ||||
// if (!fixedUp) throw new BCException("ARGH"); // fix it up now? | |||||
// if (!fixedUp) | |||||
// throw new BCException("ARGH"); // fix it up now? | |||||
return typeVariable; | return typeVariable; | ||||
} | } | ||||
return (ReferenceType) typeVariable.resolve(world).getUpperBound(); | return (ReferenceType) typeVariable.resolve(world).getUpperBound(); | ||||
} | } | ||||
/** | |||||
* resolve the type variable we are managing and then return this object. 'this' is already a ResolvedType but the type variable | |||||
* may transition from a not-resolved to a resolved state. | |||||
*/ | |||||
public ResolvedType resolve(World world) { | |||||
typeVariable.resolve(world); | |||||
return this; | |||||
} | |||||
/** | |||||
* @return true if the type variable this reference is managing is resolved | |||||
*/ | |||||
public boolean isTypeVariableResolved() { | |||||
return typeVariable.isResolved; | |||||
} | |||||
} | } |
if (ty instanceof ResolvedType) { | if (ty instanceof ResolvedType) { | ||||
ResolvedType rty = (ResolvedType) ty; | ResolvedType rty = (ResolvedType) ty; | ||||
rty = resolve(rty); | rty = resolve(rty); | ||||
return rty; | |||||
// A TypeVariableReferenceType may look like it is resolved (it extends ResolvedType) but the internal | |||||
// type variable may not yet have been resolved | |||||
if (!rty.isTypeVariableReference() || ((TypeVariableReferenceType) rty).isTypeVariableResolved()) { | |||||
return rty; | |||||
} | |||||
} | } | ||||
// dispatch back to the type variable reference to resolve its | // dispatch back to the type variable reference to resolve its |