summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/sammy_expected.check6
-rw-r--r--test/files/neg/sammy_expected.scala5
-rw-r--r--test/files/neg/sammy_overload.check7
-rw-r--r--test/files/neg/sammy_overload.scala13
-rw-r--r--test/files/pos/sammy_ctor_arg.scala (renamed from test/files/pos/sam_ctor_arg.scala)0
-rw-r--r--test/files/pos/sammy_infer_argtype_subtypes.scala (renamed from test/files/pos/sam_infer_argtype_subtypes.scala)0
-rw-r--r--test/files/pos/sammy_inferargs.scala (renamed from test/files/pos/sam_inferargs.scala)0
-rw-r--r--test/files/run/sammy_repeated.scala8
-rw-r--r--test/files/run/sammy_return.scala (renamed from test/files/run/sam_return.scala)0
-rw-r--r--test/files/run/sammy_vararg_cbn.check (renamed from test/files/run/sammy_repeated.check)0
-rw-r--r--test/files/run/sammy_vararg_cbn.scala12
11 files changed, 43 insertions, 8 deletions
diff --git a/test/files/neg/sammy_expected.check b/test/files/neg/sammy_expected.check
new file mode 100644
index 0000000000..3b76aabdd2
--- /dev/null
+++ b/test/files/neg/sammy_expected.check
@@ -0,0 +1,6 @@
+sammy_expected.scala:4: error: type mismatch;
+ found : String => Int
+ required: F[Object,Int]
+ def wrong: F[Object, Int] = (x: String) => 1
+ ^
+one error found
diff --git a/test/files/neg/sammy_expected.scala b/test/files/neg/sammy_expected.scala
new file mode 100644
index 0000000000..8fc1f66ff7
--- /dev/null
+++ b/test/files/neg/sammy_expected.scala
@@ -0,0 +1,5 @@
+trait F[A, B] { def apply(x: A): B }
+
+class MustMeetExpected {
+ def wrong: F[Object, Int] = (x: String) => 1
+} \ No newline at end of file
diff --git a/test/files/neg/sammy_overload.check b/test/files/neg/sammy_overload.check
new file mode 100644
index 0000000000..903d7c88f4
--- /dev/null
+++ b/test/files/neg/sammy_overload.check
@@ -0,0 +1,7 @@
+sammy_overload.scala:11: error: missing parameter type for expanded function ((x$1: <error>) => x$1.toString)
+ O.m(_.toString) // error expected: eta-conversion breaks down due to overloading
+ ^
+sammy_overload.scala:12: error: missing parameter type
+ O.m(x => x) // error expected: needs param type
+ ^
+two errors found
diff --git a/test/files/neg/sammy_overload.scala b/test/files/neg/sammy_overload.scala
new file mode 100644
index 0000000000..91c52cf96c
--- /dev/null
+++ b/test/files/neg/sammy_overload.scala
@@ -0,0 +1,13 @@
+trait ToString { def convert(x: Int): String }
+
+class ExplicitSamType {
+ object O {
+ def m(x: Int => String): Int = 0
+ def m(x: ToString): Int = 1
+ }
+
+ O.m((x: Int) => x.toString) // ok, function type takes precedence
+
+ O.m(_.toString) // error expected: eta-conversion breaks down due to overloading
+ O.m(x => x) // error expected: needs param type
+}
diff --git a/test/files/pos/sam_ctor_arg.scala b/test/files/pos/sammy_ctor_arg.scala
index 3c556d59f0..3c556d59f0 100644
--- a/test/files/pos/sam_ctor_arg.scala
+++ b/test/files/pos/sammy_ctor_arg.scala
diff --git a/test/files/pos/sam_infer_argtype_subtypes.scala b/test/files/pos/sammy_infer_argtype_subtypes.scala
index 63966f879e..63966f879e 100644
--- a/test/files/pos/sam_infer_argtype_subtypes.scala
+++ b/test/files/pos/sammy_infer_argtype_subtypes.scala
diff --git a/test/files/pos/sam_inferargs.scala b/test/files/pos/sammy_inferargs.scala
index 10d9b4f0dd..10d9b4f0dd 100644
--- a/test/files/pos/sam_inferargs.scala
+++ b/test/files/pos/sammy_inferargs.scala
diff --git a/test/files/run/sammy_repeated.scala b/test/files/run/sammy_repeated.scala
deleted file mode 100644
index c24dc41909..0000000000
--- a/test/files/run/sammy_repeated.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-trait RepeatedSink { def accept(a: Any*): Unit }
-
-object Test {
- def main(args: Array[String]): Unit = {
- val f: RepeatedSink = (a) => println(a)
- f.accept(1)
- }
-} \ No newline at end of file
diff --git a/test/files/run/sam_return.scala b/test/files/run/sammy_return.scala
index e959619dd1..e959619dd1 100644
--- a/test/files/run/sam_return.scala
+++ b/test/files/run/sammy_return.scala
diff --git a/test/files/run/sammy_repeated.check b/test/files/run/sammy_vararg_cbn.check
index 1cff0f067c..1cff0f067c 100644
--- a/test/files/run/sammy_repeated.check
+++ b/test/files/run/sammy_vararg_cbn.check
diff --git a/test/files/run/sammy_vararg_cbn.scala b/test/files/run/sammy_vararg_cbn.scala
new file mode 100644
index 0000000000..e5b49498ea
--- /dev/null
+++ b/test/files/run/sammy_vararg_cbn.scala
@@ -0,0 +1,12 @@
+trait SamRepeated { def accept(a: Any*): Unit }
+trait SamByName { def accept(a: => Any): (Any, Any) }
+
+object Test extends App {
+ val rep: SamRepeated = (a) => println(a)
+ rep.accept(1)
+
+ val nam: SamByName = (a) => (a, a)
+ var v = 0
+ assert(nam.accept({v += 1; v}) == (1, 2))
+ assert(v == 2, "by name arg should be evaluated twice")
+}