From b26b725ef25a55a325b2c8a44c1ac67272632f14 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 3 May 2016 11:23:24 +0200 Subject: Handle MergeErrors in RefChecks Used to throw an uncaught merge error in checkAllOverrides when compiling i1240c.scala. --- tests/neg/i1240b.scala | 23 +++++++++-------------- tests/neg/i1240c.scala | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 tests/neg/i1240c.scala (limited to 'tests') diff --git a/tests/neg/i1240b.scala b/tests/neg/i1240b.scala index 6987dbc96..2d23db614 100644 --- a/tests/neg/i1240b.scala +++ b/tests/neg/i1240b.scala @@ -1,17 +1,12 @@ -// yet another variant, testing super accessors - -trait T { - def foo[B](x: C[B]): C[B] +// yet another variant, testing type parameters +trait T[X] { + def foo(x: X): X } -abstract class A extends T { - type C[X] - def foo[B](x: C[B]): C[B] = {println("A.C"); x} - def foo[B](x: List[B]): List[B] = {println("A.List"); x} +abstract class A[X] extends T[X] { + def foo(x: X): X = {println("A.X"); x} + def foo(x: String): String = {println("A.String"); x} } -trait U extends T { - def foo[B](x: C[B]): C[B] = super.foo[B](x) -} -object Test extends A with U { - type C[X] = List[X] - def main(args: Array[String]) = foo(List("")) +trait U[X] extends T[X] { + abstract override def foo(x: X): X = super.foo(x) } +object Test extends A[String] with U[String] // error: accidental override diff --git a/tests/neg/i1240c.scala b/tests/neg/i1240c.scala new file mode 100644 index 000000000..89fded292 --- /dev/null +++ b/tests/neg/i1240c.scala @@ -0,0 +1,17 @@ +// yet another variant, testing super accessors +// (but exhibited a crash in RefChecks). + +trait T { + def foo[B](x: C[B]): C[B] +} +abstract class A extends T { + type C[X] + def foo[B](x: C[B]): C[B] = {println("A.C"); x} + def foo[B](x: List[B]): List[B] = {println("A.List"); x} +} +trait U extends T { + abstract override def foo[B](x: C[B]): C[B] = super.foo[B](x) +} +object Test extends A with U { + type C[X] = List[X] +} -- cgit v1.2.3