Skip to content

Commit ee080c6

Browse files
committed
Survive ill-formed parent types
In the face of previous errors: - Constant#classBound cannot assume all class parents have good types - dominator cannot assume that all classes in an OrType inherit from the same parent
1 parent 8490251 commit ee080c6

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ object Constants {
153153
*/
154154
def convertTo(pt: Type)(implicit ctx: Context): Constant = {
155155
def classBound(pt: Type): Type = pt.dealias.stripTypeVar match {
156-
case tref: TypeRef if !tref.symbol.isClass => classBound(tref.info.bounds.lo)
156+
case tref: TypeRef if !tref.symbol.isClass && tref.info.exists =>
157+
classBound(tref.info.bounds.lo)
157158
case param: TypeParamRef =>
158159
ctx.typerState.constraint.entry(param) match {
159160
case TypeBounds(lo, hi) =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
140140
val accu1 = if (accu exists (_ derivesFrom c)) accu else c :: accu
141141
if (cs == c.baseClasses) accu1 else dominators(rest, accu1)
142142
case Nil => // this case can happen because after erasure we do not have a top class anymore
143-
assert(ctx.erasedTypes)
143+
assert(ctx.erasedTypes || ctx.reporter.errorsReported)
144144
defn.ObjectClass :: Nil
145145
}
146146

tests/neg/parser-stability-15.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package x0
2+
class x0 {
3+
def x1 =
4+
x2 match // error
5+
] // error
6+
case x3[] => x0 // error // error // error // error

0 commit comments

Comments
 (0)