aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-12-18 15:44:03 +0100
committerGitHub <noreply@github.com>2016-12-18 15:44:03 +0100
commit18b8daa30916b2efaa59638c21198d401a67e46a (patch)
tree09c1a3be43132c89f84605f78429d0094e8749e6 /compiler/src/dotty/tools/dotc/typer/Typer.scala
parent5df985cc599a0c69029773e3416bbb5fc883476a (diff)
parent1f9990b58c23ba74a8d96166700e755704b78a49 (diff)
downloaddotty-18b8daa30916b2efaa59638c21198d401a67e46a.tar.gz
dotty-18b8daa30916b2efaa59638c21198d401a67e46a.tar.bz2
dotty-18b8daa30916b2efaa59638c21198d401a67e46a.zip
Merge pull request #1817 from dotty-staging/fix-#1802
Fix #1802: Make sure errors are not swept under the carpet
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Typer.scala23
1 files changed, 18 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala
index 73084bd86..af0ae0166 100644
--- a/compiler/src/dotty/tools/dotc/typer/Typer.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala
@@ -351,10 +351,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val ownType =
if (rawType.exists)
ensureAccessible(rawType, superAccess = false, tree.pos)
- else {
- error(new MissingIdent(tree, kind, name.show), tree.pos)
- ErrorType
- }
+ else
+ errorType(new MissingIdent(tree, kind, name.show), tree.pos)
val tree1 = ownType match {
case ownType: NamedType if !prefixIsElidable(ownType) =>
@@ -1970,10 +1968,25 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
else err.typeMismatch(tree1, pt)
}
+ /** If tree has an error type but no errors are reported yet, issue
+ * the error message stored in the type.
+ * One way this can happen is if implicit search causes symbols and types
+ * to be completed. The types are stored by `typedAhead` so that they can be
+ * retrieved later and thus avoid duplication of typechecking work.
+ * But if the implicit search causing the `typedAhead` fails locally but
+ * another alternative succeeds we can be left with an ErrorType in the
+ * tree that went unreported. A scenario where this happens is i1802.scala.
+ */
+ def ensureReported(tp: Type) = tp match {
+ case err: ErrorType if !ctx.reporter.hasErrors => ctx.error(err.msg, tree.pos)
+ case _ =>
+ }
+
tree match {
case _: MemberDef | _: PackageDef | _: Import | _: WithoutTypeOrPos[_] => tree
case _ => tree.tpe.widen match {
- case _: ErrorType =>
+ case tp: FlexType =>
+ ensureReported(tp)
tree
case ref: TermRef =>
pt match {