diff --git a/compiler/src/dotty/tools/dotc/core/NameKinds.scala b/compiler/src/dotty/tools/dotc/core/NameKinds.scala index ef9e62d113a8..6e5de7071aa7 100644 --- a/compiler/src/dotty/tools/dotc/core/NameKinds.scala +++ b/compiler/src/dotty/tools/dotc/core/NameKinds.scala @@ -295,7 +295,7 @@ object NameKinds { val DocArtifactName: UniqueNameKind = new UniqueNameKind("$doc") val UniqueInlineName: UniqueNameKind = new UniqueNameKind("$i") val InlineScrutineeName: UniqueNameKind = new UniqueNameKind("$scrutinee") - val InlineBinderName: UniqueNameKind = new UniqueNameKind("$elem") + val InlineBinderName: UniqueNameKind = new UniqueNameKind("$proxy") /** A kind of unique extension methods; Unlike other unique names, these can be * unmangled. diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 0bb431a1479a..ccee284be953 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -421,7 +421,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { val (bindingFlags, bindingType) = if (isByName) (inlineFlags, ExprType(argtpe.widen)) else (inlineFlags, argtpe.widen) - val boundSym = newSym(name, bindingFlags, bindingType).asTerm + val boundSym = newSym(InlineBinderName.fresh(name.asTermName), bindingFlags, bindingType).asTerm val binding = { if (isByName) DefDef(boundSym, arg.changeOwner(ctx.owner, boundSym)) else ValDef(boundSym, arg) diff --git a/compiler/test/dotty/tools/backend/jvm/InlineBytecodeTests.scala b/compiler/test/dotty/tools/backend/jvm/InlineBytecodeTests.scala index 085ad1b4b445..96611aae2fa6 100644 --- a/compiler/test/dotty/tools/backend/jvm/InlineBytecodeTests.scala +++ b/compiler/test/dotty/tools/backend/jvm/InlineBytecodeTests.scala @@ -424,7 +424,7 @@ class InlineBytecodeTests extends DottyBytecodeTest { val fun = getMethod(clsNode, "test") val instructions = instructionsFromMethod(fun) - val expected = List(Invoke(INVOKESTATIC, "Foo", "f$1", "()V", false), Op(RETURN)) + val expected = List(Invoke(INVOKESTATIC, "Foo", "f$proxy1$1", "()V", false), Op(RETURN)) assert(instructions == expected, "`inlined` was not properly inlined in `test`\n" + diffInstructions(instructions, expected)) diff --git a/tests/pos/i9342a.scala b/tests/pos/i9342a.scala new file mode 100644 index 000000000000..c90731feeadf --- /dev/null +++ b/tests/pos/i9342a.scala @@ -0,0 +1,3 @@ +inline def label(x: Int, inline g: Int => String): String = g(x) +def f: Int => String = ??? +def label2(g: Int) = label(g, f) diff --git a/tests/pos/i9342b.scala b/tests/pos/i9342b.scala new file mode 100644 index 000000000000..c6712c00236f --- /dev/null +++ b/tests/pos/i9342b.scala @@ -0,0 +1,10 @@ +trait Label[A]: + def apply(v: A): String + +given [A] as Label[A] = _.toString + +extension [A](x: A) inline def label(using inline l: Label[A]): String = l(x) + +def label1[A](v: A) = v.label + +def label2[A](l: A) = l.label diff --git a/tests/pos/i9342c.scala b/tests/pos/i9342c.scala new file mode 100644 index 000000000000..eed9d45326f1 --- /dev/null +++ b/tests/pos/i9342c.scala @@ -0,0 +1,9 @@ +trait Label[A]: + def apply(v: A): String + +def g[A]: Label[A] = _.toString + +inline def label[A](x: A, inline l: Label[A]): String = l(x) + +def label1[A](v: A) = label(v, g) +def label2[A](l: A) = label(l, g) diff --git a/tests/run-macros/quote-inline-function.check b/tests/run-macros/quote-inline-function.check index 65ef8a064247..57abdefad982 100644 --- a/tests/run-macros/quote-inline-function.check +++ b/tests/run-macros/quote-inline-function.check @@ -3,11 +3,11 @@ Normal function var i: scala.Int = 0 val j: scala.Int = 5 while (i.<(j)) { - f.apply(i) + f$proxy1.apply(i) i = i.+(1) } while ({ - f.apply(i) + f$proxy1.apply(i) i = i.+(1) i.<(j) }) () @@ -18,11 +18,11 @@ By name function var i: scala.Int = 0 val j: scala.Int = 5 while (i.<(j)) { - f.apply(i) + f$proxy2.apply(i) i = i.+(1) } while ({ - f.apply(i) + f$proxy2.apply(i) i = i.+(1) i.<(j) }) () diff --git a/tests/run-macros/quoted-matching-docs.check b/tests/run-macros/quoted-matching-docs.check index 9ff2df78d8c0..fb1c2283d68d 100644 --- a/tests/run-macros/quoted-matching-docs.check +++ b/tests/run-macros/quoted-matching-docs.check @@ -2,5 +2,5 @@ 6 10.+(Test.a) 15 -args.sum[scala.Int](scala.math.Numeric.IntIsIntegral) +args$proxy5.sum[scala.Int](scala.math.Numeric.IntIsIntegral) 9 diff --git a/tests/run-macros/tasty-argument-tree-1.check b/tests/run-macros/tasty-argument-tree-1.check index b8a57f737c5c..9f400af67132 100644 --- a/tests/run-macros/tasty-argument-tree-1.check +++ b/tests/run-macros/tasty-argument-tree-1.check @@ -5,7 +5,7 @@ tree deref. vals: Literal(Constant(3)) tree: Inlined(None, Nil, Ident("v")) tree deref. vals: Literal(Constant(1)) -tree: Inlined(None, Nil, Ident("x")) +tree: Inlined(None, Nil, Ident("x$proxy1")) tree deref. vals: Literal(Constant(2)) tree: Inlined(None, Nil, Ident("l")) @@ -14,29 +14,29 @@ tree deref. vals: Literal(Constant(3)) tree: Inlined(None, Nil, Ident("a")) tree deref. vals: Ident("a") -tree: Inlined(None, Nil, Ident("x")) +tree: Inlined(None, Nil, Ident("x$proxy2")) tree deref. vals: Ident("b") -tree: Inlined(None, Nil, Ident("x")) +tree: Inlined(None, Nil, Ident("x$proxy3")) tree deref. vals: Apply(Ident("d2"), Nil) -tree: Inlined(None, Nil, Ident("x")) +tree: Inlined(None, Nil, Ident("x$proxy4")) tree deref. vals: Apply(Ident("d3"), List(Literal(Constant(3)))) -tree: Inlined(None, Nil, Ident("x")) +tree: Inlined(None, Nil, Ident("x$proxy5")) tree deref. vals: TypeApply(Ident("d4"), List(TypeIdent("Int"))) tree: Inlined(None, Nil, Ident("vv")) tree deref. vals: Literal(Constant(1)) -tree: Inlined(None, Nil, Ident("x")) +tree: Inlined(None, Nil, Ident("x$proxy6")) tree deref. vals: Literal(Constant(1)) tree: Inlined(None, Nil, Ident("vd")) tree deref. vals: Literal(Constant(2)) -tree: Inlined(None, Nil, Ident("x")) +tree: Inlined(None, Nil, Ident("x$proxy7")) tree deref. vals: Literal(Constant(2)) -tree: Inlined(None, Nil, Ident("x")) +tree: Inlined(None, Nil, Ident("x$proxy8")) tree deref. vals: Apply(TypeApply(Select(Ident("Tuple2"), "apply"), List(Inferred(), Inferred())), List(Literal(Constant(1)), Literal(Constant(2))))