fix regression with generic params in static type #24075
Merged
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.
Caught in https://github.com/metagn/applicates, I'm not sure which commit causes this but it's also in the 2.0 branch (but not 2.0.2), so it's not any recent PRs.
If a proc has a static parameter with type
static Foo[T]
, then another parameter with typestatic Bar[T, U]
, the generic instantiation forBar
doesn't matchU
which has typetyGenericParam
, but matchesT
since it has typetyTypeDesc
. The reason is thatconcreteType
returns the type itself fortyTypeDesc
ifc.isNoCall
(i.e. matching a generic invocation), but returnsnil
fortyGenericParam
. I'm guessingtyGenericParam
is received here because of #22618, but that doesn't explain whyT
is stilltyTypeDesc
. I'm not sure.Regardless, we can just copy the behavior for
tyTypeDesc
totyGenericParam
and also return the type itself whenc.isNoCall
. This feels like it defeats the purpose ofconcreteType
but the way it's used doesn't make sense without it (generic param can't match another generic param?). Alternatively we could loosen theif concrete == nil: return isNone
checks in some places for specific conditions, whetherc.isNoCall
orc.inGenericContext == 0
(though this would need #24005).