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

Compiler crashes with qualified "this" in auxiliary constructor

    Details

      Description

      The following will crash the compiler:

      class Foo (x: AnyRef) {
        def this() = {
          this(new Object { println(Foo.this) } )
        }
      }
      

      Presumably it's invalid to reference "this" before calling the primary constructor, but the compiler should give an error rather than crashing.

      I get a stack trace that begins with

      error: java.lang.Error: no-symbol does not have owner
      	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:32)
      	at scala.reflect.internal.Symbols$NoSymbol$.owner(Symbols.scala:2286)
      	at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.outerSelect(ExplicitOuter.scala:214)
      	at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.outerValue(ExplicitOuter.scala:200)
      	at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:478)
      	at scala.reflect.internal.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:1462)
      	at scala.reflect.internal.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:1462)
      ...
      

        Activity

        Hide
        Adriaan Moors added a comment -

        Jason, would you care to tackle another of those wannabe NPE's?

        Show
        Adriaan Moors added a comment - Jason, would you care to tackle another of those wannabe NPE's?
        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/commit/320a32b0

          People

          • Assignee:
            Jason Zaugg
            Reporter:
            Kipton Barros
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development