Skip to content

Fixes related to ErrorType appearing in other types #3680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,16 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
tp1.rebind(approximateOr(tp1.parent, tp2))
case tp1: TypeProxy if !isClassRef(tp1) =>
orDominator(tp1.superType | tp2)
case err: ErrorType =>
err
case _ =>
tp2 match {
case tp2: RecType =>
tp2.rebind(approximateOr(tp1, tp2.parent))
case tp2: TypeProxy if !isClassRef(tp2) =>
orDominator(tp1 | tp2.superType)
case err: ErrorType =>
err
case _ =>
val commonBaseClasses = tp.mapReduceOr(_.baseClasses)(intersect)
val doms = dominators(commonBaseClasses, Nil)
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ trait TypeAssigner {
if (sameLength(argTypes, paramNames)) pt.instantiate(argTypes)
else wrongNumberOfTypeArgs(fn.tpe, pt.typeParams, args, tree.pos)
}
case err: ErrorType =>
err
case _ =>
//println(i"bad type: $fn: ${fn.symbol} / ${fn.symbol.isType} / ${fn.symbol.info}") // DEBUG
errorType(err.takesNoParamsStr(fn, "type "), tree.pos)
Expand Down
4 changes: 4 additions & 0 deletions compiler/test-resources/repl/errmsgs
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ scala> while ((( foo ))) {}
1 | while ((( foo ))) {}
| ^^^
| not found: foo
scala> val a: iDontExist = 1
1 | val a: iDontExist = 1
| ^^^^^^^^^^
| not found: type iDontExist
11 changes: 11 additions & 0 deletions tests/neg/errorTypes.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
object Test {
val x: iDontExist = 1 // error: not found: type iDontExist

val y = x.asInstanceOf[Int] // No error reported (was: value asInstanceOf does not take type parameters)

val a: iDontExist | Int = 1 // error: not found: type iDontExist
val a2 = a.isInstanceOf[Int] // No error (used to crash)

val b: iDontExist & Int = 1 // error: not found: type iDontExist
val b2 = a.isInstanceOf[Int] // No error (worked before too)
}