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

Assignments to null of variables with generics lead to cryptic errors

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.1
    • Static Type Checker
    • None

    Description

      Using the following code:

      Map<String, Integer> foo = null
      Integer result = foo?.get('a')
      

      The type checker returns a cryptic error:

      [Static type checking] - Incompatible generic argument types. Cannot assign <unknown parameter type> to: java.util.Map <String, Integer>
       @ line 2, column 13.
                     Map<String, Integer> foo = null
                     ^
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: