summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2016-03-23 17:53:19 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2016-03-26 22:55:13 -0700
commitaa972dc100544179beecde48b52dfdb847162001 (patch)
treedc6c57fd7c1c97d6ce104797994dbf92637e86ae /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent608ac2c2b9e3f6f46489e20830d8949ee7d506cf (diff)
downloadscala-aa972dc100544179beecde48b52dfdb847162001.tar.gz
scala-aa972dc100544179beecde48b52dfdb847162001.tar.bz2
scala-aa972dc100544179beecde48b52dfdb847162001.zip
SAM conversion precedes implicit view application (as in dotty).
This reflects the majority vote on the PR. DSLs that need their implicit conversions to kick in instead of SAM conversion, will have to make their target types not be SAM types (e.g., by adding a second abstract method to them).
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)