summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2015-11-18 07:27:37 +0100
committerLukas Rytz <lukas.rytz@typesafe.com>2015-11-18 07:27:37 +0100
commitfe336167e7a9f68c7ea6beb80e2cbb69cea95ff8 (patch)
tree876f8ebf0990af27b7a7c83344553cb2434075a2 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent15ef8399b817edfd941d93b206915ca6093c7b45 (diff)
parent9da23ec80f2046f2aac8de3e690376cf2af642d4 (diff)
downloadscala-fe336167e7a9f68c7ea6beb80e2cbb69cea95ff8.tar.gz
scala-fe336167e7a9f68c7ea6beb80e2cbb69cea95ff8.tar.bz2
scala-fe336167e7a9f68c7ea6beb80e2cbb69cea95ff8.zip
Merge pull request #4822 from retronym/ticket/9178
SI-9178 Don't eta expand to an Function0-like SAM expected type
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-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 510c83eb88..3889d48213 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)