Skip to content

Using P.self on private @objc protocol with custom ObjC name causing crash. #74546

Open
@WeZZard

Description

@WeZZard

Description

Running the following code on Xcode 15.0 and 16.0 causing a runtime crash. a can be evaluated in LLDB. However, it's 0x0 when evaluated in assembly mode.

@objc(MyName)
private protocol MyObjCProtocol {
    
    func myObjCProtocolMessage()
    
}

private let a = MyObjCProtocol.self
print(a)
Screenshot 2024-06-19 at 18 11 02 Screenshot 2024-06-19 at 18 11 36

Reproduction

@objc(MyName)
private protocol MyObjCProtocol {
    
    func myObjCProtocolMessage()
    
}

private let a = MyObjCProtocol.self
print(a)

Stack dump

Thread 1 Queue : com.apple.main-thread (serial)
#0	0x00000001acad98d0 in outlined init with copy of Any ()
#1	0x00000001ac932d5c in specialized _print<τ_0_0>(_:separator:terminator:to:) ()
#2	0x00000001ac931efc in print(_:separator:terminator:) ()
#3	0x00000001000032dc in main at main.swift:295
#4	0x000000019c73e0e0 in start ()

Expected behavior

Printing "MyObjCProtocol"

Environment

Xcode 15.0
Xcode 16.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @objcFeature → attributes: The @objc attributebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareobjective-c interopFeature: Interoperability with Objective-CprotocolFeature → type declarations: Protocol declarationsruntimeThe Swift Runtimeswift 6.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions