Skip to content

Commit 56acbc9

Browse files
committed
Simplify removal of erased paramters
1 parent 15b9cd8 commit 56acbc9

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

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

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -318,20 +318,6 @@ object Splicer {
318318
protected def interpretNew(fn: Symbol, args: => List[Result])(implicit env: Env): Result
319319
protected def unexpectedTree(tree: Tree)(implicit env: Env): Result
320320

321-
private final def removeErasedArguments(args: List[List[Tree]], fnTpe: Type): List[List[Tree]] =
322-
fnTpe match {
323-
case tp: TermRef => removeErasedArguments(args, tp.underlying)
324-
case tp: PolyType => removeErasedArguments(args, tp.resType)
325-
case tp: ExprType => removeErasedArguments(args, tp.resType)
326-
case tp: MethodType =>
327-
val tail = removeErasedArguments(args.tail, tp.resType)
328-
if (tp.isErasedMethod) tail else args.head :: tail
329-
case tp: AppliedType if defn.isImplicitFunctionType(tp) =>
330-
val tail = removeErasedArguments(args.tail, tp.args.last)
331-
if (defn.isErasedFunctionType(tp)) tail else args.head :: tail
332-
case tp => assert(args.isEmpty, tp); Nil
333-
}
334-
335321
protected final def interpretTree(tree: Tree)(implicit env: Env): Result = tree match {
336322
case Apply(TypeApply(fn, _), quoted :: Nil) if fn.symbol == defn.InternalQuoted_exprQuote =>
337323
val quoted1 = quoted match {
@@ -359,11 +345,11 @@ object Splicer {
359345
interpretModuleAccess(fn.symbol)
360346
} else if (fn.symbol.isStatic) {
361347
val module = fn.symbol.owner
362-
def interpretedArgs = removeErasedArguments(args, fn.tpe).flatten.map(interpretTree)
348+
def interpretedArgs = args.flatten.map(interpretTree)
363349
interpretStaticMethodCall(module, fn.symbol, interpretedArgs)
364350
} else if (fn.qualifier.symbol.is(Module) && fn.qualifier.symbol.isStatic) {
365351
val module = fn.qualifier.symbol.moduleClass
366-
def interpretedArgs = removeErasedArguments(args, fn.tpe).flatten.map(interpretTree)
352+
def interpretedArgs = args.flatten.map(interpretTree)
367353
interpretStaticMethodCall(module, fn.symbol, interpretedArgs)
368354
} else if (env.contains(fn.name)) {
369355
env(fn.name)
@@ -407,12 +393,14 @@ object Splicer {
407393
def unapply(arg: Tree): Option[(RefTree, List[List[Tree]])] =
408394
Call0.unapply(arg).map((fn, args) => (fn, args.reverse))
409395

410-
object Call0 {
396+
private object Call0 {
411397
def unapply(arg: Tree): Option[(RefTree, List[List[Tree]])] = arg match {
412398
case Select(Call0(fn, args), nme.apply) if defn.isImplicitFunctionType(fn.tpe.widenDealias.finalResultType) =>
413399
Some((fn, args))
414400
case fn: RefTree => Some((fn, Nil))
415-
case Apply(Call0(fn, args1), args2) => Some((fn, args2 :: args1))
401+
case Apply(f @ Call0(fn, args1), args2) =>
402+
if (f.tpe.widenDealias.isErasedMethod) Some((fn, args1))
403+
else Some((fn, args2 :: args1))
416404
case TypeApply(Call0(fn, args), _) => Some((fn, args))
417405
case _ => None
418406
}

0 commit comments

Comments
 (0)