Skip to content

Commit

Permalink
Fix scala#3672: avoid error on type-application of ErrorType value
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
smarter committed Dec 19, 2017
1 parent 88d016c commit cecfb61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
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
5 changes: 5 additions & 0 deletions tests/neg/errorTypes.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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)
}

0 comments on commit cecfb61

Please sign in to comment.