From f3cdf146709e0dd98533ee77e8ca2566380cb932 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Fri, 1 Feb 2013 14:31:32 +0100 Subject: Fix context for type checking early initializers Before: scala> class A { class C extends { val x: A = this } with AnyRef } :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 ) --- test/files/pos/presuperContext.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/files/pos/presuperContext.scala (limited to 'test') diff --git a/test/files/pos/presuperContext.scala b/test/files/pos/presuperContext.scala new file mode 100644 index 0000000000..cc34263073 --- /dev/null +++ b/test/files/pos/presuperContext.scala @@ -0,0 +1,13 @@ +class A { + class C extends { val x: A = this } with AnyRef +} + +class B(x: Int) + +class D { + class C(x: Int) extends B({val test: D = this; x}) { + def this() { + this({val test: D = this; 1}) + } + } +} -- cgit v1.2.3