summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2016-03-21 22:56:08 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2016-03-26 22:55:00 -0700
commit391e2843f420bb4686b974b18ac361c9bb49465c (patch)
tree580deff7251bd37f57fc4b432c6c772f55ff98f0 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parentb0b0abab89f0c40ba3c45b4a1f7bada31040d55a (diff)
downloadscala-391e2843f420bb4686b974b18ac361c9bb49465c.tar.gz
scala-391e2843f420bb4686b974b18ac361c9bb49465c.tar.bz2
scala-391e2843f420bb4686b974b18ac361c9bb49465c.zip
Don't adapt erroneous tree to SAM type.
Do not report second error. Go straight to the exit. Based on review by Jason.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 3b826ae2e5..cd5759f40f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1074,7 +1074,7 @@ 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) {
+ if (sam.exists && !tree.tpe.isErroneous) {
val samTree = adaptToSAM(sam, tree.asInstanceOf[Function], pt, mode)
if (samTree ne EmptyTree) return samTree
}
@@ -2794,7 +2794,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
EmptyTree
}
} catch {
- case e@(_: NoInstance | _: TypeError) => // TODO: we get here whenever pt contains a wildcardtype???
+ case e@(_: NoInstance | _: TypeError) =>
debuglog(s"Error during SAM synthesis: could not define type $pt using ${fun.tpe} <:< ${pt memberInfo sam} (for $sam)\n$e")
EmptyTree
}