Skip to content
Merged
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
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -698,13 +698,15 @@ object PatternMatcher {
for ((rhs, _) <- seenVars if !seenAtLabel(plan.label).contains(rhs))
yield (rhs, newVar(rhs.tree, Param))
}
plan.args =
val newArgs =
for {
(rhs, actual) <- seenVars.toList
formal <- paramsOfLabel(plan.label).get(rhs)
}
yield (formal -> actual)
plan
if (plan.args.isEmpty) { plan.args = newArgs; plan }
else if (newArgs == plan.args) plan
else CallPlan(plan.label, newArgs)
}
}
(new Merge(Map()))(plan)
Expand Down
43 changes: 43 additions & 0 deletions tests/pos/i4449.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
class TreeAccumulator2 {

def foo(tasty: Tasty2)(tree: Any): Unit = {
import tasty._
tree match {
case A() =>
case B() =>
case C() =>
case D() =>
}
}

}

abstract class Tasty2 {

type X
type Y

implicit def xct: scala.reflect.ClassTag[X]
implicit def yct: scala.reflect.ClassTag[Y]

val A: AExtractor
trait AExtractor {
def unapply(x: X): Boolean
}

val B: BExtractor
trait BExtractor {
def unapply(x: X): Boolean
}

val C: CExtractor
trait CExtractor {
def unapply(x: Y): Boolean // Note the type Y
}

val D: DExtractor
trait DExtractor {
def unapply(x: X): Boolean
}

}