Skip to content

Fix -Ymagic-offset-header for DoubleDefinition error and implicitNotFound errors, and remove global unmanaged cache#25706

Open
lihaoyi wants to merge 8 commits intoscala:mainfrom
lihaoyi:fix-magic-header
Open

Fix -Ymagic-offset-header for DoubleDefinition error and implicitNotFound errors, and remove global unmanaged cache#25706
lihaoyi wants to merge 8 commits intoscala:mainfrom
lihaoyi:fix-magic-header

Conversation

@lihaoyi
Copy link
Copy Markdown
Contributor

@lihaoyi lihaoyi commented Apr 3, 2026

This makes the reported error properly use remapped file paths and line numbers, where previously it did not. This was encountered trying to use -Ymagic-offset-header to properly refer to Mill's source .mill scripts during error reporting rather than wrapped generated source files.

This PR generalizes the header handling logic previous in Positioned.scala and re-uses it in SourcePosition.scala and Symbol.scala, which also need to render source locations

Also turns the global WrappedSourceFile.cache into a per-context cache, so multiple compilers sharing the same classloader don't stomp over each other's wrapped source file header caches (which happens in Mill since we re-use classloaders for performance)

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

Mostly vibe coded with claude

How was the solution tested?

Added new unit tests

Additional Notes

These are issues encountered trying to use -Ymagic-offset-header in Mill to replace the ad-hoc AST/bytecode/error-message mangling com-lihaoyi/mill#5932

@lihaoyi lihaoyi changed the title Fix -Ymagic-offset-header for DoubleDefinition error Fix -Ymagic-offset-header for DoubleDefinition error and implicitNotFound errors Apr 4, 2026
@lihaoyi lihaoyi changed the title Fix -Ymagic-offset-header for DoubleDefinition error and implicitNotFound errors Fix -Ymagic-offset-header for DoubleDefinition error and implicitNotFound errors, and remove global unmanaged cache Apr 4, 2026
@lihaoyi
Copy link
Copy Markdown
Contributor Author

lihaoyi commented Apr 4, 2026

This is ready to review, the CI failure is due to a broken master from b2b23b6 CC @tanishiking

@tanishiking
Copy link
Copy Markdown
Member

Oops, there was a conflict between two PRs, sent a patch #25710
Thank you for letting me know :)

@Gedochao
Copy link
Copy Markdown
Contributor

Gedochao commented Apr 8, 2026

@lihaoyi Seems there's a conflict now, another rebase necessary

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.

3 participants