aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-04-23 13:38:55 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-04-23 13:38:55 +0200
commitc01389d170bb0f1c8a925a25c145396007a75106 (patch)
tree40d0117154755585d1208ef28c67d11bffe6b238 /tests
parente3449e9fdbb3801eb07680e4938bc4c3c77ec3a8 (diff)
downloaddotty-c01389d170bb0f1c8a925a25c145396007a75106.tar.gz
dotty-c01389d170bb0f1c8a925a25c145396007a75106.tar.bz2
dotty-c01389d170bb0f1c8a925a25c145396007a75106.zip
Fix #492. Traits that require an outer pointer are not SAMs.
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/sammy_poly.scala7
-rw-r--r--tests/pos/sammy_poly.scala12
2 files changed, 16 insertions, 3 deletions
diff --git a/tests/neg/sammy_poly.scala b/tests/neg/sammy_poly.scala
new file mode 100644
index 000000000..8d0236496
--- /dev/null
+++ b/tests/neg/sammy_poly.scala
@@ -0,0 +1,7 @@
+// test synthesizeSAMFunction where the sam type is not fully defined
+class T {
+ trait F[T, U] { def apply(x: T): U }
+ // this is an inner trait, that will recieve an abstract $outer pointer. Not a SAM.
+ def app[T, U](x: T)(f: F[T, U]): U = f(x)
+ app(1)(x => List(x))
+}
diff --git a/tests/pos/sammy_poly.scala b/tests/pos/sammy_poly.scala
index f43fa292c..ff20b5c9c 100644
--- a/tests/pos/sammy_poly.scala
+++ b/tests/pos/sammy_poly.scala
@@ -1,7 +1,13 @@
// test synthesizeSAMFunction where the sam type is not fully defined
+
+trait F1[T, U] { def apply(x: T): U }
class T {
- trait F[T, U] { def apply(x: T): U }
// NOTE: the f(x) desugaring for now assumes the single abstract method is called 'apply'
- def app[T, U](x: T)(f: F[T, U]): U = f(x)
- app(1)(x => List(x))
+ def app1[T, U](x: T)(f: F1[T, U]): U = f(x)
+ def app2[T, U](x: T)(f: F2[T, U]): U = f(x)
+ app1(1)(x => List(x))
+ app2(1)(x => List(x))
+}
+object T{
+ trait F2[T, U] { def apply(x: T): U }
}