From ba8d9ea2e4b887fc0faa1f636aade84c45292144 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 10 Mar 2014 11:06:49 +0100 Subject: Fix for t1002 Need to compile the self type of a class not in the context of the class members but one context further out. Reason: self type should not be able to see the members. --- src/dotty/tools/dotc/typer/Typer.scala | 2 +- tests/pos/t0002.scala | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/pos/t0002.scala diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 51eba3b02..6a1d279df 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -786,7 +786,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit val constr1 = typed(constr).asInstanceOf[DefDef] val parents1 = ensureConstrCall(ensureFirstIsClass( parents mapconserve typedParent, cdef.pos.toSynthetic)) - val self1 = typed(self).asInstanceOf[ValDef] + val self1 = typed(self)(ctx.outer).asInstanceOf[ValDef] // outer context where class memebers are not visible val localDummy = ctx.newLocalDummy(cls, impl.pos) val body1 = typedStats(body, localDummy)(inClassContext(self1.symbol)) checkNoDoubleDefs(cls) diff --git a/tests/pos/t0002.scala b/tests/pos/t0002.scala new file mode 100644 index 000000000..4c58ed3f4 --- /dev/null +++ b/tests/pos/t0002.scala @@ -0,0 +1,6 @@ +object main { + def main(args: Array[String]) = { + val b = true; + while (b == true) { } + } +} -- cgit v1.2.3