use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterReference_11.
@Test
public void testTypeParameterReference_11() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class X<Z> implements Iterable<Z> { def Iterable<Z> foo() { val result = new X result }}").getXtendTypes().get(0)).getMembers().get(0);
JvmOperation operation = associator.getDirectlyInferredOperation(func);
JvmTypeReference returnType = operation.getReturnType();
assertEquals("java.lang.Iterable<Z>", returnType.getIdentifier());
LightweightTypeReference bodyType = getType(func.getExpression());
assertEquals("X<Z>", bodyType.getIdentifier());
LightweightTypeReference bodyReturnType = getReturnType(func.getExpression());
assertEquals("X<Z>", bodyReturnType.getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeReference_0.
@Test
public void testTypeReference_0() throws Exception {
XtendFunction func = function("def =>java.lang.Boolean foo() {[|true]}");
XFunctionTypeRef type = (XFunctionTypeRef) func.getReturnType();
JvmTypeReference returnType = type.getReturnType();
assertEquals("java.lang.Boolean", returnType.getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeReference_withImport.
@Test
public void testTypeReference_withImport() throws Exception {
XtendFunction func = (XtendFunction) clazz("import java.lang.* class X { def (String)=>Boolean foo() {[|true]} }").getMembers().get(0);
XFunctionTypeRef type = (XFunctionTypeRef) func.getReturnType();
JvmTypeReference returnType = type.getReturnType();
assertEquals("java.lang.Boolean", returnType.getIdentifier());
JvmTypeReference paramType = type.getParamTypes().get(0);
assertEquals("java.lang.String", paramType.getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class ParserTest method testBug427257.
@Test
public void testBug427257() throws Exception {
XtendClass clazz = clazz("class C { def Iterable<=>String> m() { emptyList } }");
assertEquals(1, clazz.getMembers().size());
XtendFunction m = (XtendFunction) clazz.getMembers().get(0);
JvmParameterizedTypeReference returnType = (JvmParameterizedTypeReference) m.getReturnType();
JvmTypeReference typeArgument = returnType.getArguments().get(0);
assertTrue(typeArgument instanceof XFunctionTypeRef);
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class ValidationBug433213Test method test_01.
@Test
public void test_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("new Object {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("def <T> T m2() {}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.parser.parse(_builder);
final XtendTypeDeclaration c = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head = IterableExtensions.<XtendMember>head(c.getMembers());
final XtendFunction m = ((XtendFunction) _head);
XExpression _expression = m.getExpression();
final XBlockExpression body = ((XBlockExpression) _expression);
XExpression _head_1 = IterableExtensions.<XExpression>head(body.getExpressions());
final AnonymousClass anon = ((AnonymousClass) _head_1);
XtendMember _head_2 = IterableExtensions.<XtendMember>head(anon.getMembers());
final XtendFunction m2 = ((XtendFunction) _head_2);
final JvmTypeReference returnType = m2.getReturnType();
final JvmType t = returnType.getType();
Assert.assertNotNull("notNull", t);
Assert.assertFalse("t.eIsProxy", t.eIsProxy());
this.helper.assertNoErrors(file);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations