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

STC is looking for the wrong constructor reference

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 5.0.0-alpha-1
    • None
    • None

    Description

      I have the following program

      class Foo {
        Foo(String d) {}
      }
      
      class Main {
        static final void test() {
              def x = java.util.stream.Collectors.groupingBy(Main::m) // works;
              def y = java.util.stream.Collectors.groupingBy(Foo::new) // fails;
        }
      
        static Foo m(String x) { return null; }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 8: [Static type checking] - Cannot find matching constructor Foo(java.lang.Object)
       @ line 8, column 56.
         .stream.Collectors.groupingBy(Foo::new)
                                       ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Tested against master (commit: 46722e7147ed529fe8817660617ac6af98ad6f54)

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              theosot Thodoris Sotiropoulos
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: