@@ -11,7 +11,7 @@ import core.Decorators._
11
11
import core .StdNames .nme
12
12
import core .Names ._
13
13
import core .NameOps ._
14
- import core .NameKinds .DirectName
14
+ import core .NameKinds .DirectMethodName
15
15
import ast .Trees ._
16
16
import ast .tpd
17
17
import collection .mutable
@@ -77,6 +77,7 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisTr
77
77
private def shouldBeSpecialized (sym : Symbol )(implicit ctx : Context ) =
78
78
sym.is(Method , butNot = Accessor ) &&
79
79
defn.isImplicitFunctionType(sym.info.finalResultType) &&
80
+ ! sym.isAnonymousFunction &&
80
81
(specializeMonoTargets || ! sym.isEffectivelyFinal || sym.allOverriddenSymbols.nonEmpty)
81
82
82
83
/** @pre The type's final result type is an implicit function type `implicit Ts => R`.
@@ -92,7 +93,7 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisTr
92
93
/** A new `m$direct` method to accompany the given method `m` */
93
94
private def newDirectMethod (sym : Symbol )(implicit ctx : Context ): Symbol = {
94
95
val direct = sym.copy(
95
- name = DirectName (sym.name.asTermName).asInstanceOf [sym.ThisName ],
96
+ name = DirectMethodName (sym.name.asTermName).asInstanceOf [sym.ThisName ],
96
97
flags = sym.flags | Synthetic ,
97
98
info = directInfo(sym.info))
98
99
if (direct.allOverriddenSymbols.isEmpty) direct.resetFlag(Override )
@@ -104,14 +105,13 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisTr
104
105
*/
105
106
private def directMethod (sym : Symbol )(implicit ctx : Context ): Symbol =
106
107
if (sym.owner.isClass) {
107
- val direct = sym.owner.info.member(DirectName (sym.name.asTermName))
108
+ val direct = sym.owner.info.member(DirectMethodName (sym.name.asTermName))
108
109
.suchThat(_.info matches directInfo(sym.info)).symbol
109
110
if (direct.maybeOwner == sym.owner) direct
110
111
else newDirectMethod(sym).enteredAfter(thisTransform)
111
112
}
112
113
else directMeth.getOrElseUpdate(sym, newDirectMethod(sym))
113
114
114
-
115
115
/** Transform `qual.apply` occurrences according to rewrite rule (2) above */
116
116
override def transformSelect (tree : Select )(implicit ctx : Context , info : TransformerInfo ) =
117
117
if (tree.name == nme.apply &&
@@ -122,7 +122,7 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisTr
122
122
case TypeApply (fn, args) => cpy.TypeApply (tree)(directQual(fn), args)
123
123
case Block (stats, expr) => cpy.Block (tree)(stats, directQual(expr))
124
124
case tree : RefTree =>
125
- cpy.Ref (tree)(DirectName (tree.name.asTermName))
125
+ cpy.Ref (tree)(DirectMethodName (tree.name.asTermName))
126
126
.withType(directMethod(tree.symbol).termRef)
127
127
}
128
128
directQual(tree.qualifier)
@@ -136,7 +136,7 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisTr
136
136
137
137
def splitClosure (tree : Tree ): (List [Type ] => List [List [Tree ]] => Tree , Tree ) = tree match {
138
138
case Block (Nil , expr) => splitClosure(expr)
139
- case Block ((meth @ DefDef (nme.ANON_FUN , Nil , clparams :: Nil , _, _)) :: Nil , cl : Closure ) =>
139
+ case Block ((meth @ DefDef (nme.ANON_FUN , Nil , clparams :: Nil , _, _)) :: rest , cl : Closure ) =>
140
140
val tparamSyms = mdef.tparams.map(_.symbol)
141
141
val vparamSymss = mdef.vparamss.map(_.map(_.symbol))
142
142
val clparamSyms = clparams.map(_.symbol)
@@ -149,16 +149,16 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisTr
149
149
val forwarder = ref(direct)
150
150
.appliedToTypeTrees(tparamSyms.map(ref(_)))
151
151
.appliedToArgss(vparamSymss.map(_.map(ref(_))) :+ clparamSyms.map(ref(_)))
152
- val fwdClosure = cpy.Block (tree)(cpy.DefDef (meth)(rhs = forwarder) :: Nil , cl)
152
+ val fwdClosure = cpy.Block (tree)(cpy.DefDef (meth)(rhs = forwarder) :: rest , cl)
153
153
(remappedCore, fwdClosure)
154
154
case EmptyTree =>
155
155
(_ => _ => EmptyTree , EmptyTree )
156
156
}
157
157
158
158
val (remappedCore, fwdClosure) = splitClosure(mdef.rhs)
159
159
val originalDef = cpy.DefDef (mdef)(rhs = fwdClosure)
160
- val directDef = polyDefDef(direct.asTerm, remappedCore)
161
- Thicket ( originalDef, directDef)
160
+ val directDef = transformDefDef( polyDefDef(direct.asTerm, remappedCore) )
161
+ flatTree( List ( originalDef, directDef) )
162
162
}
163
163
else mdef
164
164
}
0 commit comments