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-8120] Bridging an Objective-C protocol named "Optional" breaks the 'po' LLDB command when execution is paused inside a closure. #4492

Closed
swift-ci opened this issue Jun 27, 2018 · 6 comments
Labels
bug Something isn't working LLDB for Swift

Comments

@swift-ci
Copy link

Previous ID SR-8120
Radar rdar://problem/41525749
Original Reporter TylerTheCompiler (JIRA User)
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

Xcode 9.4.1 (9F2000)

SWIFT_VERSION = 4.0 (but says 4.1 when "Show Values" is turned on in Xcode's build settings)

macOS 10.13.5 (17F77)

Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug
Assignee None
Priority Medium

md5: 85b3af80dbca20a2aaf07fd74bcdab75

Issue Description:

If you have, say, an Objective-C protocol like this:

@protocol Optional
@end

and it is bridged into a Swift-based project using a bridging header, if you try to po something (say, self) in the debugger while code execution is paused inside a closure, you will receive something like this lovely error:

error: <EXPR>:1:11: error: 'Optional' is ambiguous for type lookup in this context
extension Optional where Wrapped: $__lldb_context {                            
          ^~~~~~~~

Swift.Optional:1:13: note: found this candidate
public enum Optional<Wrapped> : ExpressibleByNilLiteral {
            ^

__ObjC.Optional:1:17: note: found this candidate
public protocol Optional {
                ^

error: <EXPR>:18:5: error: value of type 'Optional<ViewController>' has no member '$__lldb_wrapped_expr_2'
    $__lldb_injected_self.$__lldb_wrapped_expr_2(     
    ^~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~

Note that using NS_SWIFT_NAME to rename the Objective-C protocol does not solve the problem, as it just creates a typealias that also seems to confuse LLDB, as you can see in this error (I used NS_SWIFT_NAME(SomeOtherOptional) to try to rename the protocol):

error: <EXPR>:1:11: error: 'Optional' is ambiguous for type lookup in this context
extension Optional where Wrapped: $__lldb_context {                            
          ^~~~~~~~

Swift.Optional:1:13: note: found this candidate
public enum Optional<Wrapped> : ExpressibleByNilLiteral {
            ^

__ObjC.Optional:2:18: note: found this candidate
public typealias Optional = SomeOtherOptional
                 ^

error: <EXPR>:18:5: error: value of type 'Optional<ViewController>' has no member '$__lldb_wrapped_expr_3'
    $__lldb_injected_self.$__lldb_wrapped_expr_3(     
    ^~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~

I've attached a bare-bones sample project that reproduces the issue using Xcode 9.4.1, using Swift 4.1 (although the build settings in Xcode show a value of 4.0 for SWIFT_VERSION... not sure what's going on there).

For context, I found this out when trying to use Optimizely's iOS SDK, which declares an Objective-C protocol named "Optional" as you can see here. This is making using the debugger an awful experience because we usually can't po something when stopped at a breakpoint inside a closure, and there's not much we can do about it.

@belkadan
Copy link

LLDB, I guess the safest thing to do here would always be to write "Swift.Optional"?

@swift-ci create

@belkadan
Copy link

Ah, that was a comment to the LLDB developers, not to you!

@swift-ci
Copy link
Author

swift-ci commented Jul 6, 2018

Comment by Jim Ingham (JIRA)

Jordan's suggestion seems reasonable. I'll give that a try.

@swift-ci
Copy link
Author

swift-ci commented Jul 7, 2018

Comment by Jim Ingham (JIRA)

Should be resolved by apple/swift-lldb#750

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Jul 23, 2019

TylerTheCompiler (JIRA User), Could you verify if the problem is fixed and if so move the JIRA to "Closed"?

Thanks!
Anna

@swift-ci
Copy link
Author

Comment by Tyler Prevost (JIRA)

Hi @AnnaZaks![]( Yep, I can't seem to reproduce this in Xcode 10.3 using any version of Swift, so I'll close this) Thanks!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 7, 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 Something isn't working LLDB for Swift
Projects
None yet
Development

No branches or pull requests

2 participants