Scala Programming Language
  1. Scala Programming Language
  2. SI-4859

Nested case class construction fails with "no legal prefix"

    Details

      Description

      ==========================================================================================
      This is a bug, affected versions (at least) 2.9.0.1, 2.9.1.RC1 and 2.10 (a recent nightly)
      ==========================================================================================

      Try to compile the following:

      object O

      { val o = C().CC(0) }

      case class C(s: String = "") {
      case class CC(ii: Int)

      { val ss = s }

      }

      Will result in
      error: java.lang.NullPointerException
      at scala.tools.nsc.typechecker.Typers$Typer.typedTypeConstructor(Typers.scala:4329)
      at scala.tools.nsc.typechecker.Typers$Typer.typedTypeConstructor(Typers.scala:4353)
      at scala.tools.nsc.typechecker.Typers$Typer.typedNew$1(Typers.scala:3185) ...

        Issue Links

          Activity

          Hide
          Paul Phillips added a comment -

          There is no constructor invocation in this code. The compiler is the only one throwing around constructor invocations. As far as the author of the code is concerned, it's two method calls. At the point where the compiler should be inserting a constructor call, it does have a stable prefix: "this".

          object O {
            // error: C is not a legal prefix for a constructor
            C().CC()
          }
          

          (From the example in my most recent comment containing code.)

          Show
          Paul Phillips added a comment - There is no constructor invocation in this code. The compiler is the only one throwing around constructor invocations. As far as the author of the code is concerned, it's two method calls. At the point where the compiler should be inserting a constructor call, it does have a stable prefix: "this". object O { // error: C is not a legal prefix for a constructor C().CC() } (From the example in my most recent comment containing code.)
          Hide
          Paul Phillips added a comment -

          ...and thusly do I reopen. The ball is in your court, good sir.

          Show
          Paul Phillips added a comment - ...and thusly do I reopen. The ball is in your court, good sir.
          Hide
          Adriaan Moors added a comment -

          right you are

          Show
          Adriaan Moors added a comment - right you are
          Show
          Jason Zaugg added a comment - https://github.com/scala/scala/pull/1710
          Show
          Jason Zaugg added a comment - https://github.com/scala/scala/pull/1864

            People

            • Assignee:
              Jason Zaugg
              Reporter:
              Heiko Seeberger
            • Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development