Skip to content

Commit f111d7c

Browse files
committed
Fix union with error
1 parent cecfb61 commit f111d7c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-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)

tests/neg/errorTypes.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ object Test {
22
val x: iDontExist = 1 // error: not found: type iDontExist
33

44
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)
511
}

0 commit comments

Comments
 (0)