use of org.eclipse.xtext.xbase.typesystem.override.BottomResolvedOperation in project xtext-xtend by eclipse.
the class XtendReentrantTypeResolver method getReturnTypeOfOverriddenOperation.
@Override
protected LightweightTypeReference getReturnTypeOfOverriddenOperation(JvmOperation operation, ResolvedTypes resolvedTypes, IFeatureScopeSession session) {
if (operation.getVisibility() == JvmVisibility.PRIVATE)
return null;
if (InferredTypeIndicator.isInferred(operation.getReturnType())) {
LightweightTypeReference declaringType = resolvedTypes.getActualType(operation.getDeclaringType());
if (declaringType == null) {
throw new IllegalStateException("Cannot determine declaring type of operation: " + operation);
}
BottomResolvedOperation resolvedOperation = new BottomResolvedOperation(operation, declaringType, overrideTester);
List<IResolvedOperation> overriddenMethods = resolvedOperation.getOverriddenAndImplementedMethods();
if (overriddenMethods.isEmpty())
return null;
IResolvedOperation overriddenMethod = overriddenMethods.get(0);
JvmOperation declaration = overriddenMethod.getDeclaration();
XExpression inferredFrom = getInferredFrom(declaration.getReturnType());
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=439535
if (inferredFrom != null && (inferredFrom == getInferredFrom(operation.getReturnType()) || isHandled(inferredFrom))) {
return null;
}
LightweightTypeReference result = overriddenMethod.getResolvedReturnType();
return result;
}
return null;
}
use of org.eclipse.xtext.xbase.typesystem.override.BottomResolvedOperation in project xtext-xtend by eclipse.
the class SuperMemberImplementorTest method checkOverrideMethodCode.
protected void checkOverrideMethodCode(String operationName, String overrideCode) {
StringBuilderBasedAppendable appendable = new StringBuilderBasedAppendable();
LightweightTypeReference contextType = getContextType();
IResolvedOperation resolvedOperation = new BottomResolvedOperation((JvmOperation) findExecutable(implementedInterface, operationName), contextType, new OverrideTester());
implementor.appendOverrideFunction(xtendClass, resolvedOperation, appendable);
String code = appendable.toString();
if (!equalsIgnoreWhitespace(overrideCode, code))
assertEquals(overrideCode, code);
}
use of org.eclipse.xtext.xbase.typesystem.override.BottomResolvedOperation in project xtext-xtend by eclipse.
the class AbstractOverloadedInstanceMethodTest method linksTo.
protected void linksTo(final String invocation, final String method) {
try {
final XtendFile file = this.file(this.inMethodBody(invocation), false);
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
final XtendClass c = ((XtendClass) _head);
XtendMember _head_1 = IterableExtensions.<XtendMember>head(c.getMembers());
final XtendFunction m = ((XtendFunction) _head_1);
XExpression _expression = m.getExpression();
final XBlockExpression body = ((XBlockExpression) _expression);
XExpression _last = IterableExtensions.<XExpression>last(body.getExpressions());
final XAbstractFeatureCall featureCall = ((XAbstractFeatureCall) _last);
JvmIdentifiableElement _feature = featureCall.getFeature();
final JvmOperation operation = ((JvmOperation) _feature);
final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, file);
final ParameterizedTypeReference declaration = owner.newParameterizedTypeReference(operation.getDeclaringType());
final BottomResolvedOperation resolved = new BottomResolvedOperation(operation, declaration, this.overrideTester);
Assert.assertEquals(method, resolved.getSimpleSignature());
Assert.assertTrue(IterableExtensions.join(file.eResource().getErrors(), "\n"), file.eResource().getErrors().isEmpty());
Assert.assertNotNull(featureCall.getImplicitReceiver());
Assert.assertNull(featureCall.getImplicitFirstArgument());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.xbase.typesystem.override.BottomResolvedOperation in project xtext-xtend by eclipse.
the class AbstractOverloadedStaticMethodTest method linksTo.
protected void linksTo(final String invocation, final String method) {
try {
final XtendFile file = this.file(this.inMethodBody(invocation), false);
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
final XtendClass c = ((XtendClass) _head);
XtendMember _head_1 = IterableExtensions.<XtendMember>head(c.getMembers());
final XtendFunction m = ((XtendFunction) _head_1);
XExpression _expression = m.getExpression();
final XBlockExpression body = ((XBlockExpression) _expression);
XExpression _last = IterableExtensions.<XExpression>last(body.getExpressions());
final XAbstractFeatureCall featureCall = ((XAbstractFeatureCall) _last);
JvmIdentifiableElement _feature = featureCall.getFeature();
final JvmOperation operation = ((JvmOperation) _feature);
final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, file);
final ParameterizedTypeReference declaration = owner.newParameterizedTypeReference(operation.getDeclaringType());
final BottomResolvedOperation resolved = new BottomResolvedOperation(operation, declaration, this.overrideTester);
Assert.assertEquals(method, resolved.getSimpleSignature());
Assert.assertTrue(IterableExtensions.join(file.eResource().getErrors(), "\n"), file.eResource().getErrors().isEmpty());
Assert.assertNull(featureCall.getImplicitReceiver());
Assert.assertNull(featureCall.getImplicitFirstArgument());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations