@@ -862,15 +862,14 @@ trait Checking {
862862 }
863863
864864 /** Check that `tree` can be right hand-side or argument to `inline` value or parameter. */
865- def checkInlineConformant (tree : Tree , isFinal : Boolean , what : => String )(using Context ): Unit = {
866- // final vals can be marked inline even if they're not pure, see Typer#patchFinalVals
867- val purityLevel = if (isFinal) Idempotent else Pure
868- tree.tpe.widenTermRefExpr match {
869- case tp : ConstantType if exprPurity(tree) >= purityLevel => // ok
870- case _ =>
871- if (! ctx.erasedTypes && ! ctx.inInlineMethod)
872- ctx.error(em " $what must be a known value " , tree.sourcePos)
873- }
865+ def checkInlineConformant (tpt : Tree , tree : Tree , sym : Symbol )(using Context ): Unit = {
866+ if sym.is(Inline , butNot = DeferredOrTermParamOrAccessor ) && ! ctx.erasedTypes && ! ctx.inInlineMethod then
867+ // final vals can be marked inline even if they're not pure, see Typer#patchFinalVals
868+ val purityLevel = if (sym.is(Final )) Idempotent else Pure
869+ tpt.tpe.widenTermRefExpr match
870+ case tp : ConstantType if exprPurity(tree) >= purityLevel => // ok
871+ case _ =>
872+ ctx.error(em " type of inline must be a known value " , tree.sourcePos)
874873 }
875874
876875 /** A hook to exclude selected symbols from double declaration check */
@@ -1199,7 +1198,7 @@ trait NoChecking extends ReChecking {
11991198 override def checkImplicitConversionDefOK (sym : Symbol )(using Context ): Unit = ()
12001199 override def checkImplicitConversionUseOK (sym : Symbol , posd : Positioned )(using Context ): Unit = ()
12011200 override def checkFeasibleParent (tp : Type , pos : SourcePosition , where : => String = " " )(using Context ): Type = tp
1202- override def checkInlineConformant (tree : Tree , isFinal : Boolean , what : => String )(using Context ): Unit = ()
1201+ override def checkInlineConformant (tpt : Tree , tree : Tree , sym : Symbol )(using Context ): Unit = ()
12031202 override def checkNoAlphaConflict (stats : List [Tree ])(using Context ): Unit = ()
12041203 override def checkParentCall (call : Tree , caller : ClassSymbol )(using Context ): Unit = ()
12051204 override def checkSimpleKinded (tpt : Tree )(using Context ): Tree = tpt
0 commit comments