the declared return type should be taken into account
authorpeter <peter.gromov@jetbrains.com>
Fri, 10 Sep 2010 19:48:03 +0000 (20:48 +0100)
committerpeter <peter.gromov@jetbrains.com>
Fri, 10 Sep 2010 19:49:19 +0000 (20:49 +0100)
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrMethodBaseImpl.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GppFunctionalTest.groovy

index c2e8f81bc7fa89650e8f9a87431173e7eb892312..11d6a2184f4b3429a1f90b30fef894c84518fc5e 100644 (file)
@@ -163,6 +163,8 @@ public abstract class GrMethodBaseImpl<T extends NamedStub> extends GroovyBaseEl
       if (nominal != null && nominal.equals(PsiType.VOID)) return nominal;
 
       if (GppTypeConverter.hasTypedContext(method)) {
+        if (nominal != null) return nominal;
+
         return PsiType.getJavaLangObject(method.getManager(), method.getResolveScope());
       }
 
index c7137f8ad76fbd00159cc0d255cef4a5cea1d03e..898012026a3d2145342924e56e67b56b55f1717d 100644 (file)
@@ -521,6 +521,17 @@ new Foo().foo().substr<caret>a
     assertEmpty myFixture.completeBasic()
   }
 
+  public void testDeclaredReturnTypeInTypedContext() throws Exception {
+    configureGppScript """
+class Foo {
+  String getFoo() { "aaa" }
+}
+new Foo().foo.substr<caret>a
+"""
+    myFixture.completeBasic()
+    assertOrderedEquals myFixture.lookupElementStrings, "substring", "substring"
+  }
+
 }
 
 class GppProjectDescriptor extends DefaultLightProjectDescriptor {