From ba66bd47f08e1adf3d44f578452a5113948cb988 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 2 Feb 2017 14:55:06 +1100 Subject: Fix #1501 - Check trait inheritance condition We need to check a coherence condition between the superclass of a trait and the superclass of an inheriting class or trait. --- tests/neg/i1501.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/neg/i1501.scala (limited to 'tests/neg') diff --git a/tests/neg/i1501.scala b/tests/neg/i1501.scala new file mode 100644 index 000000000..045f2be1d --- /dev/null +++ b/tests/neg/i1501.scala @@ -0,0 +1,18 @@ +class A { + def foo: Int = 1 +} + +trait B extends A + +abstract class D { + def foo: Int +} + +class C extends D with B // error: illegal trait inheritance +trait E extends D with B // error: illegal trait inheritance + +object Test { + def main(args: Array[String]): Unit = { + println(new C().foo) + } +} -- cgit v1.2.3