File tree Expand file tree Collapse file tree 3 files changed +38
-4
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -1227,13 +1227,21 @@ class Namer { typer: Typer =>
12271227 case pt : MethodOrPoly => 1 + extensionParamsCount(pt.resType)
12281228 case _ => 0
12291229 val ddef = tpd.DefDef (forwarder.asTerm, prefss => {
1230+ val forwarderCtx = ctx.withOwner(forwarder)
12301231 val (pathRefss, methRefss) = prefss.splitAt(extensionParamsCount(path.tpe.widen))
12311232 val ref = path.appliedToArgss(pathRefss).select(sym.asTerm)
1232- ref.appliedToArgss(adaptForwarderParams(Nil , sym.info, methRefss))
1233- .etaExpandCFT(using ctx.withOwner(forwarder))
1233+ val rhs = ref.appliedToArgss(adaptForwarderParams(Nil , sym.info, methRefss))
1234+ .etaExpandCFT(using forwarderCtx)
1235+ if forwarder.isInlineMethod then
1236+ // Eagerly make the body inlineable. `registerInlineInfo` does this lazily
1237+ // but it does not get evaluated during typer as the forwarder we are creating
1238+ // is already typed.
1239+ val inlinableRhs = PrepareInlineable .makeInlineable(rhs)(using forwarderCtx)
1240+ PrepareInlineable .registerInlineInfo(forwarder, inlinableRhs)(using forwarderCtx)
1241+ inlinableRhs
1242+ else
1243+ rhs
12341244 })
1235- if forwarder.isInlineMethod then
1236- PrepareInlineable .registerInlineInfo(forwarder, ddef.rhs)
12371245 buf += ddef.withSpan(span)
12381246 if hasDefaults then
12391247 foreachDefaultGetterOf(sym.asTerm,
Original file line number Diff line number Diff line change 1+ class Dog :
2+ inline given bark (using msg : String = " Woof!" ): String = s " bark: $msg"
3+
4+ class Wolf :
5+ private val dog : Dog = Dog ()
6+ export dog .given
7+
8+ def test =
9+ val w = Wolf ()
10+ import w .given
11+ summon[String ]
Original file line number Diff line number Diff line change 1+ class Context {
2+ def normalMethod (): String = " normal"
3+ inline def inlineMethod (): String = " inline"
4+ }
5+
6+ class Script (ctx : Context ) {
7+ export ctx .*
8+ normalMethod()
9+ inlineMethod()
10+ }
11+
12+ class MyScript (context : Context ) extends Script (context) {
13+ normalMethod()
14+ inlineMethod()
15+ }
You can’t perform that action at this time.
0 commit comments