Skip to content

Commit 5e01703

Browse files
committed
Fix #3597 - Don't check inline for params after pickling
There was a discrepancy in that value parameters had a Deferred flag set before pickling but not after unpickling. This triggered a check that the (missing) rhs of an inline parameter was a constant. This commit changes the condition of the test to also exclude parameters. It also aligns frontend and unpickler in that the frontend will no longer mark term parameters as Deferred.
1 parent 885165b commit 5e01703

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
264264
*/
265265
def lacksDefinition(mdef: MemberDef)(implicit ctx: Context) = mdef match {
266266
case mdef: ValOrDefDef =>
267-
mdef.unforcedRhs == EmptyTree && !mdef.name.isConstructorName && !mdef.mods.is(ParamAccessor)
267+
mdef.unforcedRhs == EmptyTree && !mdef.name.isConstructorName && !mdef.mods.is(TermParamOrAccessor)
268268
case mdef: TypeDef =>
269269
def isBounds(rhs: Tree): Boolean = rhs match {
270270
case _: TypeBoundsTree => true

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ object Flags {
575575
final val SyntheticOrPrivate = Synthetic | Private
576576

577577
/** A deferred member or a parameter accessor (these don't have right hand sides) */
578-
final val DeferredOrParamAccessor = Deferred | ParamAccessor
578+
final val DeferredOrParamOrAccessor = Deferred | Param | ParamAccessor
579579

580580
/** value that's final or inline */
581581
final val FinalOrInline = Final | Inline

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
13001300
case rhs => typedExpr(rhs, tpt1.tpe)
13011301
}
13021302
val vdef1 = assignType(cpy.ValDef(vdef)(name, tpt1, rhs1), sym)
1303-
if (sym.is(Inline, butNot = DeferredOrParamAccessor))
1303+
if (sym.is(Inline, butNot = DeferredOrParamOrAccessor))
13041304
checkInlineConformant(rhs1, em"right-hand side of inline $sym")
13051305
patchIfLazy(vdef1)
13061306
patchFinalVals(vdef1)

tests/pos-from-tasty/i3597.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test {
2+
def bar(inline n: Int) = n
3+
}

0 commit comments

Comments
 (0)