@@ -335,15 +335,6 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
335
335
}
336
336
}
337
337
338
- private object dropInlines extends TreeMap {
339
- override def transform (tree : Tree )(using Context ): Tree = tree match {
340
- case tree @ Inlined (call, _, expansion) =>
341
- val newExpansion = PruneErasedDefs .trivialErasedTree(tree)
342
- cpy.Inlined (tree)(call, Nil , newExpansion)
343
- case _ => super .transform(tree)
344
- }
345
- }
346
-
347
338
def checkUsableAsValue (tree : Tree )(using Context ): Tree =
348
339
def unusable (msg : Symbol => Message ) =
349
340
errorTree(tree, msg(tree.symbol))
@@ -414,26 +405,13 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
414
405
checkUsableAsValue(tree) match
415
406
case tree1 : Select => transformSelect(tree1, Nil )
416
407
case tree1 => tree1
417
- case tree : Apply =>
418
- val methType = tree.fun.tpe.widen.asInstanceOf [MethodType ]
419
- val app =
420
- if (methType.hasErasedParams)
421
- tpd.cpy.Apply (tree)(
422
- tree.fun,
423
- tree.args.zip(methType.erasedParams).map((arg, isErased) =>
424
- if ! isErased then arg
425
- else
426
- if methType.isResultDependent then
427
- Checking .checkRealizable(arg.tpe, arg.srcPos, " erased argument" )
428
- if (methType.isImplicitMethod && arg.span.isSynthetic)
429
- arg match
430
- case _ : RefTree | _ : Apply | _ : TypeApply if arg.symbol.is(Erased ) =>
431
- dropInlines.transform(arg)
432
- case _ =>
433
- PruneErasedDefs .trivialErasedTree(arg)
434
- else dropInlines.transform(arg)))
435
- else
436
- tree
408
+ case app : Apply =>
409
+ val methType = app.fun.tpe.widen.asInstanceOf [MethodType ]
410
+ if (methType.hasErasedParams)
411
+ for (arg, isErased) <- app.args.lazyZip(methType.erasedParams) do
412
+ if isErased then
413
+ if methType.isResultDependent then
414
+ Checking .checkRealizable(arg.tpe, arg.srcPos, " erased argument" )
437
415
def app1 =
438
416
// reverse order of transforming args and fun. This way, we get a chance to see other
439
417
// well-formedness errors before reporting errors in possible inferred type args of fun.
@@ -499,7 +477,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
499
477
registerIfHasMacroAnnotations(tree)
500
478
checkErasedDef(tree)
501
479
Checking .checkPolyFunctionType(tree.tpt)
502
- val tree1 = cpy.ValDef (tree)(tpt = makeOverrideTypeDeclared(tree.symbol, tree.tpt), rhs = normalizeErasedRhs(tree.rhs, tree.symbol) )
480
+ val tree1 = cpy.ValDef (tree)(tpt = makeOverrideTypeDeclared(tree.symbol, tree.tpt))
503
481
if tree1.removeAttachment(desugar.UntupledParam ).isDefined then
504
482
checkStableSelection(tree.rhs)
505
483
processValOrDefDef(super .transform(tree1))
@@ -508,7 +486,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
508
486
checkErasedDef(tree)
509
487
Checking .checkPolyFunctionType(tree.tpt)
510
488
annotateContextResults(tree)
511
- val tree1 = cpy.DefDef (tree)(tpt = makeOverrideTypeDeclared(tree.symbol, tree.tpt), rhs = normalizeErasedRhs(tree.rhs, tree.symbol) )
489
+ val tree1 = cpy.DefDef (tree)(tpt = makeOverrideTypeDeclared(tree.symbol, tree.tpt))
512
490
processValOrDefDef(superAcc.wrapDefDef(tree1)(super .transform(tree1).asInstanceOf [DefDef ]))
513
491
case tree : TypeDef =>
514
492
registerIfHasMacroAnnotations(tree)
@@ -632,12 +610,6 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
632
610
Checking .checkAndAdaptExperimentalImports(trees)
633
611
super .transformStats(trees, exprOwner, wrapResult)
634
612
635
- /** Transforms the rhs tree into a its default tree if it is in an `erased` val/def.
636
- * Performed to shrink the tree that is known to be erased later.
637
- */
638
- private def normalizeErasedRhs (rhs : Tree , sym : Symbol )(using Context ) =
639
- if (sym.isEffectivelyErased) dropInlines.transform(rhs) else rhs
640
-
641
613
private def registerNeedsInlining (tree : Tree )(using Context ): Unit =
642
614
if tree.symbol.is(Inline ) && ! Inlines .inInlineMethod && ! ctx.mode.is(Mode .NoInline ) then
643
615
ctx.compilationUnit.needsInlining = true
0 commit comments