diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2013-02-01 14:31:32 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2013-02-03 21:08:34 +0100 |
commit | f3cdf146709e0dd98533ee77e8ca2566380cb932 (patch) | |
tree | 54333250b47e1a744cb0b2454ea955bd9586b4c9 /src/compiler | |
parent | 7e836f83e2930755f5d6b896a140909eb686289d (diff) | |
download | scala-f3cdf146709e0dd98533ee77e8ca2566380cb932.tar.gz scala-f3cdf146709e0dd98533ee77e8ca2566380cb932.tar.bz2 scala-f3cdf146709e0dd98533ee77e8ca2566380cb932.zip |
Fix context for type checking early initializers
Before:
scala> class A { class C extends { val x: A = this } with AnyRef }
<console>:7: error: type mismatch;
found : A.this.C
required: A
class A { class C extends { val x: A = this } with AnyRef }
^
Note that the same thing is necessary and already done in Namers (see
def createNamer). The whole logic of when and how to create contexts
should be factored out and reused in Namer and Typer.
(
My Hobby [1]: detecting compiler by just looking at its soruce
[1] http://www.explainxkcd.com/wiki/index.php?title=Category:My_Hobby
)
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index a910d0b608..026c130a87 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2069,7 +2069,7 @@ trait Typers extends Modes with Adaptations with Tags { val sym = vdef.symbol val valDefTyper = { val maybeConstrCtx = - if (sym.isParameter && sym.owner.isConstructor) context.makeConstructorContext + if ((sym.isParameter || sym.isEarlyInitialized) && sym.owner.isConstructor) context.makeConstructorContext else context newTyper(maybeConstrCtx.makeNewScope(vdef, sym)) } |