Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,18 @@ object PatternMatcher {
// begin patternPlan
swapBind(tree) match {
case Typed(pat, tpt) =>
val isTrusted = pat match {
def isTrusted(pattern: Tree): Boolean = pattern match {
case UnApply(extractor, _, _) =>
extractor.symbol.is(Synthetic)
&& extractor.symbol.owner.linkedClass.is(Case)
&& !hasExplicitTypeArgs(extractor)
case Bind(_, body) => isTrusted(body)
case _ => false
}
val castTp = if Feature.ccEnabled
then CapturingType(tpt.tpe, scrutinee.termRef.singletonCaptureSet)
else tpt.tpe
TestPlan(TypeTest(tpt, isTrusted), scrutinee, tree.span,
TestPlan(TypeTest(tpt, isTrusted(pat)), scrutinee, tree.span,
letAbstract(ref(scrutinee).cast(castTp)) { casted =>
nonNull += casted
patternPlan(casted, pat, onSuccess)
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i24557.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
object test {
sealed trait X[T]
trait Iterable[T]
case class I[T, C <: Iterable[T]]() extends X[C]

def t[T](i: X[T]): Unit =
i match
case i @ I() => ()
}
Loading