aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/pos/implicit-scope-loop.scala17
-rw-r--r--tests/pos/implicit_cache.scala16
-rw-r--r--tests/pos/implicit_tparam.scala12
-rw-r--r--tests/run/overload_directly_applicable.check1
-rw-r--r--tests/run/overload_directly_applicable.scala16
5 files changed, 62 insertions, 0 deletions
diff --git a/tests/pos/implicit-scope-loop.scala b/tests/pos/implicit-scope-loop.scala
new file mode 100644
index 000000000..162f1a52c
--- /dev/null
+++ b/tests/pos/implicit-scope-loop.scala
@@ -0,0 +1,17 @@
+trait Dummy[T]
+
+
+trait A[T] extends B
+trait B extends Dummy[A[Int]]
+object B {
+ implicit def theB: B = new B {}
+ implicit def theA: A[Int] = new A[Int] {}
+}
+
+object Test {
+ def getB(implicit b: B) = b
+ def getA[T](implicit a: A[T]) = a
+
+ getB
+ getA
+} \ No newline at end of file
diff --git a/tests/pos/implicit_cache.scala b/tests/pos/implicit_cache.scala
new file mode 100644
index 000000000..d124876e0
--- /dev/null
+++ b/tests/pos/implicit_cache.scala
@@ -0,0 +1,16 @@
+class A
+object A {
+ implicit def theA: A = new A
+}
+class Foo[T]
+object Foo {
+ implicit def theFoo: Foo[A] = new Foo[A]
+}
+
+object Test {
+ def getFooA(implicit foo: Foo[A]) = foo
+ def getA(implicit a: A) = a
+
+ getFooA
+ getA
+}
diff --git a/tests/pos/implicit_tparam.scala b/tests/pos/implicit_tparam.scala
new file mode 100644
index 000000000..3b7cf9113
--- /dev/null
+++ b/tests/pos/implicit_tparam.scala
@@ -0,0 +1,12 @@
+class Foo[T]
+class Bar extends Foo[A]
+
+class A
+object A {
+ implicit val bar: Bar = new Bar
+}
+
+object Test {
+ def getBar(implicit bar: Bar) = bar
+ getBar
+}
diff --git a/tests/run/overload_directly_applicable.check b/tests/run/overload_directly_applicable.check
new file mode 100644
index 000000000..e2cf5e790
--- /dev/null
+++ b/tests/run/overload_directly_applicable.check
@@ -0,0 +1 @@
+C1
diff --git a/tests/run/overload_directly_applicable.scala b/tests/run/overload_directly_applicable.scala
new file mode 100644
index 000000000..d204d424a
--- /dev/null
+++ b/tests/run/overload_directly_applicable.scala
@@ -0,0 +1,16 @@
+class A
+class B
+
+class C1 {
+ def f(x: A): Unit = println("C1")
+}
+class C2 extends C1 {
+ def f(x: B): Unit = println("C2")
+}
+
+object Test extends C2 {
+ implicit def a2b(x: A): B = new B
+ def main(args: Array[String]): Unit = {
+ f(new A)
+ }
+}