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

STC claims non-existent Diamond in Anonymous Inner Class with Generics

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

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

    Description

      In following code, STC error with variable x.

      [Static type checking] - Cannot use diamond <> with anonymous inner classes

      But diamond is not used for x.

      interface Cls<T> {
          void foo(T t)
      }
      
      @groovy.transform.TypeChecked
      def func() {
          Cls<String> x = new Cls<String>(){ // [Static type checking] - Cannot use diamond <> with anonymous inner classes
                                             // why?
              void foo(String t){}
          }
          Cls y = new Cls<String>(){ // OK
              void foo(String t){}
          }
          Cls<String> z = new Cls<>(){ // [Static type checking] - Cannot use diamond <> with anonymous inner classes
                                       // fair enough
              public void foo(String t){}
          }
      }
      
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            melix Cédric Champeau
            uehaj UEHARA Junji
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment