From 428bddb27eceea787ca755359ca2e52f28c92e4f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 20 Jan 2020 15:00:58 +0100 Subject: [PATCH 1/2] Test case --- tests/run/i8035.scala | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/run/i8035.scala diff --git a/tests/run/i8035.scala b/tests/run/i8035.scala new file mode 100644 index 000000000000..fe44adf9ea94 --- /dev/null +++ b/tests/run/i8035.scala @@ -0,0 +1,8 @@ +implicit class Ops[A](val a: String) extends AnyVal { + def foo(e: => String): Unit = () +} + +def bar(e: => String): Unit = (new Ops("")).foo(e) +def baz(e: => String): Unit = "".foo(e) + +@main def Test = baz("") \ No newline at end of file From 9928fd4c50e0d5e1fdae03b829f65898d8510369 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 21 Jan 2020 10:21:14 +0100 Subject: [PATCH 2/2] Fix #8035: Add missing transformFollowing to VCInlineMethods VCinline methods rewires function calls and sometimes pulls out the prefix so the original call becomes a subnode. In that case it has to make sure that the subnode call is still transformed by the following phases. --- .../src/dotty/tools/dotc/transform/VCInlineMethods.scala | 8 +++++--- tests/run/i8035.scala | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/VCInlineMethods.scala b/compiler/src/dotty/tools/dotc/transform/VCInlineMethods.scala index c9dbb2255508..a37649b24188 100644 --- a/compiler/src/dotty/tools/dotc/transform/VCInlineMethods.scala +++ b/compiler/src/dotty/tools/dotc/transform/VCInlineMethods.scala @@ -1,4 +1,5 @@ -package dotty.tools.dotc +package dotty.tools +package dotc package transform import ast.{Trees, tpd} @@ -71,10 +72,11 @@ class VCInlineMethods extends MiniPhase with IdentityDenotTransformer { evalOnce(qual) { ev => val ctArgs = ctParams.map(tparam => TypeTree(tparam.typeRef.asSeenFrom(ev.tpe, origCls))) - ref(extensionMeth) + transformFollowing( + ref(extensionMeth) .appliedToTypeTrees(mtArgs ++ ctArgs) .appliedTo(ev) - .appliedToArgss(mArgss) + .appliedToArgss(mArgss)) } else ref(extensionMeth) diff --git a/tests/run/i8035.scala b/tests/run/i8035.scala index fe44adf9ea94..605063d1665e 100644 --- a/tests/run/i8035.scala +++ b/tests/run/i8035.scala @@ -2,7 +2,7 @@ implicit class Ops[A](val a: String) extends AnyVal { def foo(e: => String): Unit = () } -def bar(e: => String): Unit = (new Ops("")).foo(e) -def baz(e: => String): Unit = "".foo(e) +def bar(e1: => String): Unit = (new Ops("")).foo(e1) +def baz(e2: => String): Unit = "".foo(e2) @main def Test = baz("") \ No newline at end of file