@@ -385,7 +385,7 @@ object SpaceEngine {
385
385
project(pat)
386
386
387
387
case Typed (_, tpt) =>
388
- Typ (erase(tpt.tpe.stripAnnots, isValue = true ), decomposed = false )
388
+ Typ (erase(tpt.tpe.stripAnnots, isValue = true , isTyped = true ), decomposed = false )
389
389
390
390
case This (_) =>
391
391
Typ (pat.tpe.stripAnnots, decomposed = false )
@@ -453,24 +453,26 @@ object SpaceEngine {
453
453
* If `isValue` is true, then pattern-bound symbols are erased to its upper bound.
454
454
* This is needed to avoid spurious unreachable warnings. See tests/patmat/i6197.scala.
455
455
*/
456
- private def erase (tp : Type , inArray : Boolean = false , isValue : Boolean = false )(using Context ): Type =
457
- trace(i " erase( $tp${if inArray then " inArray" else " " }${if isValue then " isValue" else " " }) " , debug)(tp match {
456
+ private def erase (tp : Type , inArray : Boolean = false , isValue : Boolean = false , isTyped : Boolean = false )(using Context ): Type =
457
+ trace(i " erase( $tp${if inArray then " inArray" else " " }${if isValue then " isValue" else " " }${ if isTyped then " isTyped " else " " } ) " , debug)(tp match {
458
458
case tp @ AppliedType (tycon, args) if tycon.typeSymbol.isPatternBound =>
459
459
WildcardType
460
460
461
461
case tp @ AppliedType (tycon, args) =>
462
462
val inArray = tycon.isRef(defn.ArrayClass )
463
- val args2 = args.map(arg => erase(arg, inArray = inArray, isValue = false ))
463
+ val args2 =
464
+ if isTyped && ! inArray then args.map(_ => WildcardType )
465
+ else args.map(arg => erase(arg, inArray = inArray, isValue = false ))
464
466
tp.derivedAppliedType(erase(tycon, inArray, isValue = false ), args2)
465
467
466
468
case tp @ OrType (tp1, tp2) =>
467
- OrType (erase(tp1, inArray, isValue), erase(tp2, inArray, isValue), tp.isSoft)
469
+ OrType (erase(tp1, inArray, isValue, isTyped ), erase(tp2, inArray, isValue, isTyped ), tp.isSoft)
468
470
469
471
case AndType (tp1, tp2) =>
470
- AndType (erase(tp1, inArray, isValue), erase(tp2, inArray, isValue))
472
+ AndType (erase(tp1, inArray, isValue, isTyped ), erase(tp2, inArray, isValue, isTyped ))
471
473
472
474
case tp @ RefinedType (parent, _, _) =>
473
- erase(parent, inArray, isValue)
475
+ erase(parent, inArray, isValue, isTyped )
474
476
475
477
case tref : TypeRef if tref.symbol.isPatternBound =>
476
478
if inArray then tref.underlying
0 commit comments