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

Null-safe operator on lhs of comparison may lead to NPE with @CompileStatic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • None
    • 2.1.4
    • None
    • None

    Description

      The following code throws an NPE at runtime if compiled using @CompileStatic:

      class A {
        int foo() { 123 }
      }
      A a = null
      def bar = a?.foo() == 123 // will evaluate to false
      assert bar == false
      

      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: