summaryrefslogtreecommitdiff
path: root/test/files/run/t9178a.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-10-27 14:37:44 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-10-27 16:08:15 +1000
commit639e52ae7e128025f6eb57957a590b808d83a9a4 (patch)
tree19958923ec2beea7b770ccf2197fef6930e830f1 /test/files/run/t9178a.scala
parentb194a4e7230334e441cd31b617fdce8e329dfa3a (diff)
downloadscala-639e52ae7e128025f6eb57957a590b808d83a9a4.tar.gz
scala-639e52ae7e128025f6eb57957a590b808d83a9a4.tar.bz2
scala-639e52ae7e128025f6eb57957a590b808d83a9a4.zip
SI-9178 Don't eta expand param-less method types to SAMs
Otherwise, we can end up with a subtle source incompatibility with the pre-SAM regime. Arguably we should phase out eta expansion to Function0 as well, but I'll leave that for another day.
Diffstat (limited to 'test/files/run/t9178a.scala')
-rw-r--r--test/files/run/t9178a.scala15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/files/run/t9178a.scala b/test/files/run/t9178a.scala
new file mode 100644
index 0000000000..4788841f8d
--- /dev/null
+++ b/test/files/run/t9178a.scala
@@ -0,0 +1,15 @@
+trait Sam { def apply(): Unit }
+abstract class Test {
+ def foo(): Sam
+ // no parens, instantiateToMethodType would wrap in a `new Sam { def apply = foo }`
+ // rather than applying to an empty param list() */
+ val f: Sam = foo
+}
+
+object Test extends Test {
+ lazy val samIAm = new Sam { def apply() {} }
+ def foo() = samIAm
+ def main(args: Array[String]): Unit = {
+ assert(f eq samIAm, f)
+ }
+}