Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4030: avoid adding duplicate binders #4034

Merged
merged 1 commit into from
Feb 27, 2018
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
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,10 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
/** Add a `Bind` node for each `bound` symbol in a type application `unapp` */
def addBinders(unapp: Tree, bound: List[Symbol]) = unapp match {
case TypeApply(fn, args) =>
var remain = bound.toSet
def addBinder(arg: Tree) = arg.tpe.stripTypeVar match {
case ref: TypeRef if bound.contains(ref.symbol) =>
case ref: TypeRef if remain.contains(ref.symbol) =>
remain -= ref.symbol
tpd.Bind(ref.symbol, Ident(ref))
case _ =>
arg
Expand Down
1 change: 1 addition & 0 deletions tests/patmat/i4030.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9: Pattern Match Exhaustivity: (C4(), _), (_, C4())
13 changes: 13 additions & 0 deletions tests/patmat/i4030.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sealed trait Root[T]
case object C1 extends Root[Int]
case object C2 extends Root[String]
case class C3[X, Y]() extends Root[(X => X)|(Y => Y)|(X => Y)]
case class C4[X, Y]() extends Root[(X => X)|(Y => Y)|(X => Y)]

object TestGADT {

def f[A <: Seq[_], B, Foo >: A => B](v: Root[Foo], u: Root[Foo]) = (v, u) match {
case (C3(), C3()) =>
}
f(C3[Seq[_], Long](), C4[Seq[_], Long]())
}