Skip to content

Fix missing indexing data with overloaded type #65729

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

Conversation

keith
Copy link
Member

@keith keith commented May 6, 2023

When you have a type that's ambiguous because it's defined in 2 imported modules, but you don't have to disambiguate by using the module name, previously no index references were produced. Now most are for the common case, but notably nested type constructors and generics still aren't emitted, partially because of #65726

Fixes: #64598

When you have a type that's ambiguous because it's defined in 2 imported
modules, but you don't have to disambiguate by using the module name,
previously no index references were produced. Now most are for the
common case, but notably nested type constructors and generics still
aren't emitted, partially because of swiftlang#65726

Fixes: swiftlang#64598
@keith
Copy link
Member Author

keith commented May 6, 2023

@swift-ci please test

@keith keith requested a review from AnthonyLatsis as a code owner May 30, 2023 21:25
@keith
Copy link
Member Author

keith commented May 30, 2023

@swift-ci please test

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

I'm not sure it makes sense to add a new TypeRepr for Self, especially since it appears to only be used in preCheckExpr(). TypeReprs are syntactic constructs and Self is not special in any way as far as the syntax is concerned.

Why does indexing look at TypeReprs at all?

@bnbarham
Copy link
Contributor

bnbarham commented Jun 1, 2023

Why does indexing look at TypeReprs at all?

As far as I understand it we index various type references through walkToTypeReprPre. Are you suggesting we should be able to index those some other way? I assume there were reasons those couldn't be handled through eg. other decls/exprs, but honestly I don't actually know. @akyrtzi / @benlangmuir may have more background here.

@keith
Copy link
Member Author

keith commented Jun 1, 2023

@swift-ci please test linux platform

@keith
Copy link
Member Author

keith commented Jun 20, 2023

Friendly bump

@hamishknight
Copy link
Contributor

I'm not sure it makes sense to add a new TypeRepr for Self, especially since it appears to only be used in preCheckExpr(). TypeReprs are syntactic constructs and Self is not special in any way as far as the syntax is concerned.

@slavapestov IMO the existing logic that uses a FixedTypeRepr for this is wrong since, as I understand it, it really should only be used when we need to synthesize a TypeRepr to represent a Type that isn't spelled in the source. Self however is spelled in the source, so should have a proper TypeRepr IMO. We can't re-use something like SimpleIdentTypeRepr, since that is assumed to be resolved via name lookup to a proper Decl, which Self cannot be.

Why does indexing look at TypeReprs at all?

As I understand it, we care not only what Type is being used, but also how it is spelled in source. e.g Self could resolve to a StructType, but for the purposes of indexing, we'd want to consider the reference to the struct decl as implicit, since e.g renaming the decl shouldn't rename the use of Self.

Copy link
Contributor

@hamishknight hamishknight left a comment

Choose a reason for hiding this comment

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

Modulo the two comments I've left, this LGTM! (sorry for the late review)

@xedin xedin self-requested a review June 22, 2023 15:55
@ahoppen ahoppen removed their request for review June 22, 2023 20:09
@keith keith requested a review from hamishknight June 22, 2023 21:00
@keith
Copy link
Member Author

keith commented Jun 22, 2023

@swift-ci please test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

I concur with @hamishknight comments, this looks good to me too!

Copy link
Contributor

@hamishknight hamishknight left a comment

Choose a reason for hiding this comment

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

Thanks!

@keith keith merged commit e9ff334 into swiftlang:main Jun 23, 2023
@keith keith deleted the ks/fix-missing-indexing-data-with-overloaded-type branch June 23, 2023 16:58
DougGregor pushed a commit that referenced this pull request Aug 19, 2023
When you have a type that's ambiguous because it's defined in 2 imported
modules, but you don't have to disambiguate by using the module name,
previously no index references were produced. Now most are for the
common case, but notably nested type constructors and generics still
aren't emitted, partially because of #65726

Fixes: #64598

(cherry picked from commit e9ff334 / #65729)
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.

Index data incomplete when referencing an ambiguous type name
5 participants