Skip to content

Commit 0cdc425

Browse files
authored
Merge pull request #3680 from dotty-staging/fix-error-types
Fixes related to ErrorType appearing in other types
2 parents 13e879c + f111d7c commit 0cdc425

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,16 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
185185
tp1.rebind(approximateOr(tp1.parent, tp2))
186186
case tp1: TypeProxy if !isClassRef(tp1) =>
187187
orDominator(tp1.superType | tp2)
188+
case err: ErrorType =>
189+
err
188190
case _ =>
189191
tp2 match {
190192
case tp2: RecType =>
191193
tp2.rebind(approximateOr(tp1, tp2.parent))
192194
case tp2: TypeProxy if !isClassRef(tp2) =>
193195
orDominator(tp1 | tp2.superType)
196+
case err: ErrorType =>
197+
err
194198
case _ =>
195199
val commonBaseClasses = tp.mapReduceOr(_.baseClasses)(intersect)
196200
val doms = dominators(commonBaseClasses, Nil)

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
6+
val a: iDontExist | Int = 1 // error: not found: type iDontExist
7+
val a2 = a.isInstanceOf[Int] // No error (used to crash)
8+
9+
val b: iDontExist & Int = 1 // error: not found: type iDontExist
10+
val b2 = a.isInstanceOf[Int] // No error (worked before too)
11+
}

0 commit comments

Comments
 (0)