From 9a4b5e7c306eb3f1c82ace10dd62576473b1dec1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 20 Jun 2015 00:44:47 +0200 Subject: Map outer fields to parameters in primary constructor Previously this was only done in secondary constructors; need to do it in primary constructor as well to avoid "reference to this before super" problems. --- tests/run/t8611b.scala | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/run/t8611b.scala (limited to 'tests/run/t8611b.scala') diff --git a/tests/run/t8611b.scala b/tests/run/t8611b.scala new file mode 100644 index 000000000..75114c2ae --- /dev/null +++ b/tests/run/t8611b.scala @@ -0,0 +1,54 @@ +sealed trait KrafsDescription + +abstract class NotWorkingEnum extends Enumeration { + + type ExtendedValue = Value with KrafsDescription + + def Enum(inDescription: String): ExtendedValue = { + new Val(nextId) with KrafsDescription { + } + } +} + +abstract class WorkingEnum extends Enumeration { + + type ExtendedValue = Value + + def Enum(inDescription: String): ExtendedValue = { + new Val(nextId) { + } + } +} + +object NotWorkingTab extends NotWorkingEnum { + val a = Enum("A") + val b = Enum("B") +} + +object WorkingTab extends WorkingEnum { + val a = Enum("A") + val b = Enum("B") +} + +object Test extends dotty.runtime.LegacyApp { + testGris() + testWorking() + + def testGris(): Unit = { + val pipp = NotWorkingTab.b + pipp match { + case NotWorkingTab.a => ??? + case NotWorkingTab.b => + case _ => ??? + } + } + + def testWorking(): Unit = { + val stuff = WorkingTab.a + stuff match { + case WorkingTab.a => + case WorkingTab.b => ??? + case _ => ??? + } + } +} -- cgit v1.2.3