Skip to content

[SR-7250] Cannot conform to protocol in extension constrained to that protocol #49798

@hamishknight

Description

@hamishknight
Previous ID SR-7250
Radar None
Original Reporter @hamishknight
Type Bug
Status Closed
Resolution Done
Environment

Swift version 4.2-dev (LLVM cef3fe6d75, Clang bdc970d89c, Swift 5b60ace)
Target: x86_64-apple-darwin17.4.0

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

md5: f1c1f35674f7cf782c53c23ed4e7f453

Issue Description:

The following doesn't compile:

protocol P {
  var i: Int { get }
}

extension P {
  var i: Int { return 0 }
}

struct S<T> : P {} // error: Type 'S<T>' does not conform to protocol 'P'

extension S where T : P {
  var i: Int { return 0 }
}

However it only doesn't compile while the last extension is constrained to T : P, if we constrain it to some other protocol (or not at all), the code compiles fine:

// This is fine.
protocol P1 {}
extension S where T : P1 {
  var i: Int { return 0 }
}

Metadata

Metadata

Assignees

Labels

bugA 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