From fc319b002ff4bc82061250352f1568c612c70d72 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 26 Nov 2014 11:46:46 +0100 Subject: Allow refinements that refine already refined types. Previously, a double definition errorfor `T` was produced in a case like this: type T1 = C { T <: A } type T2 = T1 { T <: B } This was caused by the way T1 was treated in the refinement class that is used to typecheck the type. Desugaring of T2 with `refinedTypeToClass` would give trait extends T1 { type T <: B } and `normalizeToClassRefs` would transform this to: trait extends C { type T <: A; type T <: B } Hence the double definition. The new scheme desugars the rhs of `T2` to: trait extends C { this: T1 => type T <: B } which avoids the problem. Also, added tests that #232 (fix/boundsPropagation) indeed considers all refinements together when comparing refined types. --- test/dotc/tests.scala | 1 + 1 file changed, 1 insertion(+) (limited to 'test/dotc/tests.scala') diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 1c437e833..d592aaa24 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -106,6 +106,7 @@ class tests extends CompilerTest { @Test def neg_t1569_failedAvoid = compileFile(negDir, "t1569-failedAvoid", xerrors = 1) @Test def neg_cycles = compileFile(negDir, "cycles", xerrors = 8) @Test def neg_boundspropagation = compileFile(negDir, "boundspropagation", xerrors = 4) + @Test def neg_refinedSubtyping = compileFile(negDir, "refinedSubtyping", xerrors = 2) @Test def dotc = compileDir(dotcDir + "tools/dotc", twice)(allowDeepSubtypes) @Test def dotc_ast = compileDir(dotcDir + "tools/dotc/ast", twice) -- cgit v1.2.3