protected void copyTypeArguments(ParameterizedTypeReference result, ITypeReferenceOwner owner) { if (typeArguments != null && !typeArguments.isEmpty()) { for(LightweightTypeReference typeArgument: typeArguments) { result.addTypeArgument(typeArgument.copyInto(owner)); } } }
@Override protected LightweightTypeReference doCopyInto(ITypeReferenceOwner owner) { LightweightTypeReference copiedComponent = component.copyInto(owner); return owner.newArrayTypeReference(copiedComponent); }
@Override protected void doVisitTypeReference(LightweightTypeReference reference) { result.addComponent(reference.copyInto(owner)); } };
protected LightweightTypeReference copy(LightweightTypeReference reference) { return reference.copyInto(getOwner()); }
protected LightweightTypeReference toOwnedReference(/* @Nullable */ LightweightTypeReference result) { return result != null ? result.copyInto(getReferenceOwner()) : null; }
@Override protected void copyTypeArguments(ParameterizedTypeReference result, ITypeReferenceOwner owner) { super.copyTypeArguments(result, owner); FunctionTypeReference casted = (FunctionTypeReference) result; if (parameterTypes != null && !parameterTypes.isEmpty()) { for(LightweightTypeReference typeArgument: parameterTypes) { casted.addParameterType(typeArgument.copyInto(owner)); } } if (returnType != null) { casted.setReturnType(returnType.copyInto(owner)); } }
@Override protected LightweightTypeReference doCopyInto(ITypeReferenceOwner owner) { CompoundTypeReference result = owner.newCompoundTypeReference(synonym); if (components != null && !components.isEmpty()) { for(LightweightTypeReference typeArgument: components) { result.addComponent(typeArgument.copyInto(owner)); } } return result; }
@Override protected void doVisitMultiTypeReference(CompoundTypeReference reference) { List<LightweightTypeReference> components = reference.getMultiTypeComponents(); for(LightweightTypeReference component: components) { result.addComponent(component.copyInto(owner)); } } @Override
@Override public ITypeExpectation copyInto(ITypeReferenceOwner referenceOwner) { return new RootTypeExpectation(reference.copyInto(referenceOwner), getState()); } }
protected void mergeTypesIntoParent(ResolvedTypes parent) { Map<JvmIdentifiableElement, LightweightTypeReference> types = basicGetTypes(); if (!types.isEmpty()) { for(Map.Entry<JvmIdentifiableElement, LightweightTypeReference> entry: types.entrySet()) { LightweightTypeReference value = entry.getValue(); if (value instanceof UnboundTypeReference && super.isResolved(((UnboundTypeReference) value).getHandle())) { parent.setType(entry.getKey(), value.getUpperBoundSubstitute().copyInto(parent.getReferenceOwner())); } else { parent.setType(entry.getKey(), value.copyInto(parent.getReferenceOwner())); } } } }
@Override protected ParameterizedTypeReference doCopyInto(ITypeReferenceOwner owner) { LightweightTypeReference copiedOuter = outer.copyInto(owner); InnerTypeReference result = new InnerTypeReference(owner, copiedOuter, getType()); copyTypeArguments(result, owner); return result; }
@Override protected InnerFunctionTypeReference doCopyInto(ITypeReferenceOwner owner) { LightweightTypeReference copiedOuter = outer.copyInto(owner); InnerFunctionTypeReference result = new InnerFunctionTypeReference(owner, copiedOuter, getType()); copyTypeArguments(result, owner); return result; }
protected AbstractTypeExpectation createTypeExpectation(/* @Nullable */ LightweightTypeReference expectedType, AbstractTypeComputationState actualState, boolean returnType) { AbstractTypeExpectation result = null; if (expectedType != null) { LightweightTypeReference copied = expectedType.copyInto(actualState.getReferenceOwner()); result = new TypeExpectation(copied, actualState, returnType); } else { result = new NoExpectation(actualState, returnType); } return result; }
protected void resolveKnownArgumentType(XExpression argument, LightweightTypeReference knownType, /* @Nullable */ LightweightTypeReference declaredType, ITypeComputationState argumentState) { if (!(argumentState instanceof AbstractTypeComputationState)) throw new IllegalArgumentException("argumentState was " + argumentState); AbstractTypeComputationState castedArgumentState = (AbstractTypeComputationState) argumentState; ResolvedTypes resolvedTypes = getState().getResolvedTypes(); LightweightTypeReference copiedDeclaredType = declaredType != null ? declaredType.copyInto(resolvedTypes.getReferenceOwner()) : null; TypeExpectation expectation = new TypeExpectation(copiedDeclaredType, castedArgumentState, false); LightweightTypeReference copiedReceiverType = knownType.copyInto(resolvedTypes.getReferenceOwner()); // TODO should we use the result of #acceptType? resolvedTypes.acceptType(argument, expectation, copiedReceiverType, false, ConformanceFlags.UNCHECKED); if (copiedDeclaredType != null) resolveAgainstActualType(copiedDeclaredType, copiedReceiverType, castedArgumentState); }
protected AbstractTypeExpectation createTypeExpectation(/* @Nullable */ LightweightTypeReference expectedType, AbstractTypeComputationState actualState, boolean voidAllowed, boolean returnType) { AbstractTypeExpectation result = null; if (expectedType != null) { LightweightTypeReference copied = expectedType.copyInto(actualState.getReferenceOwner()); result = new RootTypeExpectation(copied, actualState); } else if (returnType) { result = new PendingRootExpectation(actualState, this, voidAllowed); } else { result = new RootNoExpectation(actualState, voidAllowed); } return result; }
@Override public TypeExpectation copyInto(ITypeReferenceOwner referenceOwner) { if (reference == null || reference.isOwnedBy(referenceOwner)) return this; return new TypeExpectation(reference.copyInto(referenceOwner), getState(), isReturnType()); }
@Override protected AbstractTypeExpectation createTypeExpectation(/* @Nullable */ LightweightTypeReference expectedType, AbstractTypeComputationState actualState, boolean returnType) { LightweightTypeReference type = expectedType != null ? expectedType.copyInto(actualState.getReferenceOwner()) : null; AbstractTypeExpectation result; if (type != null) { result = returnType ? new TypeExpectation(type, actualState, returnType) : new RootTypeExpectation(type, actualState); } else { result = returnType ? new NoExpectation(actualState, returnType) : new RootNoExpectation(actualState, true); } return result; }
@Override public void applyToComputationState() { ResolvedTypes resolvedTypes = getState().getResolvedTypes(); LightweightTypeReference actualType = resolvedTypes.getActualType(getFeature()); if (actualType == null) throw new IllegalStateException("Cannot determine actual type of already resolved implicit receiver"); LightweightTypeReference expectedReceiverType = new FeatureLinkHelper().getExpectedReceiverType(getOwner().getFeature(), actualType); if (expectedReceiverType != null) expectedReceiverType = expectedReceiverType.copyInto(resolvedTypes.getReferenceOwner()); TypeExpectation expectation = new TypeExpectation(expectedReceiverType, getState(), false); resolvedTypes.acceptType(getFeatureCall(), expectation, actualType.copyInto(resolvedTypes.getReferenceOwner()), false, ConformanceFlags.UNCHECKED); super.applyToComputationState(); }
@Override public void applyToComputationState() { ResolvedTypes resolvedTypes = getState().getResolvedTypes(); TypeExpectation expectation = new TypeExpectation(null, getState(), false); LightweightTypeReference actualType = resolvedTypes.getActualType(getFeature()); if (actualType == null) throw new IllegalStateException("Cannot determine actual type of already resolved implicit first argument"); resolvedTypes.acceptType(getFeatureCall(), expectation, actualType.copyInto(resolvedTypes.getReferenceOwner()), false, ConformanceFlags.UNCHECKED); super.applyToComputationState(); }
protected TypeData prepareMerge(TypeData typeData, ITypeReferenceOwner owner) { LightweightTypeReference typeReference = typeData.getActualType(); if (typeData.isOwnedBy(owner) && !(typeReference instanceof UnboundTypeReference)) return typeData; if (typeReference instanceof UnboundTypeReference && super.isResolved(((UnboundTypeReference) typeReference).getHandle())) { typeReference = typeReference.getUpperBoundSubstitute(); } return new TypeData(typeData.getExpression(), typeData.getExpectation().copyInto(owner), typeReference.copyInto(owner), typeData.getConformanceFlags(), typeData.isReturnType()); }