Skip to content

Commit a4be1b2

Browse files
authored
Merge pull request #8466 from dotty-staging/fix-#5005
Fix #5005: Weaken assertion when trying to compute an ErasedValueType
2 parents 611bee1 + 2142541 commit a4be1b2

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,12 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
550550
private def eraseDerivedValueClassRef(tref: TypeRef)(implicit ctx: Context): Type = {
551551
val cls = tref.symbol.asClass
552552
val underlying = underlyingOfValueClass(cls)
553-
if (underlying.exists && !isCyclic(cls)) {
553+
if underlying.exists && !isCyclic(cls) then
554554
val erasedValue = valueErasure(underlying)
555-
assert(erasedValue.exists, i"no erasure for $underlying")
556-
ErasedValueType(tref, erasedValue)
557-
}
555+
if erasedValue.exists then ErasedValueType(tref, erasedValue)
556+
else
557+
assert(ctx.reporter.errorsReported, i"no erasure for $underlying")
558+
NoType
558559
else NoType
559560
}
560561

tests/neg/i5005.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
case class i0 (i0: i1) extends AnyVal
3+
trait i1 extends i0 // error
4+
5+
trait F[x] extends AnyVal // error
6+
case class G[x](a: F[x]) extends F[x] // error // error

0 commit comments

Comments
 (0)