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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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
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
1 participant