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

STC: instanceof guard for property loses type information

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.17, 4.0.11
    • 3.0.18, 4.0.12
    • None
    • None

    Description

      Consider the following:

      interface I {
          CharSequence getCharSequence()
      }
      
      void accept(CharSequence cs) { }
      
      void test(I i) {
          i.with {
              if (charSequence instanceof String) {
                  charSequence.toUpperCase()
                  accept(charSequence)
              }
          }
      }
      
      test({ -> 'works' } as I)
      

      Reports "Cannot find matching method script#accept(java.lang.Object)".

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: