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
[SR-10472] Feature request: show generic type variables in Xcode's variables pane #4438
Comments
Interesting idea. jingham@apple.com (JIRA User), @dcci, @adrian-prantl, what do you think? |
Comment by Jim Ingham (JIRA) The thing you want to see is the full resolved type of T & U, right? We have the info to show this. I'm not so sure about how to present the results. I don't think you want to show T & U as held onto by some implicit function parameter, etc. That's too much inside baseball... It seems like we should just show T -> some type, and U -> some type. But that would mean the results don't fit naturally in frame variable, which presents values not types. But we could certainly add something to "frame info" and an SB API to return a map of Generic Names -> Types which Xcode could present however it wants to. |
Because of how the debug information is encoded, the generic type parameters are actually part of the current frame. They are just hidden by default because they are not particularly pretty to look at. |
To clarify: I don't recommend that users should turn on this setting. I think it would be reasonable to expect, for example, the type substitutions to appear in the back trace. I would also be okay with showing the type parameters in frame variable by default, if we can make sure they are actually printed as an abstract `T=Swift.Int32` hiding all the type metadata implementation details. |
Comment by Jim Ingham (JIRA) We got a request to print type substitutions in backtraces previously. I was worried that doing that would make the already noisy swift backtraces even noisier, particularly it you substitute them inline, e.g. just T->[Int, MyClass] everywhere... |
@adrian-prantl Oh, neat! It works, this caused
Output: ![](Screen Shot 2019-04-16 at 2.57.09 PM.png) Ideally type variables would show up as an [A] auto variable, like [A] |
I don't even think that the pointer value is of any relevance to anyone but compiler developers, so it might as well be `T = Tests.Human` is that fair? |
I can see myself needing it when working with the runtime directly, at least until Swift gets full-fledged reflection on par with Objc. In fact I'll definitely need it for that. Compromise: if I can see it's address by expanding/unfolding it, that works too! |
Attachment: Download
Additional Detail from JIRA
md5: 3969b4dc93d426faa2ed68c5f5bb82eb
Issue Description:
Consider the following code:
The variables pane will only show you a variable for
bar
(andself
if this is a method). It would be so useful ifT
andU
showed up as variables here too, relieving the developer from having to typepo T.self
(which often doesn't work) or from assigning a temporary variable toT.self
. Generic type variables are implicit function parameters, after all.I'm not sure how this could be incorporated into Playgrounds, but it would be nice to have something similar for Playgrounds as well.
The text was updated successfully, but these errors were encountered: