@Override public boolean validate(IAcceptor<? super AbstractDiagnostic> result) { JvmIdentifiableElement implicitFeature = getFeature(); if (implicitFeature instanceof XVariableDeclaration) { XVariableDeclaration casted = (XVariableDeclaration) implicitFeature; if (casted.isWriteable()) { String message = getState().getResolver().getInvalidWritableVariableAccessMessage(casted, getFeatureCall(), getState().getResolvedTypes()); if (message != null) { AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.INVALID_MUTABLE_VARIABLE_ACCESS, message, getOwner(), XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, -1, null); result.accept(diagnostic); return false; } } if (EcoreUtil.isAncestor(casted, getFeatureCall())) { String message = String.format("The implicitly referenced variable %s may not have been initialized", implicitFeature.getSimpleName()); AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.ILLEGAL_FORWARD_REFERENCE, message, getOwner(), XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, -1, null); result.accept(diagnostic); return false; } } return true; }
@Override public boolean validate(IAcceptor<? super AbstractDiagnostic> result) { if (!getState().isInstanceContext()) { JvmIdentifiableElement implicitFeature = getFeature(); if (implicitFeature instanceof JvmType) { JvmIdentifiableElement feature = getState().getResolvedTypes().getLinkedFeature(getOwner()); if (feature == null || feature.eIsProxy() || !(feature instanceof JvmFeature)) return true; String message = "Cannot make an implicit reference to this from a static context"; AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.STATIC_ACCESS_TO_INSTANCE_MEMBER, message, getOwner(), XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, -1, null); result.accept(diagnostic); return false; } } return super.validate(result); }
@Override public void applyToComputationState() { state.acceptCandidate(implicit, this); getState().markAsRefinedTypeIfNecessary(this); }
@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); } }
return super.validate(result);