You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public protocol P1 {
subscript<T2> () -> T2 { get }
}
struct Impl : P1 {
subscript() -> Int {
return 42
}
}
we currently reject it incorrectly like this:
t.swift:49:8: error: type 'Impl' does not conform to protocol 'P1'
struct Impl : P1 {
^
t.swift:50:3: note: candidate has non-matching type '() -> Int'
subscript() -> Int {
^
t.swift:46:3: note: protocol requires subscript with type '<T2> () -> T2'; do you want to add a stub?
subscript<T2> () -> T2 { get }
^
The text was updated successfully, but these errors were encountered:
The example as written is ill-formed, because Impl’s subscript needs to be generic as well. If generic subscripts are actually broken in protocols, I’d expect the bug to be shallow.
Additional Detail from JIRA
md5: edcc85d2bd744a54b39f3b6c82f8aef2
Issue Description:
I'd really like for this to be possible:
public protocol P1 {
subscript<T2> () -> T2 { get }
}
struct Impl : P1 {
subscript() -> Int {
return 42
}
}
we currently reject it incorrectly like this:
t.swift:49:8: error: type 'Impl' does not conform to protocol 'P1'
struct Impl : P1 {
^
t.swift:50:3: note: candidate has non-matching type '() -> Int'
subscript() -> Int {
^
t.swift:46:3: note: protocol requires subscript with type '<T2> () -> T2'; do you want to add a stub?
subscript<T2> () -> T2 { get }
^
The text was updated successfully, but these errors were encountered: