summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index a9d5b69e2e..52242c10b3 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1053,6 +1053,14 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (hasUndets)
return instantiate(tree, mode, pt)
+ // we know `!(tree.tpe <:< pt)`; try to remedy if there's a sam for pt
+ val sam = samMatchingFunction(tree, pt) // this implies tree.isInstanceOf[Function]
+ if (sam.exists && !tree.tpe.isErroneous) {
+ val samTree = adaptToSAM(sam, tree.asInstanceOf[Function], pt, mode)
+ if (samTree ne EmptyTree)
+ return samTree.updateAttachment(SAMFunction(pt, sam))
+ }
+
if (context.implicitsEnabled && !pt.isError && !tree.isErrorTyped) {
// (14); the condition prevents chains of views
inferView(tree, tree.tpe, pt) match {
@@ -1071,14 +1079,6 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
}
}
-
- // we know `!(tree.tpe <:< pt)`; try to remedy if there's a sam for pt
- val sam = samMatchingFunction(tree, pt) // this implies tree.isInstanceOf[Function]
- if (sam.exists && !tree.tpe.isErroneous) {
- val samTree = adaptToSAM(sam, tree.asInstanceOf[Function], pt, mode)
- if (samTree ne EmptyTree)
- return samTree.updateAttachment(SAMFunction(pt, sam))
- }
}
debuglog("error tree = " + tree)