Skip to content
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-6032] String(describing:) shouldn't include extra stuff if the class is private #48589

Closed
swift-ci opened this issue Sep 29, 2017 · 5 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. good first issue Good for newcomers runtime The Swift Runtime standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6032
Radar None
Original Reporter soffes (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 4.0 (swiftlang-900.0.65 clang-900.0.37)

Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, Runtime, StarterBug
Assignee @JGiola
Priority Medium

md5: 523b9f57ba12dd9b37135eb1c712aac2

relates to:

  • SR-6787 Unexpected result when getting a String describing a type created inside a function

Issue Description:

`String(describing)` adds "extra stuff" to the end of a class name to disambiguate it from other classes that could be named the same. This shouldn't be the case for `String(describing)` since it includes the module name.

private class Foo {}
class Bar {}

String(describing: Foo.self) // "(Foo in _0968BA4B0D33033CA00782436B519CF1)"
String(describing: Bar.self) // "Bar"

Discussion from Twitter:

https://twitter.com/soffes/status/913875836498976769
https://twitter.com/UINT_MIN/status/913877830823403522
https://twitter.com/UINT_MIN/status/913877917339283456
https://twitter.com/UINT_MIN/status/913877917339283456

@belkadan
Copy link
Contributor

After tracing through several calls, the place that would need to change for this is _buildNameForMetadata in the runtime's Casting.cpp. This function sets up a DemangleOptions struct, as defined in Demangling.h. Setting ShowPrivateDiscriminators to false when the qualified parameter is false should accomplish this. (Then you'll need to run the Swift tests and update anything that's changed. If there's not already a test case that covers this, you can add one to test/stdlib/. Look for an example using the StdlibUnittest library.)

@belkadan
Copy link
Contributor

(instructions for someone treating this as a starter bug)

@JGiola
Copy link
Contributor

JGiola commented Oct 2, 2017

Can I take this?

@belkadan
Copy link
Contributor

belkadan commented Oct 2, 2017

Go for it! (And assign it to yourself so someone else doesn't.)

@JGiola
Copy link
Contributor

JGiola commented Oct 5, 2017

I've opened the pull request, but I'm not sure if the test is done in the right way.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. good first issue Good for newcomers runtime The Swift Runtime standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants