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
Swift: Correct the behaviour of Type.getName #13829
base: main
Are you sure you want to change the base?
Conversation
…(regex solution).
… suitble substitute for the old Type.getName behaviour).
As queries aren't supposed to depend on the behavior of
(from CONTRIBUTING.) |
|
Yep, so it comes down to whether query output looks better with the full or short type names. There are surprisingly few failing tests (no query tests, just a few integration tests), with differences like these: I think the full names were clearer in these cases, so I'll switch |
|
This also adds a fair number of new string operations to many pipelines so I think we should run DCA once we're happy with the output. |
|
DCA LGTM (analysis time unaffected; stage timings OK as far as I can tell). There are some test failures I need to fix though... |
|
Test failures fixed - but I had to rewrite In a couple of places we were using I will do another DCA run after the tests pass, as the solution has fundamentally changed. |
|
DCA still LGTM. It's slightly less clear than last time (analysis time has gone up but not by enough I'm sure it's a real effect) so I'll do a couple of local tests tomorrow to confirm. |
|
Tested: I'll see if I can make this better... |
|
Note that all this regex stuff may break in the future since we're fundamentally trying to parse the output of a function that's used for diagnostics only: https://github.com/apple/swift/blob/c2fc7ee9e72e9a39854548e3202c667e4934dc65/include/swift/AST/Types.h#L1429. Are we sure this is the direction we want to go in? |
|
We use type names to match things like MAD models against things in the database - I think it's safe to say that if the underlying strings change, we will have to fix it somewhere. |
Yeah, but I'm wondering if the proper fix may be to change the extractor not not output this diagnostics name in the first place. |
If there's a formal short name available, yes that would be fantastic! (and I believe we already do that for decls and perhaps other things) |
Correct the behaviour of
Type.getName. For a typeBdeclared inside a typeA,Type.getFullNamereturns the string"A.B".Type.getNameshould return the string"B", but prior to this pull request returned"A.B".Behaviour is now consistent with that for
TypeDecl.An open question is whether we want to redefine
Type.toStringto preserve the old behaviour. I think we do ... but I'm going to let the tests run on this pull request first and see what it looks like if we don't...