From d8356b6dc9221bfc38b1f167e5cfafcc9261f3d7 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 1 Mar 2014 13:17:05 +0100 Subject: Reorganization of template parents. Template parents always were constructor calls before. This is not correct because in a situation like the one elaborated in templateParents, the trait D has the class C as supertype, but it does not call its constructor (in fact, if we added a () parameter list to make it into a constructor this would be wrong because C takes parameters. Now parents can be either types or constructor calls. The logic in Namer and Typer that deals with parents is cleaned up. In particular, we now construct any synthetic class parent as a full type, before calling normalizeToClassRefs. This obviates the forwardRefs logic that needed to be done in a cleanup of Namers. Also added two more checks: (1) All parents except the first one must point to traits. (2) A trait may not call a parent class constructor. --- tests/pos/templateParents.scala | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/pos/templateParents.scala (limited to 'tests/pos/templateParents.scala') diff --git a/tests/pos/templateParents.scala b/tests/pos/templateParents.scala new file mode 100644 index 000000000..530f8c148 --- /dev/null +++ b/tests/pos/templateParents.scala @@ -0,0 +1,12 @@ +object templateParents { + +// traits do not call a constructor + class C[+T](x: T) + trait D extends C[String] + trait E extends C[Int] + new C("abc") with D + + //val x = new D with E + + //val y: C = x +} \ No newline at end of file -- cgit v1.2.3