aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-02-13 15:36:57 +0100
committerGitHub <noreply@github.com>2017-02-13 15:36:57 +0100
commitb29783237c03ade1dd19cc564170c7a87d7b8b84 (patch)
tree9aa30b02b5267665bb204a38c4912c3b763f4375 /tests/neg
parent07b67a8416c501d7f7b37442f3a294d9f9252895 (diff)
parent36e91d4ed0a293943d66f409f7515953e961067f (diff)
downloaddotty-b29783237c03ade1dd19cc564170c7a87d7b8b84.tar.gz
dotty-b29783237c03ade1dd19cc564170c7a87d7b8b84.tar.bz2
dotty-b29783237c03ade1dd19cc564170c7a87d7b8b84.zip
Merge pull request #1931 from dotty-staging/fix-#1501
Fix #1501 - Check trait inheritance condition
Diffstat (limited to 'tests/neg')
-rw-r--r--tests/neg/i1501.scala28
-rw-r--r--tests/neg/i1653.scala2
2 files changed, 29 insertions, 1 deletions
diff --git a/tests/neg/i1501.scala b/tests/neg/i1501.scala
new file mode 100644
index 000000000..685566403
--- /dev/null
+++ b/tests/neg/i1501.scala
@@ -0,0 +1,28 @@
+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)
+ }
+}
+
+object Test2 {
+ class A
+ class SubA(x: Int) extends A
+ trait TA extends A
+ trait TSubA extends SubA(2) // error: trait TSubA may not call constructor of class SubA
+
+
+ class Foo extends TA with TSubA // error: missing argument for parameter x of constructor SubA:
+}
diff --git a/tests/neg/i1653.scala b/tests/neg/i1653.scala
index ab5369e5f..f21fc7d54 100644
--- a/tests/neg/i1653.scala
+++ b/tests/neg/i1653.scala
@@ -1,3 +1,3 @@
trait Foo {
- def foo() = new Unit with Foo // error
+ def foo() = new Unit with Foo // error: cannot extend final class Unit // error: illegal trait inheritance
}