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

STC: no error for if (!(x instanceof T)) x.methodFromT()

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.19, 2.5.10, 3.0.2
    • Fix Version/s: 4.0.0-alpha-1, 3.0.3
    • Component/s: None
    • Labels:
      None

      Description

      Variant of GROOVY-6429, GROOVY-8321, GROOVY-8412, GROOVY-8523 and GROOVY-8645.

      Consider the following:

      @groovy.transform.TypeChecked
      void test(x) {
        if (!(x instanceof Number)) {
          x.byteValue() // accidentally had this and got no compiler error; STC has Number for typeof(x)
        } else {
          // ...
        }
      }
      

      Since the inferred type of "x" inside then block is Number, the IDE shows code assist for Number, which is misleading.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                emilles Eric Milles
                Reporter:
                emilles Eric Milles
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h