@@ -495,7 +495,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
495
495
case _ => tree
496
496
}}
497
497
498
- val inlineTyper = if (meth.isTransparentMethod) new InlineTyper else new InlineReTyper
498
+ val inlineTyper = if (meth.isTransparentMethod) new TransparentTyper else new InlineReTyper
499
499
val inlineCtx = inlineContext(call).fresh.setTyper(inlineTyper).setNewScope
500
500
501
501
// The complete translation maps references to `this` and parameters to
@@ -523,16 +523,18 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
523
523
expansion
524
524
}
525
525
526
- trace(i " inlining $call\n , BINDINGS = \n ${bindingsBuf.toList} % \n % \n EXPANSION = \n $expansion " , inlining, show = true ) {
526
+ trace(i " inlining $call" , inlining, show = true ) {
527
527
528
528
// The final expansion runs a typing pass over the inlined tree. See InlineTyper for details.
529
529
val expansion1 = inlineTyper.typed(expansion, pt)(inlineCtx)
530
530
531
531
/** All bindings in `bindingsBuf` except bindings of inlineable closures */
532
532
val bindings = bindingsBuf.toList.map(_.withPos(call.pos))
533
533
534
- inlining.println(i " original bindings = $bindings% \n % " )
535
- inlining.println(i " original expansion = $expansion1" )
534
+ if (ctx.settings.verbose.value) {
535
+ inlining.println(i " original bindings = $bindings% \n % " )
536
+ inlining.println(i " original expansion = $expansion1" )
537
+ }
536
538
537
539
val (finalBindings, finalExpansion) = dropUnusedDefs(bindings, expansion1)
538
540
@@ -625,13 +627,24 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
625
627
}
626
628
627
629
/** A full typer used for transparent methods */
628
- private class InlineTyper extends Typer with InlineTyping {
630
+ private class TransparentTyper extends Typer with InlineTyping {
629
631
630
632
override def typedTypedSplice (tree : untpd.TypedSplice )(implicit ctx : Context ): Tree =
631
633
tree.splice match {
632
634
case InlineableArg (rhs) => inlining.println(i " inline arg $tree -> $rhs" ); rhs
633
635
case _ => super .typedTypedSplice(tree)
634
636
}
637
+
638
+ /** Pre-type any nested calls to transparent methods. Otherwise the declared result type
639
+ * of these methods can influence constraints
640
+ */
641
+ override def typedApply (tree : untpd.Apply , pt : Type )(implicit ctx : Context ) = {
642
+ def typeTransparent (tree : untpd.Tree ): untpd.Tree =
643
+ if (tree.symbol.isTransparentMethod) untpd.TypedSplice (typed(tree))
644
+ else tree
645
+ val tree1 = tree.args.mapConserve(typeTransparent)
646
+ super .typedApply(untpd.cpy.Apply (tree)(tree.fun, tree1), pt)
647
+ }
635
648
}
636
649
637
650
/** A re-typer used for inlined methods */
0 commit comments