Skip to content

Commit f459bf0

Browse files
DarkDimiusodersky
authored andcommitted
Fix PreserveSubPatBinders not storing subparts that are used only for type tests.
1 parent a5878de commit f459bf0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
428428

429429
private lazy val (stored, substed) = (subPatBinders, subPatRefs).zipped.partition{ case (sym, _) => storedBinders(sym) }
430430

431+
// dd: this didn't yet trigger error. But I believe it would. if this causes double denition of symbol error this can be replaced with NoRebindings
431432
protected lazy val introducedRebindings: Rebindings = if (!emitVars) Rebindings(subPatBinders, subPatRefs)
432433
else {
433434
val (subPatBindersSubstituted, subPatRefsSubstituted) = substed.unzip
@@ -948,7 +949,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
948949
case Bind(nme.WILDCARD, _) => true // don't skip when binding an interesting symbol!
949950
case Ident(nme.WILDCARD) => true
950951
case Alternative(ps) => ps forall unapply
951-
case Typed(PatternBoundToUnderscore(), _) => true
952+
case Typed(PatternBoundToUnderscore(), _) => false // true // Dmitry: change in dotty. Type test will be performed and the field must be stored
952953
case _ => false
953954
}
954955
}

0 commit comments

Comments
 (0)