Skip to content

Commit da044ba

Browse files
committed
I observed a crash in replace when hacking ElimOpaque the compiler.
It came down to the problem that a TermRef with a context function as underlying type was added to the context as lower bound after some errors were already reported. I could not track down the exact chain of effects. But anyway it's better to be defensive and not let junk enter the context.
1 parent 212b8af commit da044ba

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,9 @@ trait ConstraintHandling {
484484
* way isSubType is organized.
485485
*/
486486
protected def addConstraint(param: TypeParamRef, bound: Type, fromBelow: Boolean)(using Context): Boolean =
487+
if !bound.isValueTypeOrLambda then
488+
assert(ctx.reporter.errorsReported)
489+
return false
487490

488491
/** When comparing lambdas we might get constraints such as
489492
* `A <: X0` or `A = List[X0]` where `A` is a constrained parameter

0 commit comments

Comments
 (0)