Skip to content

Commit cecfb61

Browse files
committed
Fix #3672: avoid error on type-application of ErrorType value
When a value `foo` has type `ErrorType`, `foo[Bla]` should not report an error `value foo does not take type parameters`. Instead we propagate the existing ErrorType.
1 parent 88d016c commit cecfb61

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

+2
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ trait TypeAssigner {
411411
if (sameLength(argTypes, paramNames)) pt.instantiate(argTypes)
412412
else wrongNumberOfTypeArgs(fn.tpe, pt.typeParams, args, tree.pos)
413413
}
414+
case err: ErrorType =>
415+
err
414416
case _ =>
415417
//println(i"bad type: $fn: ${fn.symbol} / ${fn.symbol.isType} / ${fn.symbol.info}") // DEBUG
416418
errorType(err.takesNoParamsStr(fn, "type "), tree.pos)

compiler/test-resources/repl/errmsgs

+4
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ scala> while ((( foo ))) {}
6868
1 | while ((( foo ))) {}
6969
| ^^^
7070
| not found: foo
71+
scala> val a: iDontExist = 1
72+
1 | val a: iDontExist = 1
73+
| ^^^^^^^^^^
74+
| not found: type iDontExist

tests/neg/errorTypes.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Test {
2+
val x: iDontExist = 1 // error: not found: type iDontExist
3+
4+
val y = x.asInstanceOf[Int] // No error reported (was: value asInstanceOf does not take type parameters)
5+
}

0 commit comments

Comments
 (0)