Skip to content

[SR-1894] Return type of 'NSCoding.Protocol' is considered ObjC-compatible, but crashes #44503

@belkadan

Description

@belkadan
Previous ID SR-1894
Radar None
Original Reporter @belkadan
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, StarterBug
Assignee gal (JIRA)
Priority Medium

md5: 7c3c3d2da857e9ccac5a0aca9b6a8702

Issue Description:

import Foundation
class Test: NSObject {
  @objc func foo() -> NSCoding.Protocol { return NSCoding.self }
}

Compiling this with Swift 3 (preview 1) leads to a crash in SILGen trying to emit an ObjC thunk for foo. We should probably just not consider this to be Objective-C-compatible; it doesn't buy us much over just returning Protocol (which works fine, though despite the name it's limited to Objective-C protocols).

Banning this means altering the logic in lib/AST/Type.cpp. There's actually an explicit check marked "@objc protocol metatypes"; that entire block can be removed to make the whole function return false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwaregood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions