aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-07-18 13:04:17 +0200
committerGitHub <noreply@github.com>2016-07-18 13:04:17 +0200
commita307a90c1a5f498087612894c3a923a299d02a66 (patch)
tree04658afa9c262f0be0d690290dae38ed72c325a3 /tests
parent9da40cb84d613bcea3a0e0890b2e53129fe60bc6 (diff)
parent762375cb41c23fc912dd9c9e1cc273b706a65631 (diff)
downloaddotty-a307a90c1a5f498087612894c3a923a299d02a66.tar.gz
dotty-a307a90c1a5f498087612894c3a923a299d02a66.tar.bz2
dotty-a307a90c1a5f498087612894c3a923a299d02a66.zip
Merge pull request #1389 from dotty-staging/fix-#1381
Changes to overloading
Diffstat (limited to 'tests')
-rw-r--r--tests/pos/hkgadt.scala9
-rw-r--r--tests/pos/i618.scala3
-rw-r--r--tests/pos/t2660.scala (renamed from tests/neg/t2660.scala)8
-rw-r--r--tests/run/t1381.check7
-rw-r--r--tests/run/t1381.scala59
5 files changed, 80 insertions, 6 deletions
diff --git a/tests/pos/hkgadt.scala b/tests/pos/hkgadt.scala
new file mode 100644
index 000000000..ac8caa6f3
--- /dev/null
+++ b/tests/pos/hkgadt.scala
@@ -0,0 +1,9 @@
+object HKGADT {
+ sealed trait Foo[F[_]]
+ final case class Bar() extends Foo[List]
+
+ def frob[F[_]](foo: Foo[F]) =
+ foo match {
+ case Bar() => ()
+ }
+}
diff --git a/tests/pos/i618.scala b/tests/pos/i618.scala
new file mode 100644
index 000000000..70be56cc2
--- /dev/null
+++ b/tests/pos/i618.scala
@@ -0,0 +1,3 @@
+class C(val f: Any*)
+
+class D(override val f: Nothing) extends C(f)
diff --git a/tests/neg/t2660.scala b/tests/pos/t2660.scala
index 17fe26258..695db67b9 100644
--- a/tests/neg/t2660.scala
+++ b/tests/pos/t2660.scala
@@ -1,5 +1,3 @@
-// Dotty deviation. The calls here now are classified as ambiguous.
-
package hoho
class G
@@ -22,9 +20,7 @@ class A[T](x: T) {
object T {
def main(args: Array[String]): Unit = {
implicit def g2h(g: G): H = new H
- new A[Int](new H, 23) // error
- // in the context here, either secondary constructor is applicable
- // to the other, due to the implicit in scope. So the call is ambiguous.
+ new A[Int](new H, 23)
}
}
@@ -40,7 +36,7 @@ object X {
object T2 {
def main(args: Array[String]): Unit = {
implicit def g2h(g: G): H = new H
- X.f(new H, 23) // error
+ X.f(new H, 23)
}
}
diff --git a/tests/run/t1381.check b/tests/run/t1381.check
new file mode 100644
index 000000000..84aec1df2
--- /dev/null
+++ b/tests/run/t1381.check
@@ -0,0 +1,7 @@
+4
+3
+2
+A
+B
+frA
+frB
diff --git a/tests/run/t1381.scala b/tests/run/t1381.scala
new file mode 100644
index 000000000..c7f49c6c3
--- /dev/null
+++ b/tests/run/t1381.scala
@@ -0,0 +1,59 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ Test1.test()
+ Test2.test()
+ Test3.test()
+ }
+}
+
+object Test1 {
+ class Bar[T](n: Int) {
+ println(n)
+ }
+ implicit def const[T](x: T): Bar[T] = new Bar[T](1)
+
+ def bar[T](e: T): Any = new Bar[T](2)
+ def bar[T](e: Bar[T]): Any = new Bar[T](3)
+
+ val b: Bar[Int] = new Bar[Int](4)
+
+ def test(): Unit = {
+ bar(b)
+ bar(5)
+ }
+}
+
+object Test2 {
+ trait A; trait B
+ class C1 {
+ def f(x: A): Unit = println("A")
+ }
+ class C2 extends C1 {
+ def f(x: B): Unit = println("B")
+ }
+ object Test extends C2 with App {
+ implicit def a2b(x: A): B = new B {}
+ def test(): Unit = {
+ f(new A {})
+ f(new B {})
+ }
+ }
+ def test(): Unit = Test.test()
+}
+
+object Test3 {
+ trait A; trait B
+ class C extends A with B
+ def fr(x: A): A = {
+ println("frA")
+ x
+ }
+ def fr(x: B): B = {
+ println("frB")
+ x
+ }
+ def test(): Unit = {
+ val a: A = fr(new C)
+ val b: B = fr(new C)
+ }
+}