Skip to content

Don't approximate a type using Nothing as prefix #23531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2025

Conversation

smarter
Copy link
Member

@smarter smarter commented Jul 15, 2025

Approximate range(Nothing, hi) to Nothing & hi instead of Nothing. This avoids
creating TypeRefs with a Nothing prefix which manifest themselves down the line
with an error like:

Cannot resolve reference to type path.type.AbsMember.
The classfile defining the type might be missing from the classpath.
     val z1 = transition(di).ext(1) // error
                        ^

Due to a MissingType thrown from TypeErasure#sigName.

This change required tweaking Type#findMember to handle WildcardTypes instead of
returning NoDenotation. This was only required for two
tests (tests/pos/i7414.scala and tests/pos/i13842.scala) where wildApprox ends
up creating a TermRef whose underlying type is a WildcardType, because of a type
parameter being substituted by a wildcard, which seems legitimate when we're using
wildApprox.

The presentation compiler also had a special case for Nothing appearing in
completion which had to be adapted.

Fixes #23530

Approximate range(Nothing, hi) to Nothing & hi instead of Nothing. This avoids
creating TypeRefs with a Nothing prefix which manifest themselves down the line
with an error like:

    Cannot resolve reference to type path.type.AbsMember.
    The classfile defining the type might be missing from the classpath.
         val z1 = transition(di).ext(1) // error
                            ^
Due to a MissingType thrown from TypeErasure#sigName.

This change required tweaking Type#findMember to handle WildcardTypes instead of
returning NoDenotation. This was only required for two
tests (tests/pos/i7414.scala and tests/pos/i13842.scala) where `wildApprox` ends
up creating a TermRef whose underlying type is a WildcardType, because of a type
parameter being substituted by a wildcard, which seems legitimate when we're using
`wildApprox`.

The presentation compiler also had a special case for Nothing appearing in
completion which had to be adapted.

Fixes scala#23530
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed description! LGTM

@odersky odersky merged commit 68a6d5b into scala:main Jul 21, 2025
105 of 109 checks passed
@odersky odersky deleted the i23530 branch July 21, 2025 16:35
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.

Regression in 3.7: "cannot resolve reference to type" when calling dependent method
2 participants