summaryrefslogtreecommitdiff
path: root/test/files/neg/sammy_overload.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/neg/sammy_overload.scala')
-rw-r--r--test/files/neg/sammy_overload.scala12
1 files changed, 7 insertions, 5 deletions
diff --git a/test/files/neg/sammy_overload.scala b/test/files/neg/sammy_overload.scala
index 91c52cf96c..548e9d2d2e 100644
--- a/test/files/neg/sammy_overload.scala
+++ b/test/files/neg/sammy_overload.scala
@@ -2,12 +2,14 @@ trait ToString { def convert(x: Int): String }
class ExplicitSamType {
object O {
- def m(x: Int => String): Int = 0
- def m(x: ToString): Int = 1
+ def m(x: Int => String): Int = 0 // (1)
+ def m(x: ToString): Int = 1 // (2)
}
- O.m((x: Int) => x.toString) // ok, function type takes precedence
+ O.m((x: Int) => x.toString) // ok, function type takes precedence, because (1) is more specific than (2),
+ // because (1) is as specific as (2): (2) can be applied to a value of type Int => String (well, assuming it's a function literal)
+ // but (2) is not as specific as (1): (1) cannot be applied to a value of type ToString
- O.m(_.toString) // error expected: eta-conversion breaks down due to overloading
- O.m(x => x) // error expected: needs param type
+ O.m(_.toString) // ok: overloading resolution pushes through `Int` as the argument type, so this type checks
+ O.m(x => x) // error expected: m cannot be applied to Int => Int
}