summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-01-20 18:19:28 +0000
committerPaul Phillips <paulp@improving.org>2011-01-20 18:19:28 +0000
commita8a7481ab79430bef3ca9524538fa5217e0e14d8 (patch)
treec2c3dd346052b91c1186d773b073e4c4af96525f /src
parent919d4e1f3163496d725f7731d2ccd30d47ecee82 (diff)
downloadscala-a8a7481ab79430bef3ca9524538fa5217e0e14d8.tar.gz
scala-a8a7481ab79430bef3ca9524538fa5217e0e14d8.tar.bz2
scala-a8a7481ab79430bef3ca9524538fa5217e0e14d8.zip
Look even harder for attempts to sneak "this" i...
Look even harder for attempts to sneak "this" into superconstructor arguments, and improve positioning. Closes #4166, no review.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 3b9a845126..b5986f704a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1543,8 +1543,15 @@ trait Typers extends Modes {
// because of initialization issues; bug #473
for (arg <- superArgs ; tree <- arg) {
val sym = tree.symbol
- if (sym != null && sym.isModule && (sym.info.baseClasses contains clazz))
- error(rhs.pos, "super constructor cannot be passed a self reference unless parameter is declared by-name")
+ if (sym != null && (sym.info.baseClasses contains clazz)) {
+ if (sym.isModule)
+ error(tree.pos, "super constructor cannot be passed a self reference unless parameter is declared by-name")
+ tree match {
+ case This(qual) =>
+ error(tree.pos, "super constructor arguments cannot reference unconstructed `this`")
+ case _ => ()
+ }
+ }
}
if (superConstr.symbol.isPrimaryConstructor) {