summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-02-16 16:27:50 +0000
committerPaul Phillips <paulp@improving.org>2009-02-16 16:27:50 +0000
commitbb15b2d1d7e5caccc8b08a0f30c0e7f381921478 (patch)
tree6c2ea98fcfb031c17a3896cc3cb46261cbdcf094 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parentc25ec632d37c8c676e72da5ae792d02be7583232 (diff)
downloadscala-bb15b2d1d7e5caccc8b08a0f30c0e7f381921478.tar.gz
scala-bb15b2d1d7e5caccc8b08a0f30c0e7f381921478.tar.bz2
scala-bb15b2d1d7e5caccc8b08a0f30c0e7f381921478.zip
Fix for bug #473 and test case.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 7da10d7cc0..5e876cc8e7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1311,6 +1311,15 @@ trait Typers { self: Analyzer =>
}
val (superConstr, superArgs) = decompose(rhs)
assert(superConstr.symbol ne null)//debug
+
+ // an object cannot be allowed to pass a reference to itself to a superconstructor
+ // because of initialization issues; bug #473
+ for {
+ arg <- superArgs
+ val sym = arg.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 (superConstr.symbol.isPrimaryConstructor) {
val superClazz = superConstr.symbol.owner
if (!superClazz.hasFlag(JAVA)) {