@@ -887,17 +887,20 @@ trait Checking {
887
887
*/
888
888
def checkInlineConformant (tpt : Tree , tree : Tree , sym : Symbol )(using Context ): Tree = {
889
889
if sym.is(Inline , butNot = DeferredOrTermParamOrAccessor ) && ! ctx.erasedTypes && ! ctx.inInlineMethod then
890
- tree.tpe.widenTermRefExpr.dealias match
891
- case tp : ConstantType =>
892
- // final vals can be marked inline even if they're not pure, see Typer#patchFinalVals
893
- val purityLevel = if (sym.is(Final )) Idempotent else Pure
894
- if ! (exprPurity(tree) >= purityLevel) then
895
- ctx.error(" inline value must be pure" , tree.sourcePos)
896
- if tree.tpe =:= tpt.tpe then tpt
897
- else TypeTree (tree.tpe).withSpan(tpt.span)
890
+ // final vals can be marked inline even if they're not pure, see Typer#patchFinalVals
891
+ val purityLevel = if (sym.is(Final )) Idempotent else Pure
892
+ if ! (exprPurity(tree) >= purityLevel) then
893
+ ctx.error(" inline value must be pure" , tree.sourcePos)
894
+ tpt
895
+ else tpt.tpe.widenTermRefExpr.dealias match
896
+ case tp : ConstantType => tpt
898
897
case _ =>
899
- ctx.error(" inline value must have a literal constant type" , tree.sourcePos)
900
- tpt
898
+ if sym.is(Transparent ) then
899
+ TypeTree (tree.tpe).withSpan(tpt.span)
900
+ else
901
+ val pos = if tpt.span.isZeroExtent then tree.sourcePos else tpt.sourcePos
902
+ ctx.error(" inline value must have a literal constant type" , pos)
903
+ tpt
901
904
else
902
905
tpt
903
906
}
0 commit comments