Skip to content

Commit f77b3a9

Browse files
committed
Address review comments
1 parent f3e0170 commit f77b3a9

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

-6
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,6 @@ object desugar {
202202
* def f[T](x: Int)(y: String)(implicit evidence$0: B[T]) = ...
203203
* def f$default$1[T] = 1
204204
* def f$default$2[T](x: Int) = x + "m"
205-
*
206-
* 3. Upcast non-specializing inline methods. E.g.
207-
*
208-
* inline def f(x: Boolean): Any = if (x) 1 else ""
209-
* ==>
210-
* inline def f(x: Boolean): Any = (if (x) 1 else ""): Any
211205
*/
212206
private def defDef(meth0: DefDef, isPrimaryConstructor: Boolean = false)(implicit ctx: Context): Tree = {
213207
val meth @ DefDef(_, tparams, vparamss, tpt, rhs) = transformQuotedPatternName(meth0)

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,7 @@ class Namer { typer: Typer =>
865865
case original: untpd.DefDef if sym.isInlineMethod =>
866866
def rhsToInline(using Context): tpd.Tree =
867867
val mdef = typedAheadExpr(original).asInstanceOf[tpd.DefDef]
868-
if original.mods.hasMod(classOf[untpd.Mod.Transparent]) then mdef.rhs
869-
else tpd.Typed(mdef.rhs, mdef.tpt)
868+
PrepareInlineable.wrapRHS(original, mdef.tpt, mdef.rhs)
870869
PrepareInlineable.registerInlineInfo(sym, rhsToInline)(localContext(sym))
871870
case _ =>
872871
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ object PrepareInlineable {
206206

207207
/** The type ascription `rhs: tpt`, unless `original` is `transparent`. */
208208
def wrapRHS(original: untpd.DefDef, tpt: Tree, rhs: Tree)(using Context): Tree =
209-
if original.mods.mods.exists(_.isInstanceOf[untpd.Mod.Transparent]) then rhs
209+
if original.mods.hasMod(classOf[untpd.Mod.Transparent]) then rhs
210210
else Typed(rhs, tpt)
211211

212212
/** Register inline info for given inlineable method `sym`.
@@ -228,7 +228,7 @@ object PrepareInlineable {
228228
inlined.updateAnnotation(LazyBodyAnnotation {
229229
given ctx as Context = inlineCtx
230230
val initialErrorCount = ctx.reporter.errorCount
231-
var inlinedBody = treeExpr(using ctx)
231+
var inlinedBody = treeExpr
232232
if (ctx.reporter.errorCount == initialErrorCount) {
233233
inlinedBody = ctx.compilationUnit.inlineAccessors.makeInlineable(inlinedBody)
234234
checkInlineMethod(inlined, inlinedBody)

0 commit comments

Comments
 (0)