Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9945

STC: Cannot find matching method when using Generics

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

      Description

      I have the following Groovy program.

      interface I1<X, Y> {}
      
      interface I2 extends I1<Character, Character> {}
      
      class Foo<X, Y> implements I2 {
        public void foo(X x, Y y) {}
      }
      
      class Bar<X, Y> extends Foo<X, Y> {}
      
      @groovy.transform.TypeChecked
      class Main {
        public static void foo() {
          new Bar<Float, Integer>().foo((Float) 1.4, -1)
        }
      }
      
      

      Actual Behavior

      The program does not compile, and I get the following error.

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Main.groovy: 14: [Static type checking] - Cannot find matching method Bar#foo(java.lang.Float, java.lang.Integer). Please check if the declared type is correct and if the method exists.
       @ line 14, column 5.
             new Bar<Float, Integer>().foo((Float) 1.4, -1)
             ^
      
      1 error
      

      Expected Behavior

      Compile successfully.

        Attachments

          Activity

            People

            • Assignee:
              emilles Eric Milles
              Reporter:
              schaliasos Stefanos Chaliasos

              Dates

              • Created:
                Updated:
                Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0h
              0h
              Logged:
              Time Spent - 0.5h
              0.5h

                Issue deployment