aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-02-21 10:28:56 +0100
committerMartin Odersky <odersky@gmail.com>2017-02-21 10:29:09 +0100
commit5dae5f2953438e8a1443075b44b310965c2cf863 (patch)
tree133a7fe8afed600767ad6b1cba4151ff87ea0e23 /tests/neg
parentf467be62da8978e506f58b702b84e74ef7ce09de (diff)
downloaddotty-5dae5f2953438e8a1443075b44b310965c2cf863.tar.gz
dotty-5dae5f2953438e8a1443075b44b310965c2cf863.tar.bz2
dotty-5dae5f2953438e8a1443075b44b310965c2cf863.zip
Fix #2000: Make implicit and non-implicit functions incomparable with <:<
Implicit and non-implicit functions are incomparable with <:<, but are treated as equivalent with `matches`. This means implicit and non-implicit functions of the same types override each other, but RefChecks will give an error because their types are not subtypes. Also contains a test for #2002.
Diffstat (limited to 'tests/neg')
-rw-r--r--tests/neg/customArgs/i2002.scala4
-rw-r--r--tests/neg/i2000.scala23
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/neg/customArgs/i2002.scala b/tests/neg/customArgs/i2002.scala
new file mode 100644
index 000000000..5561b77b8
--- /dev/null
+++ b/tests/neg/customArgs/i2002.scala
@@ -0,0 +1,4 @@
+class Test {
+ def foo(i: Int): Int = i
+ def foo(implicit i: Int): Int = i // error
+}
diff --git a/tests/neg/i2000.scala b/tests/neg/i2000.scala
new file mode 100644
index 000000000..aa1250f08
--- /dev/null
+++ b/tests/neg/i2000.scala
@@ -0,0 +1,23 @@
+object test1 {
+ class C[A] { def foo(a: A) = "c" }
+ class D extends C[String] { override def foo(implicit s: String) = "d" } // error
+}
+
+object test2 {
+ class C[A] { final def foo(a: A) = "c" }
+ class D extends C[String] { def foo(implicit s: String) = "d" } // error
+ object Test {
+ def main(args: Array[String]) =
+ new D
+ }
+}
+
+object test3 {
+ class A {
+ def foo(implicit i: Int): Int = i + i
+ }
+
+ class B extends A {
+ override def foo(i: Int): Int = i // error
+ }
+}