Skip to content

Commit 434f7a7

Browse files
committed
Match the original apply method name in tuple specialisation
... not the new name from the import.
1 parent 1d2c641 commit 434f7a7

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/transform/SpecializeTuples.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class SpecializeTuples extends MiniPhase:
2323

2424
override def transformApply(tree: Apply)(using Context): Tree = tree match
2525
case Apply(TypeApply(fun: NameTree, targs), args)
26-
if fun.name == nme.apply && fun.symbol.exists && defn.isSpecializableTuple(fun.symbol.owner.companionClass, targs.map(_.tpe)) =>
26+
if fun.symbol.name == nme.apply && fun.symbol.exists && defn.isSpecializableTuple(fun.symbol.owner.companionClass, targs.map(_.tpe)) =>
2727
cpy.Apply(tree)(Select(New(defn.SpecialisedTuple(fun.symbol.owner.companionClass, targs.map(_.tpe)).typeRef), nme.CONSTRUCTOR), args).withType(tree.tpe)
2828
case Apply(TypeApply(fun: NameTree, targs), args)
29-
if fun.name == nme.CONSTRUCTOR && fun.symbol.exists && defn.isSpecializableTuple(fun.symbol.owner, targs.map(_.tpe)) =>
29+
if fun.symbol.name == nme.CONSTRUCTOR && fun.symbol.exists && defn.isSpecializableTuple(fun.symbol.owner, targs.map(_.tpe)) =>
3030
cpy.Apply(tree)(Select(New(defn.SpecialisedTuple(fun.symbol.owner, targs.map(_.tpe)).typeRef), nme.CONSTRUCTOR), args).withType(tree.tpe)
3131
case _ => tree
3232
end transformApply

tests/run/i11114.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
class scala.Tuple2$mcII$sp
22
class scala.Tuple2$mcII$sp
33
class scala.Tuple2$mcII$sp
4+
class scala.Tuple2$mcII$sp
5+
class scala.Tuple2$mcII$sp

tests/run/i11114.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22
println((1, 1).getClass)
33
println(Tuple2.apply(1, 1).getClass)
44
println(new Tuple2(1, 1).getClass)
5+
6+
import Tuple2.apply
7+
println(apply(1, 4).getClass)
8+
9+
import Tuple2.{ apply => t2 }
10+
println(t2(1, 5).getClass)

0 commit comments

Comments
 (0)