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

STC error If we use java.lang.Integer as Target Type with method generics

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.0-beta-3
    • 2.4.6
    • Static Type Checker
    • None
    • Groovy Version: 2.4.0-beta-3 JVM: 1.8.0_25 Vendor: Oracle Corporation OS: Mac OS X

    Description

      Target type inference makes an STC Error when the target is java.lang.Integer:

          static <T> T empty() {..}
          Integer i = empty(); //[Static type checking] - Cannot assign value of type T to variable of type java.lang.Integer
      

      Even if we specify the type explicitly, STC says same error:

              Integer i2 = TargetTypeTestGroovy.<Integer>empty(); // [Static type checking] - Cannot assign value of type T to variable of type java.lang.Integer
      

      If we use java.lang.String instead of java.lang.Integer, it's OK.
      Both of cases are worked well in java.

      Attachments

        1. TargetTypeTestGroovy.groovy
          1 kB
          UEHARA Junji
        2. TargetTypeTestJava.java
          1 kB
          UEHARA Junji

        Activity

          People

            pascalschumacher Pascal Schumacher
            uehaj UEHARA Junji
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: