Skip to content

Commit 44253d4

Browse files
committed
Remove DispatchToSpecializedApply phase
1 parent 0bc379d commit 44253d4

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ class Compiler {
6565
new CrossCastAnd, // Normalize selections involving intersection types.
6666
new Splitter, // Expand selections involving union types into conditionals
6767
new SpecializeFunction1), // Specialized Function1 by replacing super with specialized super
68-
List(new DispatchToSpecializedApply, // Dispatch to the specialized apply by `SpecializeFunction1`
69-
new VCInlineMethods, // Inlines calls to value class methods
68+
List(new VCInlineMethods, // Inlines calls to value class methods
7069
new IsInstanceOfEvaluator, // Issues warnings when unreachable statements are present in match/if expressions
7170
new SeqLiterals, // Express vararg arguments as arrays
7271
new InterceptedMethods, // Special handling of `==`, `|=`, `getClass` methods

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

Lines changed: 0 additions & 29 deletions
This file was deleted.

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ class SpecializeFunction1 extends MiniPhaseTransform with DenotTransformer {
2828
case _ => tree
2929
}
3030

31+
override def transformApply(tree: Apply)(implicit ctx: Context, info: TransformerInfo) = {
32+
import ast.Trees._
33+
tree match {
34+
case Apply(select @ Select(id, nme.apply), arg :: Nil) =>
35+
val params = List(arg.tpe, tree.tpe)
36+
val specializedApply = nme.apply.specializedFor(params, params.map(_.typeSymbol.name))
37+
val hasOverridenSpecializedApply = id.tpe.decls.iterator.exists { sym =>
38+
sym.is(Flags.Override) && (sym.name eq specializedApply)
39+
}
40+
41+
if (hasOverridenSpecializedApply) tpd.Apply(tpd.Select(id, specializedApply), arg :: Nil)
42+
else tree
43+
case _ => tree
44+
}
45+
}
46+
3147
private[this] val functionName = "JFunction1".toTermName
3248
private[this] val functionPkg = "scala.compat.java8.".toTermName
3349
private[this] var Function1: Symbol = _

0 commit comments

Comments
 (0)