protected AbstractTypeExpectation createTypeExpectation(/* @Nullable */ LightweightTypeReference expectedType, AbstractTypeComputationState actualState) { AbstractTypeExpectation result = null; if (expectedType != null) { throw new IllegalArgumentException("expectedType should be null"); } result = new TypeExpectation(null, actualState, false); return result; }
@Override protected List<AbstractTypeExpectation> getExpectations(AbstractTypeComputationState actualState, boolean returnType) { LightweightTypeReference voidType = getExpectedType(); AbstractTypeExpectation result = returnType ? new TypeExpectation(voidType, actualState, returnType) : new RootTypeExpectation(voidType, actualState); return Collections.singletonList(result); }
@Override protected List<AbstractTypeExpectation> getExpectations(AbstractTypeComputationState actualState, boolean returnType) { LightweightTypeReference type = getExpectedType(); AbstractTypeExpectation result = returnType ? new TypeExpectation(type, actualState, returnType) : new RootTypeExpectation(type, actualState); return Collections.singletonList(result); }
@Override protected List<AbstractTypeExpectation> getExpectations(AbstractTypeComputationState actualState, boolean returnType) { LightweightTypeReference type = getExpectedType(); AbstractTypeExpectation result = returnType ? new TypeExpectation(type, actualState, returnType) : new RootTypeExpectation(type, actualState); return Collections.singletonList(result); }
@Override public void refineExpectedType(XExpression expression, LightweightTypeReference expectation) { TypeExpectation typeExpectation = new TypeExpectation(expectation, this, false); getResolvedTypes().refineExpectedType(expression, typeExpectation); }
@Override protected List<AbstractTypeExpectation> getExpectations(AbstractTypeComputationState actualState, boolean returnType) { AbstractTypeExpectation result = null; if (expectedType != null) { result = returnType ? new TypeExpectation(expectedType, actualState, returnType) : new RootTypeExpectation(expectedType, actualState); } else { result = returnType ? new NoExpectation(actualState, returnType) : new RootNoExpectation(actualState, true); } return Collections.singletonList(result); }
@Override protected List<AbstractTypeExpectation> getExpectations(AbstractTypeComputationState actualState, boolean returnType) { LightweightTypeReference type = getExpectedType(); 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 Collections.singletonList(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; }
@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; }
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); }
@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 void resolveKnownArgumentType(XExpression argument, LightweightTypeReference knownType, /* @Nullable */ LightweightTypeReference declaredType, ITypeComputationState argumentState) { if (!(argumentState instanceof AbstractLinkingCandidate.ArgumentTypeComputationState)) throw new IllegalArgumentException("argumentState was " + argumentState); AbstractLinkingCandidate<?>.ArgumentTypeComputationState castedArgumentState = (AbstractLinkingCandidate<?>.ArgumentTypeComputationState) 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? int defaultFlags = castedArgumentState.getDefaultFlags(); resolvedTypes.acceptType(argument, expectation, copiedReceiverType, false, ConformanceFlags.UNCHECKED | defaultFlags); if (copiedDeclaredType != null) resolveAgainstActualType(copiedDeclaredType, copiedReceiverType, castedArgumentState); }
@Override public void applyToComputationState() { super.applyToComputationState(); XExpression receiver = getReceiver(); if (receiver != null) { LightweightTypeReference receiverType = getReceiverType(); if (receiverType == null) { throw new IllegalStateException("Cannot determine receiver's type"); } LightweightTypeReference expectedReceiverType = new FeatureLinkHelper().getExpectedReceiverType(getFeature(), receiverType); TypeExpectation refinedExpectation = new TypeExpectation(expectedReceiverType, getState(), false); demandComputedTypes.refineExpectedType(receiver, refinedExpectation); } demandComputedTypes.mergeIntoParent(); } };
@Override public void applyToComputationState() { super.applyToComputationState(); XAbstractFeatureCall featureCall = getFeatureCall(); if (featureCall instanceof XMemberFeatureCall) { XExpression target = ((XMemberFeatureCall) featureCall).getMemberCallTarget(); if (target == null || !(target instanceof XAbstractFeatureCall)) throw new IllegalStateException(); XAbstractFeatureCall targetFeatureCall = (XAbstractFeatureCall) target; ResolvedTypes resolvedTypes = getState().getResolvedTypes(); LightweightTypeReference targetType = resolvedTypes.getActualType(targetFeatureCall.getFeature()); if (targetType == null) { throw new IllegalStateException(); } TypeExpectation expectation = new TypeExpectation(null, getState(), false); resolvedTypes.acceptType(targetFeatureCall, expectation, targetType.copyInto(resolvedTypes.getReferenceOwner()), false, ConformanceFlags.UNCHECKED); } }
@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(); }
protected void applyImplicitReceiver() { if (!isStatic()) { XExpression implicitReceiver = getImplicitReceiver(); if (implicitReceiver != null) { ResolvedTypes resolvedTypes = getState().getResolvedTypes(); LightweightTypeReference receiverType = getImplicitReceiverType(); if (receiverType == null) { throw new IllegalStateException("Cannot determine the receiver's type"); } LightweightTypeReference expectedReceiverType = new FeatureLinkHelper().getExpectedReceiverType(getFeature(), receiverType); if (expectedReceiverType != null) expectedReceiverType = expectedReceiverType.copyInto(resolvedTypes.getReferenceOwner()); if (receiverType.isSynonym()) { receiverType = receiverType.getMultiTypeComponents().get(0); } TypeExpectation expectation = new TypeExpectation(expectedReceiverType, getState(), false); resolvedTypes.acceptType(implicitReceiver, expectation, receiverType.copyInto(resolvedTypes.getReferenceOwner()), false, ConformanceFlags.UNCHECKED); if (implicitReceiver instanceof XAbstractFeatureCall) { new ImplicitReceiver(getFeatureCall(), (XAbstractFeatureCall) implicitReceiver, getState()).applyToComputationState(); } else { throw new IllegalStateException("unexpected implicit receiver, was: " + implicitReceiver); } } } }
TypeExpectation refinedExpectation = new TypeExpectation(expectedReceiverType, getState(), false); demandComputedTypes.refineExpectedType(receiver, refinedExpectation);
throw new IllegalStateException("Cannot determine type of receiver "+ receiver); TypeExpectation expectation = new TypeExpectation(null, getState(), false); resolvedTypes.acceptType(receiver, expectation, receiverType.copyInto(resolvedTypes.getReferenceOwner()), false, ConformanceFlags.UNCHECKED);