Skip to content

Fix #26215: Exempt inline val from inliner postcondition check#26216

Open
starswap wants to merge 2 commits into
scala:mainfrom
starswap:hamish/fix-i26215
Open

Fix #26215: Exempt inline val from inliner postcondition check#26216
starswap wants to merge 2 commits into
scala:mainfrom
starswap:hamish/fix-i26215

Conversation

@starswap
Copy link
Copy Markdown
Contributor

@starswap starswap commented Jun 2, 2026

Fixes #26215.

How much have you relied on LLM-based tools in this contribution?

Not at all.

How was the solution tested?

New automated tests.

@starswap starswap marked this pull request as ready for review June 2, 2026 15:06
@starswap starswap changed the title Also check if we are in an inline val before checking post condition … Fix #26215: Exempt inline val from inliner postcondition check Jun 2, 2026
Copy link
Copy Markdown
Contributor

@som-snytt som-snytt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving but neutral without special expertise.

def traverse(tree: Tree)(using Context): Unit =
tree match
case tree: RefTree if !Inlines.inInlineMethod && StagingLevel.level == 0 =>
case tree: RefTree if !(Inlines.inInlineMethod || Inlines.inInlineVal) && StagingLevel.level == 0 =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could Inlines.inInlineMethodOrVal to reduce walking owners chain.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it is more natural and efficient to check symbol.isInlineMethod before the rest of the condition.

Comment thread tests/neg/i26215.scala
inline def x = 10

object O2:
inline val y = O1.x // error: inline value must have a literal constant type
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an improvement in the error message, since transparent inline def x is the required fix in the test code, for either the check or the subsequent error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inlining inline def into inline val trips inlining postcondition assertion under YCheck

2 participants