Skip to content

Commit efd5310

Browse files
committed
Implement tweak
In bodies of transparent unerased method we inline only transparent erased methods.
1 parent 1299850 commit efd5310

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
276276
/** Are we in a transparent method body? */
277277
def inTransparentMethod = owner.ownersIterator.exists(_.isTransparentMethod)
278278

279+
/** Are we in a transparent method body? */
280+
def inErasedTransparentMethod = owner.ownersIterator.exists(sym =>
281+
sym.isTransparentMethod && sym.is(Erased))
282+
279283
/** Is `feature` enabled in class `owner`?
280284
* This is the case if one of the following two alternatives holds:
281285
*

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ object Inliner {
5858
/** Should call with method `meth` be inlined in this context? */
5959
def isInlineable(meth: Symbol)(implicit ctx: Context): Boolean = {
6060

61+
/** Suppress inlining of
62+
* - non-erased methods inside a transparent method,
63+
* - all methods inside an erased transparent method
64+
*/
6165
def suppressInline =
62-
ctx.inTransparentMethod ||
66+
ctx.inTransparentMethod && (!meth.is(Erased) || ctx.inErasedTransparentMethod) ||
6367
ctx.settings.YnoInline.value ||
6468
ctx.isAfterTyper ||
6569
ctx.reporter.hasErrors

tests/run/i4735/App_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ object Test {
77
System.out.println(2*x)
88
}
99
}
10+
1011
}
1112

1213
class Unrolled(arr: Array[Int]) extends AnyVal {

0 commit comments

Comments
 (0)