[groovy] static trait method generic return type fixed (& test)
authorDaniil Ovchinnikov <daniil.ovchinnikov@jetbrains.com>
Tue, 25 Aug 2015 15:28:18 +0000 (18:28 +0300)
committerDaniil Ovchinnikov <daniil.ovchinnikov@jetbrains.com>
Tue, 25 Aug 2015 15:39:08 +0000 (18:39 +0300)
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrTraitMethod.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy

index a5dc08910beec848209ff1ccacf285d5d893ee12..6f40467d3cc862ee0d2e33bfd6cad50419718393 100644 (file)
@@ -17,13 +17,22 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic;
 
 import com.intellij.psi.PsiMethod;
 import com.intellij.psi.PsiSubstitutor;
+import com.intellij.psi.PsiType;
 
 /**
  * Created by Max Medvedev on 25/04/14
  */
 public class GrTraitMethod extends GrMethodWrapper {
+  private final PsiSubstitutor mySubstitutor;
+
   protected GrTraitMethod(PsiMethod method, PsiSubstitutor substitutor) {
     super(method, substitutor);
+    mySubstitutor = substitutor;
+  }
+
+  @Override
+  public PsiType getReturnType() {
+    return mySubstitutor.substitute(super.getReturnType());
   }
 
   public static GrTraitMethod create(PsiMethod method, PsiSubstitutor substitutor) {
index e63557be967d54d1f3c2179cb6826a172f892656..2dd52c720175bb84854d86aedc490f24421d0af0 100644 (file)
@@ -2222,4 +2222,14 @@ class X {
 ''', PsiMethod)
   }
 
+  void 'test static trait method generic return type'() {
+    def method = resolveByText('''
+trait GenericSourceTrait<E> {
+    static E someOtherStaticMethod() {null}
+}
+class SourceConcrete implements GenericSourceTrait<String> {})
+SourceConcrete.someOtherStatic<caret>Method()
+''', GrTraitMethod)
+    assertEquals "java.lang.String", method.returnType.canonicalText
+  }
 }