use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterReference_9.
@Test
public void testTypeParameterReference_9() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class X<Y> { def foo(Iterable<Y> iter) { for(y: iter) { return y } }}").getXtendTypes().get(0)).getMembers().get(0);
JvmOperation operation = associator.getDirectlyInferredOperation(func);
JvmTypeReference returnType = operation.getReturnType();
assertEquals("Y", returnType.getIdentifier());
JvmTypeReference paramType = operation.getParameters().get(0).getParameterType();
assertEquals("java.lang.Iterable<Y>", 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 LinkingErrorTest method testNoException_01.
@Test
public void testNoException_01() throws Exception {
XtendFunction function = function("def noException() {\n" + // exception case is Integeri
" val closure = [Integeri| return i]\n" + " for (x : 1..100) closure.apply(x)\n" + " }");
JvmTypeReference type = associations.getDirectlyInferredOperation(function).getReturnType();
assertTrue(type.getType() instanceof JvmVoid);
assertFalse(type.getType().eIsProxy());
assertNoExceptions(function);
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterReference_18.
@Test
public void testTypeParameterReference_18() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class X<Z> { def foo() { new X }}").getXtendTypes().get(0)).getMembers().get(0);
JvmOperation operation = associator.getDirectlyInferredOperation(func);
JvmTypeReference returnType = operation.getReturnType();
assertEquals("X<java.lang.Object>", 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());
}
Aggregations