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

Static compiler prefers private constructor over public if private matches better

    XMLWordPrintableJSON

    Details

      Description

      When constructing an AssertionError for example, it has a public constructor taking Object and a private constructor taking String. The static compiler "chooses" the private constructor over the public one and this results in a compile error.

      @groovy.transform.CompileStatic
      void doIt() {
        //Cannot call private constructor for java.lang.AssertionError. However, it should call AssertionError(Object)
        throw new AssertionError("abc")
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                daniel_sun Daniel Sun
                Reporter:
                gillius Jason Winnebeck
              • Votes:
                1 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: