diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 9 |
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)) { |