Skip to content

[SR-2235] Redeclared associatedtype inference not working #44842

Open
@swift-ci

Description

@swift-ci
Previous ID SR-2235
Radar None
Original Reporter ndis1 (JIRA User)
Type Bug
Environment

swift 2.2, swift 3 with xcode 8.0 beta 3 8S174q

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 739eee6d1c31d6ff47387fe89b0a87a5

Issue Description:

When a child protocol redeclares an associatedtype from its parent and adds a new constraint, type inference for that associatedtype breaks. This code reproduces the bug in a playground on swift 2.2 and the swift 3 that ships with xcode 8.0 beta 3 8S174q.

protocol Parent {
    associatedtype T: UIView
    func f() -> T
}

protocol Child: Parent {
    associatedtype T: UITableViewCell
}

struct S: Child {
    //typealias T = UITableViewCell//required - inference not working - without this typealias, the compiler shows an error 'Parent' requires that 'T' (aka <<error type>>)inherit from UIView
    func f() -> UITableViewCell {
        return UITableViewCell()
    }
}

Metadata

Metadata

Assignees

Labels

associated type inferencebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconformancesFeature → protocol: protocol conformancesswift 6.0type checkerArea → compiler: Semantic analysisunexpected errorBug: Unexpected error

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions