@Override protected LightweightTypeReference acceptType(ResolvedTypes types, AbstractTypeExpectation expectation, LightweightTypeReference type, boolean returnType, int flags) { return types.acceptType(getNonNullRootExpression(), expectation, type, returnType, flags); }
@Override protected void acceptType(XExpression expression, TypeData typeData) { getParent().acceptType(expression, typeData); }
@Override protected void acceptType(XExpression expression, TypeData typeData) { getParent().acceptType(expression, typeData); }
protected void mergeExpressionTypesIntoParent(ResolvedTypes parent) { Map<XExpression, List<TypeData>> expressionTypes = basicGetExpressionTypes(); if (!expressionTypes.isEmpty()) { for(Map.Entry<XExpression, List<TypeData>> entry: expressionTypes.entrySet()) { List<TypeData> list = entry.getValue(); for (int i = 0, size = list.size(); i < size; i++) { parent.acceptType(entry.getKey(), prepareMerge(list.get(i), parent.getReferenceOwner())); } } } }
@Override protected LightweightTypeReference acceptType(XExpression alreadyHandled, ResolvedTypes types, AbstractTypeExpectation expectation, LightweightTypeReference type, boolean returnType, int flags) { if (alreadyHandled != getRootExpression()) return types.acceptType(getNonNullRootExpression(), expectation, type, returnType, flags); return type; }
@Override protected LightweightTypeReference acceptType(ResolvedTypes resolvedTypes, AbstractTypeExpectation expectation, LightweightTypeReference type, boolean returnType, int flags) { LightweightTypeReference result = resolvedTypes.acceptType(expression, expectation, type, returnType, flags); getParent().acceptType(expression, resolvedTypes, expectation, type, returnType, flags); return result; }
@Override protected LightweightTypeReference acceptType(XExpression expression, ResolvedTypes resolvedTypes, AbstractTypeExpectation expectation, LightweightTypeReference type, boolean returnType, int flags) { if (expression != this.expression) { LightweightTypeReference result = resolvedTypes.acceptType(this.expression, expectation, type, returnType, flags); getParent().acceptType(this.expression, resolvedTypes, expectation, type, returnType, flags); return result; } return getParent().acceptType(expression, resolvedTypes, expectation, type, returnType, flags); }
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); }
actualType = substitutor.substitute(type).getUpperBoundSubstitute(); acceptType(expression, new TypeData(expression, expectation, actualType, flags, returnType)); return actualType;
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); } }
@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() { 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); } }
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() { 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); } } } }
resolvedTypes.acceptType(receiver, expectation, receiverType.copyInto(resolvedTypes.getReferenceOwner()), false, ConformanceFlags.UNCHECKED);