Skip to content

[SR-1158] Sub-subclass doesn't conform to protocol #43766

@swift-ci

Description

@swift-ci
Previous ID SR-1158
Radar None
Original Reporter diegosanchezr (JIRA User)
Type Bug
Status Closed
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, OptimizedOnly
Assignee @jckarter
Priority Medium

md5: 88d26548a43585e6ea0dfa127129503d

Issue Description:

Module 1:

public protocol MyProtocol  {}
public class ClassLevel1: MyProtocol {
    public init() {}
}
public class ClassLevel2: ClassLevel1 {
    public override init () {}
}

Modue 2:

class ClassLevel3: ClassLevel2 {
    override init() {
        super.init()
    }
}

func createClassLevel3() -> MyProtocol {
    let class3 =  ClassLevel3()
    return class3 // <- Compiler error. Says doesn't conform to MyProtocol
}

Workaround:

func createClassLevel3() -> MyProtocol {
    let class3 =  ClassLevel3()
    return class3 as! MyProtocol
}

Only happens with whole-module-optimization. Affected versions: swift-2.2, swift-2.2.1-SNAPSHOT-2016-03-28-a.

Doesn't affect swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfoptimized onlyFlag: An issue whose reproduction requires optimized compilation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions