Skip to content

[SR-8702] Attempt to use associatedtype auto detect using the method of the nested protocol cause compiler error #51215

@swift-ci

Description

@swift-ci
Previous ID SR-8702
Radar None
Original Reporter spiceginger (JIRA User)
Type Bug

Attachment: Download

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

md5: 6cf3588e15ef830d7b036a5692175ff4

Issue Description:

protocol AbstractFactory {
    
    associatedtype ViewController: UIViewController
    
    associatedtype Context


}

protocol Factory: AbstractFactory { 

    func build(with context: Context) -> ViewController

}

struct NavigationFactory: Factory { // This line error: Type 'NavigationFactory' does not conform to protocol 'AbstractFactory'. Compiler forces you to use typealias
    
    func build(with context: Any?) -> UINavigationController {
        return UINavigationController(nibName: nil, bundle: nil)
    }
    
}

Moving `func build(with context: Context) -> ViewController` to the `AbstractFactory` protocol makes everything compile

Metadata

Metadata

Assignees

Labels

associated type inferencebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions