@@ -394,7 +394,7 @@ object SpaceEngine {
394
394
project(pat)
395
395
396
396
case Typed (_, tpt) =>
397
- Typ (erase(tpt.tpe.stripAnnots, isValue = true ), decomposed = false )
397
+ Typ (erase(tpt.tpe.stripAnnots, isValue = true , isTyped = true ), decomposed = false )
398
398
399
399
case This (_) =>
400
400
Typ (pat.tpe.stripAnnots, decomposed = false )
@@ -462,24 +462,26 @@ object SpaceEngine {
462
462
* If `isValue` is true, then pattern-bound symbols are erased to its upper bound.
463
463
* This is needed to avoid spurious unreachable warnings. See tests/patmat/i6197.scala.
464
464
*/
465
- private def erase (tp : Type , inArray : Boolean = false , isValue : Boolean = false )(using Context ): Type =
466
- trace(i " erase( $tp${if inArray then " inArray" else " " }${if isValue then " isValue" else " " }) " , debug)(tp match {
465
+ private def erase (tp : Type , inArray : Boolean = false , isValue : Boolean = false , isTyped : Boolean = false )(using Context ): Type =
466
+ trace(i " erase( $tp${if inArray then " inArray" else " " }${if isValue then " isValue" else " " }${ if isTyped then " isTyped " else " " } ) " , debug)(tp match {
467
467
case tp @ AppliedType (tycon, args) if tycon.typeSymbol.isPatternBound =>
468
468
WildcardType
469
469
470
470
case tp @ AppliedType (tycon, args) =>
471
471
val inArray = tycon.isRef(defn.ArrayClass )
472
- val args2 = args.map(arg => erase(arg, inArray = inArray, isValue = false ))
472
+ val args2 =
473
+ if isTyped && ! inArray then args.map(_ => WildcardType )
474
+ else args.map(arg => erase(arg, inArray = inArray, isValue = false ))
473
475
tp.derivedAppliedType(erase(tycon, inArray, isValue = false ), args2)
474
476
475
477
case tp @ OrType (tp1, tp2) =>
476
- OrType (erase(tp1, inArray, isValue), erase(tp2, inArray, isValue), tp.isSoft)
478
+ OrType (erase(tp1, inArray, isValue, isTyped ), erase(tp2, inArray, isValue, isTyped ), tp.isSoft)
477
479
478
480
case AndType (tp1, tp2) =>
479
- AndType (erase(tp1, inArray, isValue), erase(tp2, inArray, isValue))
481
+ AndType (erase(tp1, inArray, isValue, isTyped ), erase(tp2, inArray, isValue, isTyped ))
480
482
481
483
case tp @ RefinedType (parent, _, _) =>
482
- erase(parent, inArray, isValue)
484
+ erase(parent, inArray, isValue, isTyped )
483
485
484
486
case tref : TypeRef if tref.symbol.isPatternBound =>
485
487
if inArray then tref.underlying
0 commit comments