summaryrefslogtreecommitdiff
path: root/src/compiler
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 /src/compiler
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 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 45ebbd532d..d06a4a5d80 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -862,7 +862,14 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
case Block(_, tree1) => tree1.symbol
case _ => tree.symbol
}
- if (!meth.isConstructor && (isFunctionType(pt) || samOf(pt).exists)) { // (4.2)
+ def shouldEtaExpandToSam: Boolean = {
+ // SI-9536 don't adapt parameterless method types to a to SAM's, fall through to empty application
+ // instead for backwards compatiblity with 2.11. See comments of that ticket and SI-7187
+ // for analogous trouble with non-SAM eta expansion. Suggestions there are: a) deprecate eta expansion to Function0,
+ // or b) switch the order of eta-expansion and empty application in this adaptation.
+ !mt.params.isEmpty && samOf(pt).exists
+ }
+ if (!meth.isConstructor && (isFunctionType(pt) || shouldEtaExpandToSam)) { // (4.2)
debuglog(s"eta-expanding $tree: ${tree.tpe} to $pt")
checkParamsConvertible(tree, tree.tpe)
val tree0 = etaExpand(context.unit, tree, this)