Skip to content

Commit 506476f

Browse files
author
gorilskij
committed
implement using fun.tpe
1 parent 9e221a8 commit 506476f

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -207,36 +207,13 @@ object Inliner {
207207
val cls = newNormalizedClassSymbol(ctx.owner, tpnme.ANON_CLASS, Synthetic | Final, List(defn.ObjectType), coord = sym.coord)
208208
val constr = newConstructor(cls, Synthetic, Nil, Nil, coord = sym.coord).entered
209209

210-
val (targs1, targs2) = fun match
211-
// extension [T] (x: X) def unapply[U](y: Y)
212-
case TypeApply(Apply(TypeApply(_, targs1), _), targs2) => (targs1, targs2)
213-
// def unapply[U](y: Y)
214-
case TypeApply(_, targs) => (targs, Nil)
215-
// extension [T] (x: X) def unapply(y: Y)
216-
case Apply(TypeApply(_, targs1), _) => (targs1, Nil)
217-
// def unapply(y: Y)
218-
case _ => (Nil, Nil)
219-
220-
def extensionInfo(info: Type, targs: List[Tree]): Type =
221-
info match
222-
case MethodTpe(_, _, rt: PolyType) => rt.instantiate(targs.map(_.tpe))
223-
case MethodTpe(_, _, rt) => rt
224-
case info => info
225-
226-
val unapplyInfo = sym.info match
227-
case pt: PolyType =>
228-
val info = pt.instantiate(targs1.map(_.tpe))
229-
if sym.flags.is(ExtensionMethod) then extensionInfo(info, targs2) else info
230-
case info =>
231-
if sym.flags.is(ExtensionMethod) then extensionInfo(info, targs1) else info
232-
233-
val unappplySym = newSymbol(cls, sym.name.toTermName, Synthetic | Method, unapplyInfo, coord = sym.coord).entered
234-
val unapply = DefDef(unappplySym, argss =>
235-
inlineCall(fun.appliedToArgss(argss).withSpan(unapp.span))(using ctx.withOwner(unappplySym))
210+
val unapplySym = newSymbol(cls, sym.name.toTermName, Synthetic | Method, fun.tpe, coord = sym.coord).entered
211+
val unapply = DefDef(unapplySym, argss =>
212+
inlineCall(fun.appliedToArgss(argss).withSpan(unapp.span))(using ctx.withOwner(unapplySym))
236213
)
237214
val cdef = ClassDef(cls, DefDef(constr), List(unapply))
238215
val newUnapply = Block(cdef :: Nil, New(cls.typeRef, Nil))
239-
val newFun = newUnapply.select(unappplySym).withSpan(unapp.span)
216+
val newFun = newUnapply.select(unapplySym).withSpan(unapp.span)
240217
cpy.UnApply(unapp)(newFun, implicits, patterns)
241218
}
242219

0 commit comments

Comments
 (0)