Skip to content

Add hasLocationInfo for Types #12131

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 4 commits into from
Feb 13, 2023
Merged

Conversation

owen-mc
Copy link
Contributor

@owen-mc owen-mc commented Feb 8, 2023

It returns a dummy location except for named types with a type declaration in the source.

@owen-mc owen-mc requested a review from a team as a code owner February 8, 2023 15:07
@github-actions github-actions bot added the Go label Feb 8, 2023
@owen-mc owen-mc added the no-change-note-required This PR does not need a change note label Feb 8, 2023
mbg
mbg previously approved these changes Feb 8, 2023
@mbg
Copy link
Member

mbg commented Feb 8, 2023

The changes look fine, but it looks like they have made some of the tests fail and they might need updating as well.

dt.getType() = this and
// Note that if the type declaration isn't in the source that we have
// then we use a dummy location.
dt.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to explicitly return the dummy location when there isn't such a DeclaredType

It returns a dummy location except for named types with a type
declaration in the source.
Note that
go/ql/test/library-tests/semmle/go/Types/QualifiedNames.expected and
go/ql/test/library-tests/semmle/go/Types/Types.expected gain two lines.
In both cases this is because GenericArray and GenericSignature are
each instantiated twice, so they appear with two different locations.
@owen-mc owen-mc force-pushed the go/named-type-location branch from 03704a8 to 685b8b4 Compare February 10, 2023 22:10
@owen-mc
Copy link
Contributor Author

owen-mc commented Feb 10, 2023

The original version was giving multiple locations for some types because it was giving the locations of type aliases as well. The refactoring seems to fix that, which is good as we don't want to get duplicate results.

@smowton
Copy link
Contributor

smowton commented Feb 11, 2023

DCA it; otherwise lgtm

@owen-mc
Copy link
Contributor Author

owen-mc commented Feb 13, 2023

@smowton The first DCA failed for unknown reasons, but the second seems absolutely uneventful, as I'd expect.

@smowton smowton merged commit 0537579 into github:main Feb 13, 2023
@owen-mc owen-mc deleted the go/named-type-location branch February 13, 2023 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Go no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants