Skip to content

Survive competing methods with select names _1, _2, ... #11733

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

Merged
merged 1 commit into from
Mar 15, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
def productElementBody(arity: Int, index: Tree)(using Context): Tree = {
// case N => _${N + 1}
val cases = 0.until(arity).map { i =>
CaseDef(Literal(Constant(i)), EmptyTree, Select(This(clazz), nme.selectorName(i)))
val sel = This(clazz).select(nme.selectorName(i), _.info.isParameterless)
CaseDef(Literal(Constant(i)), EmptyTree, sel)
}

Match(index, (cases :+ generateIOBECase(index)).toList)
Expand Down
17 changes: 17 additions & 0 deletions tests/pos/i11725.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sealed trait Expr[+A] extends ExprTuple[A]

case class Lit[A](value: A) extends Expr[A]

trait ExprTuple[+A] {
def _1(implicit ev: ExprTuple.Has2[A]): Expr[ev._1] = ???
def _2(implicit ev: ExprTuple.Has2[A]): Expr[ev._2] = ???
}

object ExprTuple {
trait Has2[-A] { type _1; type _2 }
object Has2 {
type Aux[-A, A1, A2] = Has2[A] { type _1 = A1; type _2 = A2 }
}

implicit def tuple2[A, B]: Has2.Aux[(A, B), A, B] = ???
}