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

STC produces compile-time error on encoutering bounded type parameter with conditional

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.11, 4.0.3
    • Static Type Checker
    • None

    Description

      I have the following program:

      import java.util.function.Supplier;
      
      class A {
        static final <X extends Supplier<Number>> X m(X x, X y) {
          X z = (true) ? x : y
          z
        }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 10: [Static type checking] - Incompatible generic argument types. Cannot assign java.util.function.Supplier<java.lang.Object> to: X
       @ line 10, column 5.
             z
             ^
      
      1 error
      

      Compile successfully

      NOTE: The bug is triggered only when the type parameter is named other than `T`.

      Tested against master

      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: