diff options
author | Martin Odersky <odersky@gmail.com> | 2016-12-17 15:09:27 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-12-17 15:09:52 +0100 |
commit | b63480a59bbdd284a5e32281fbb0037e509f4b1e (patch) | |
tree | 825824024ad6768646c3dbf630a2db9283eedcd4 /compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala | |
parent | 653698ef67a5cf8f5e0fd0fcdcd1f631f1dc96e2 (diff) | |
download | dotty-b63480a59bbdd284a5e32281fbb0037e509f4b1e.tar.gz dotty-b63480a59bbdd284a5e32281fbb0037e509f4b1e.tar.bz2 dotty-b63480a59bbdd284a5e32281fbb0037e509f4b1e.zip |
Make errors are not swept under the carpet
Typer#ensureReported's comment outlines an example where errors
could go unreported, resulting in error trees after typer without
any reported error messages. This commit makes sure that at least
one error is reported if a tree node has an error type.
Fixes #1802.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala index ee2d68278..ca0af0e2b 100644 --- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -189,9 +189,8 @@ trait TypeAssigner { val where = if (ctx.owner.exists) s" from ${ctx.owner.enclosingClass}" else "" val whyNot = new StringBuffer alts foreach (_.isAccessibleFrom(pre, superAccess, whyNot)) - if (!tpe.isError) - ctx.error(ex"$what cannot be accessed as a member of $pre$where.$whyNot", pos) - ErrorType + if (tpe.isError) tpe + else errorType(ex"$what cannot be accessed as a member of $pre$where.$whyNot", pos) } } else if (d.symbol is TypeParamAccessor) @@ -215,17 +214,17 @@ trait TypeAssigner { else if (site.derivesFrom(defn.DynamicClass) && !Dynamic.isDynamicMethod(name)) { TryDynamicCallType } else { - if (!site.isErroneous) { + if (site.isErroneous) UnspecifiedErrorType + else { def kind = if (name.isTypeName) "type" else "value" def addendum = if (site.derivesFrom(defn.DynamicClass)) "\npossible cause: maybe a wrong Dynamic method signature?" else "" - ctx.error( + errorType( if (name == nme.CONSTRUCTOR) ex"$site does not have a constructor" else NotAMember(site, name, kind), pos) } - ErrorType } } |