Skip to content

Commit 9eb7eb7

Browse files
committed
Revert changes
1 parent b6554e9 commit 9eb7eb7

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Compiler {
8585
new SeqLiterals, // Express vararg arguments as arrays
8686
new InterceptedMethods, // Special handling of `==`, `|=`, `getClass` methods
8787
new Getters, // Replace non-private vals and vars with getter defs (fields are added later)
88-
// new SpecializeFunctions, // Specialized Function{0,1,2} by replacing super with specialized super
88+
new SpecializeFunctions, // Specialized Function{0,1,2} by replacing super with specialized super
8989
new LiftTry, // Put try expressions that might execute on non-empty stacks into their own methods
9090
new CollectNullableFields, // Collect fields that can be nulled out after use in lazy initialization
9191
new ElimOuterSelect, // Expand outer selections

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

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ class SpecializeApplyMethods extends MiniPhase with InfoTransformer {
3434
atNextPhase(newSymbol(sym, name, Flags.Method, MethodType(args, ret)))
3535
}
3636

37-
private def specFun0(op: Type => Unit)(using Context): Unit = {
37+
private inline def specFun0(inline op: Type => Unit)(using Context): Unit = {
3838
for (r <- defn.Function0SpecializedReturnTypes) do
3939
op(r)
4040
}
4141

42-
private def specFun1(op: (Type, Type) => Unit)(using Context): Unit = {
42+
private inline def specFun1(inline op: (Type, Type) => Unit)(using Context): Unit = {
4343
for
4444
r <- defn.Function1SpecializedReturnTypes
4545
t1 <- defn.Function1SpecializedParamTypes
4646
do
4747
op(t1, r)
4848
}
4949

50-
private def specFun2(op: (Type, Type, Type) => Unit)(using Context): Unit = {
50+
private inline def specFun2(inline op: (Type, Type, Type) => Unit)(using Context): Unit = {
5151
for
5252
r <- defn.Function2SpecializedReturnTypes
5353
t1 <- defn.Function2SpecializedParamTypes
54-
t2 <- defn.Function2SpecializedReturnTypes
54+
t2 <- defn.Function2SpecializedParamTypes
5555
do
5656
op(t1, t2, r)
5757
}
@@ -63,30 +63,29 @@ class SpecializeApplyMethods extends MiniPhase with InfoTransformer {
6363

6464
/** Add symbols for specialized methods to FunctionN */
6565
override def transformInfo(tp: Type, sym: Symbol)(using Context) = tp match {
66-
// case tp: ClassInfo =>
67-
// if sym == defn.SpecializableFunctions(0) then
68-
// val scope = tp.decls.cloneScope
69-
// specFun0 { r => scope.enter(specApplySymbol(sym, Nil, r)) }
70-
// tp.derivedClassInfo(decls = scope)
66+
case tp: ClassInfo =>
67+
if sym == defn.SpecializableFunctions(0) then
68+
val scope = tp.decls.cloneScope
69+
specFun0 { r => scope.enter(specApplySymbol(sym, Nil, r)) }
70+
tp.derivedClassInfo(decls = scope)
7171

72-
// else if sym == defn.SpecializableFunctions(1) then
73-
// val scope = tp.decls.cloneScope
74-
// specFun1 { (t1, r) => scope.enter(specApplySymbol(sym, List(t1), r)) }
75-
// tp.derivedClassInfo(decls = scope)
72+
else if sym == defn.SpecializableFunctions(1) then
73+
val scope = tp.decls.cloneScope
74+
specFun1 { (t1, r) => scope.enter(specApplySymbol(sym, List(t1), r)) }
75+
tp.derivedClassInfo(decls = scope)
7676

77-
// else if sym == defn.SpecializableFunctions(2) then
78-
// val scope = tp.decls.cloneScope
79-
// specFun2 { (t1, t2, r) => scope.enter(specApplySymbol(sym, List(t1, t2), r)) }
80-
// tp.derivedClassInfo(decls = scope)
77+
else if sym == defn.SpecializableFunctions(2) then
78+
val scope = tp.decls.cloneScope
79+
specFun2 { (t1, t2, r) => scope.enter(specApplySymbol(sym, List(t1, t2), r)) }
80+
tp.derivedClassInfo(decls = scope)
8181

82-
// else tp
82+
else tp
8383

8484
case _ => tp
8585
}
8686

8787
/** Create bridge methods for FunctionN with specialized applys */
88-
// override def transformTemplate(tree: Template)(using Context) = {
89-
def transformTemplate1(tree: Template)(using Context) = {
88+
override def transformTemplate(tree: Template)(using Context) = {
9089
val cls = tree.symbol.owner.asClass
9190

9291
def synthesizeApply(names: collection.Set[TermName]): Tree = {

0 commit comments

Comments
 (0)