Repository navigation
Fixes #25801: Handle TypeDefs in ensureHasSym - #26011
Merged
Merged
Conversation
When a class has a self-type that refines a member, the symbol of a TypeDef in its body can resolve through the self-type prefix to a different symbol than the one being defined. This caused two problems: - During TASTy unpickling, `tree.ensureHasSym(sym)` for a TypeDef tried to call `sym.asTerm.name`, which crashes with "asTerm called on not-a-Term" when sym is a type symbol. - During typer, the TypeDef tree's symbol was never reconciled with the intended sym, so `-Ycheck:all` would report the trait body as missing the type member. Use `sym.name` in `ensureHasSym` so the produced `NamedType` correctly selects between `TypeRef` and `TermRef` based on the name kind, and call `ensureHasSym` from `typedTypeDef` so the typed tree carries the right symbol before pickling. https://claude.ai/code/session_01Gu4rX4Ywk7zkf8yPqvvwNG
soronpo
marked this pull request as ready for review
May 8, 2026 18:38
odersky
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a class has a self-type that refines a member, the symbol of a TypeDef in its body can resolve through the self-type prefix to a different symbol than the one being defined. This caused two problems:
tree.ensureHasSym(sym)for a TypeDef tried to callsym.asTerm.name, which crashes with "asTerm called on not-a-Term" when sym is a type symbol.-Ycheck:allwould report the trait body as missing the type member.Use
sym.nameinensureHasSymso the producedNamedTypecorrectly selects betweenTypeRefandTermRefbased on the name kind, and callensureHasSymfromtypedTypeDefso the typed tree carries the right symbol before pickling.Fixes #25801
How much have you relied on LLM-based tools in this contribution?
Extensively, but it's a small fix.
How was the solution tested?
New automated tests (including the issue's reproducer, if applicable)