Skip to content

Protocol with typed throwing getter cannot be witnessed #80288

@stephencelis

Description

@stephencelis

Description

It does not appear to be possible to fulfill a typed throwing getter requirement in a protocol.

Reproduction

// Does not work
protocol Fooable {
  associatedtype Failure: Error = Never
  var prop: Int { get throws(Failure) }
}
extension Int: Fooable {
  var prop: Int {
    get throws(Never) {
      fatalError()
    }
  }
}

// Works
protocol Barable {
  associatedtype Failure: Error = Never
  func f() throws(Failure) -> Int
}
extension Int: Barable {
  func f() throws(Never) -> Int {
    self
  }
}

Expected behavior

I expect all of the above code to compile.

Environment

swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.5 clang-1700.0.13.3)
Target: arm64-apple-macosx15.0

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions