protected LightweightTypeReference getActualType(/* @Nullable */ XExpression expression) { if (expression == null) return null; return state.getResolvedTypes().getActualType(expression); }
@Override protected ExpressionAwareStackedResolvedTypes pushTypes(XExpression expression) { return getResolvedTypes().pushTypes(expression); }
protected void markAsPropagated() { getResolvedTypes().setPropagatedType(this.expression); }
protected LightweightTypeReference getExpectedType(XExpression expression) { return state.getResolvedTypes().getExpectedType(expression); }
@Override protected UnboundTypeReference createUnboundTypeReference(JvmTypeParameter type) { UnboundTypeReference result = state.getResolvedTypes().createUnboundTypeReference(expression, type); return result; }
/** * Returns the actual type of the given element. Does not consider reassigned types. */ /* @Nullable */ protected LightweightTypeReference getActualType(JvmIdentifiableElement element, boolean ignoreReassignedTypes) { return state.getResolvedTypes().doGetActualType(element, ignoreReassignedTypes); }
@Override protected IFeatureLinkingCandidate getLinkingCandidate(XExpression target) { return state.getResolvedTypes().getLinkingCandidate((XAbstractFeatureCall) target); }
@Override public TypeComputationStateWithExpectation withExpectation(/* @Nullable */ LightweightTypeReference expectation) { return new ExpressionTypeComputationStateWithExpectation(getResolvedTypes(), getFeatureScopeSession(), this, expectation); }
protected void initializeMapping(JvmTypeParameter typeParameter, Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> result) { UnboundTypeReference typeReference = state.getResolvedTypes().createUnboundTypeReference(expression, typeParameter); result.put(typeParameter, new LightweightMergedBoundTypeArgument(typeReference, VarianceInfo.INVARIANT)); }
@Override public AbstractTypeComputationState withoutExpectation() { return new ExpressionTypeComputationStateWithExpectation(getResolvedTypes(), getFeatureScopeSession(), this, null); }
@Override public TypeCheckpointComputationState withTypeCheckpoint(/* @Nullable */ EObject context) { return new ExpressionAwareTypeCheckpointComputationState(getResolvedTypes(), getFeatureScopeSession(), this); }
protected LightweightTypeReference getDeclaredType(JvmIdentifiableElement feature) { LightweightTypeReference result = state.getResolvedTypes().getActualType(feature); if (result == null) { return getState().getReferenceOwner().newAnyTypeReference(); } return result; }
@Override public void applyToComputationState() { chosenCandidate.getState().getResolvedTypes().reassignLinkingInformation(chosenCandidate.getExpression(), this); chosenCandidate.applyToComputationState(); }
@Override public void applyToComputationState() { Candidate candidate = getPrimaryCandidate(); candidate.getState().getResolvedTypes().reassignLinkingInformation(candidate.getExpression(), this); candidate.applyToComputationState(); }
private boolean isStaticWithDeclaringType(XExpression syntacticReceiver) { if (isStatic() && syntacticReceiver instanceof XAbstractFeatureCall && !isExtension()) { IFeatureLinkingCandidate candidate = getState().getResolvedTypes().getLinkingCandidate((XAbstractFeatureCall) syntacticReceiver); if (candidate != null && candidate.isTypeLiteral()) { return true; } } return false; }
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 void applyPackageFragment(XMemberFeatureCall memberFeatureCall, JvmDeclaredType type) { XExpression target = memberFeatureCall.getMemberCallTarget(); state.getResolvedTypes().acceptType( target, new NoExpectation(state, false), state.getReferenceOwner().newParameterizedTypeReference(type), false, ConformanceFlags.CHECKED_SUCCESS); if (target instanceof XMemberFeatureCall) { applyPackageFragment((XMemberFeatureCall) target, type); } }
/** * Returns <code>true</code> if the method {@link Class#getClass()} is bound and * the receiver is a type literal. This may indicate a bug. */ protected boolean isGetClassOnTypeLiteral() { JvmIdentifiableElement feature = getFeature(); if (isGetClass(feature)) { XExpression receiver = getSyntacticReceiver(); if (receiver instanceof XAbstractFeatureCall) { IFeatureLinkingCandidate linkingCandidate = getState().getResolvedTypes().getLinkingCandidate((XAbstractFeatureCall) receiver); if (linkingCandidate != null && linkingCandidate.isTypeLiteral()) { return true; } } } return false; }
@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(); }
@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(); }