Exemplo n.º 1
0
 @Override
 protected UnboundTypeReference getUnboundTypeReference(Object handle) {
   UnboundTypeReference result = basicGetTypeParameters().get(handle);
   if (result == null) {
     result = parent.getUnboundTypeReference(handle);
     if (result.internalIsResolved())
       throw new IllegalStateException("Cannot query unbound reference that was already resolved");
     return (UnboundTypeReference) result.copyInto(getReferenceOwner());
   }
   return result;
 }
Exemplo n.º 2
0
 protected void mergeTypeParametersIntoParent(ResolvedTypes parent) {
   for (UnboundTypeReference unbound : basicGetTypeParameters().values()) {
     LightweightTypeReference resolvedTo = unbound.getResolvedTo();
     if (resolvedTo == null) {
       List<JvmTypeParameter> typeParameters = basicGetDeclardTypeParameters();
       if (typeParameters != null && typeParameters.contains(unbound.getTypeParameter())) {
         unbound.tryResolve();
         if (!unbound.internalIsResolved()) {
           if (unbound.getExpression() instanceof XConstructorCall) {
             unbound.resolve(); // resolve against constraints
           } else {
             unbound.acceptHint(
                 unbound.getOwner().newParameterizedTypeReference(unbound.getTypeParameter()),
                 BoundTypeArgumentSource.RESOLVED,
                 unbound,
                 VarianceInfo.INVARIANT,
                 VarianceInfo.INVARIANT);
           }
         }
       } else {
         LightweightTypeReference reference = unbound.copyInto(parent.getReferenceOwner());
         if (reference instanceof UnboundTypeReference) {
           parent.acceptUnboundTypeReference(
               unbound.getHandle(), (UnboundTypeReference) reference);
         }
       }
     }
   }
   Map<Object, List<LightweightBoundTypeArgument>> typeParameterHints =
       basicGetTypeParameterHints();
   for (Map.Entry<Object, List<LightweightBoundTypeArgument>> hint :
       typeParameterHints.entrySet()) {
     if (!parent.isResolved(hint.getKey())) {
       List<LightweightBoundTypeArgument> boundTypeArguments = hint.getValue();
       for (LightweightBoundTypeArgument boundTypeArgument : boundTypeArguments) {
         if (boundTypeArgument.getOrigin() instanceof VarianceInfo) {
           parent.acceptHint(hint.getKey(), boundTypeArgument);
         } else {
           LightweightBoundTypeArgument copy =
               new LightweightBoundTypeArgument(
                   boundTypeArgument.getTypeReference().copyInto(parent.getReferenceOwner()),
                   boundTypeArgument.getSource(),
                   boundTypeArgument.getOrigin(),
                   boundTypeArgument.getDeclaredVariance(),
                   boundTypeArgument.getActualVariance());
           parent.acceptHint(hint.getKey(), copy);
         }
       }
     }
   }
 }