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
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Dynamic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ object DynamicUnapply {
def unapply(tree: tpd.Tree): Option[List[tpd.Tree]] = tree match
case TypeApply(Select(qual, name), _) if name == nme.asInstanceOfPM =>
unapply(qual)
case Apply(Apply(Select(selectable, fname), Literal(Constant(name)) :: ctag :: Nil), _ :: implicits)
case Apply(Apply(Select(selectable, fname), Literal(Constant(name)) :: restArgs), _ :: implicits)
if fname == nme.applyDynamic && (name == "unapply" || name == "unapplySeq") =>
Some(selectable :: ctag :: implicits)
Some(selectable :: (restArgs ::: implicits))
case _ =>
None
}
Expand Down
12 changes: 12 additions & 0 deletions tests/neg/i24168.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trait Generic extends Selectable:
def applyDynamic(name: String)(args: Any*): Any = ()

val foo: Generic {
def unapply(x: Int): Option[Unit]
} = new Generic:
def unapply(x: Int): Option[Unit] = Some(())

def x =
42 match
case foo(()) => println("lol") // error

Loading