Skip to content

[SR-8482] protocol with init adopted by a NSObject will crash subclass #51003

Open
@swift-ci

Description

@swift-ci
Previous ID SR-8482
Radar rdar://problem/43888894
Original Reporter SolaWing (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, RunTimeCrash
Assignee None
Priority Medium

md5: 0cc820e84ab809309573584c993f6595

Issue Description:

import Foundation
public protocol Hello {
 init()
}
extension NSObject: Hello{}
class World: NSObject {
 init(arg: Int=0) {
 super.init()
 }
}
World() // Fatal error: Use of unimplemented initializer 'init()' for class 'main.World'

main.swift: 7: 7: Fatal error: Use of unimplemented initializer 'init()' for class 'main.World'
2018-08-07 21:35:12.009333+0800 main[88892:1650048] main.swift: 7: 7: Fatal error: Use of unimplemented initializer 'init()' for class 'main.World'
Process 88892 stopped

  • thread Redundant Load Elimination Patches #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x0000000100001a5d main`World.init() at main.swift:7
    4 init()
    5 }
    6 extension NSObject: Hello{}
    -> 7 class World: NSObject {
    8 init(arg: Int=0)
    Unknown macro: { 9 super.init() 10 }
    Target 0: (main) stopped.
    (lldb) bt

Expected behavior:

compiler should report error. like adopt by a swift class

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 softwarerun-time crashBug → crash: Swift code crashed during execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions