diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-06-17 23:23:49 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-06-17 23:48:42 +0200 |
commit | 6aa5762fa0333625ec93378e2147649a8bafde34 (patch) | |
tree | 52c6c9c7d608e20d3c628d5f325977f834866a20 /src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | |
parent | 277dc7cf43566f8294bde4143107d9bfaa59e8e3 (diff) | |
download | scala-6aa5762fa0333625ec93378e2147649a8bafde34.tar.gz scala-6aa5762fa0333625ec93378e2147649a8bafde34.tar.bz2 scala-6aa5762fa0333625ec93378e2147649a8bafde34.zip |
SI-4842 Forbid access to in-construction this in self-constructor args
The check was already in place for direct calls to the super constructor.
Without this additional check, ExplicitOuter crashes, as it doesn't create
an $outer pointer for the constructor-arg scoped inner object, but expects
one to exist when transforming the Outer.this reference.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index bcf2ba6b71..fcb73f5947 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -222,7 +222,13 @@ trait ContextErrors { NormalTypeError(tree, "super constructor cannot be passed a self reference unless parameter is declared by-name") def SuperConstrArgsThisReferenceError(tree: Tree) = - NormalTypeError(tree, "super constructor arguments cannot reference unconstructed `this`") + ConstrArgsThisReferenceError("super", tree) + + def SelfConstrArgsThisReferenceError(tree: Tree) = + ConstrArgsThisReferenceError("self", tree) + + private def ConstrArgsThisReferenceError(prefix: String, tree: Tree) = + NormalTypeError(tree, s"$prefix constructor arguments cannot reference unconstructed `this`") def TooManyArgumentListsForConstructor(tree: Tree) = { issueNormalTypeError(tree, "too many argument lists for constructor invocation") |