diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index fee76e379914..c940a0ec45fb 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -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) diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala index 801f654d7a57..bd7662032daf 100644 --- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -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) diff --git a/compiler/test-resources/repl/errmsgs b/compiler/test-resources/repl/errmsgs index ca69348f8b96..711f5657babc 100644 --- a/compiler/test-resources/repl/errmsgs +++ b/compiler/test-resources/repl/errmsgs @@ -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 diff --git a/tests/neg/errorTypes.scala b/tests/neg/errorTypes.scala new file mode 100644 index 000000000000..f8d5d2795788 --- /dev/null +++ b/tests/neg/errorTypes.scala @@ -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) +}