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
The compiler sees that this is OK as long as the concrete implementations satisfy the constraints, such as:
structAImpl:A{typealiasBType=BImpltypealiasCType=CImplletb:BImplvarc:CImplfunc bGetter()->BImpl{return b
}mutatingfunc cSetter(_ newC:CImpl){
c = newC
}
subscript(b:BImpl)->CImpl{get{return c
}set{
c = newValue
}}}structBImpl:B{typealiasAType=AImpl}structCImpl:C{typealiasAType=AImpl}
Actual Behavior
The Swift compiler emits the following errors on protocol A:
/Path/To/main.swift:17:20: error: getter requirement '_' cannot add constraint 'Self.BType == Self.CType.AType.BType.AType.BType' on 'Self'
var b: BType { get }
^
/Path/To/main.swift:18:20: error: getter requirement '_' cannot add constraint 'Self.BType == Self.CType.AType.BType.AType.BType' on 'Self'
var c: CType { get set }
^
/Path/To/main.swift:18:24: error: setter requirement '_' cannot add constraint 'Self.BType == Self.CType.AType.BType.AType.BType' on 'Self'
var c: CType { get set }
^
/Path/To/main.swift:18:9: error: _modify accessor requirement '_' cannot add constraint 'Self.BType == Self.CType.AType.BType.AType.BType' on 'Self'
var c: CType { get set }
^
/Path/To/main.swift:20:10: error: instance method requirement 'bGetter()' cannot add constraint 'Self.BType == Self.CType.AType.BType.AType.BType' on 'Self'
func bGetter() -> BType
^
/Path/To/main.swift:21:10: error: instance method requirement 'cSetter' cannot add constraint 'Self.BType == Self.CType.AType.BType.AType.BType' on 'Self'
func cSetter(_ newC: CType)
^
/Path/To/main.swift:23:5: error: subscript requirement 'subscript(_:)' cannot add constraint 'Self.BType == Self.CType.AType.BType.AType.BType' on 'Self'
subscript (b: BType) -> CType { get set }
^
/Path/To/main.swift:23:37: error: getter requirement '_' cannot add constraint 'Self.BType == Self.CType.AType.BType.AType.BType' on 'Self'
subscript (b: BType) -> CType { get set }
^
/Path/To/main.swift:23:41: error: setter requirement '_' cannot add constraint 'Self.BType == Self.CType.AType.BType.AType.BType' on 'Self'
subscript (b: BType) -> CType { get set }
^
/Path/To/main.swift:23:5: error: _modify accessor requirement '_' cannot add constraint 'Self.BType == Self.CType.AType.BType.AType.BType' on 'Self'
subscript (b: BType) -> CType { get set }
^
And crashes with the following report when these protocols are implemented as demonstrated above:
@theblixguy I did just try it in Xcode 11.0.0-Beta.5 and it seems this bug was fixed. Unfortunate, as our codebase is all Swift 5.0.1. Are there plans of releasing a 5.0.2 or similar to fix bugs like this?
Attachment: Download
Environment
macOS 10.14.6 (18G87)
Xcode 10.3 (10G8)
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Additional Detail from JIRA
md5: 2a8daebc5237695929abd3fac8ed5fdd
duplicates:
Issue Description:
When:
Some protocol A has 2 associated types BType and CType, both of which depend on A such that:
Some protocol B has 1 associated type AType which is an A
Some protocol C has 1 associated type AType which is an A
And:
SSCCE
Expected Behavior
The compiler sees that this is OK as long as the concrete implementations satisfy the constraints, such as:
Actual Behavior
The Swift compiler emits the following errors on protocol A:
And crashes with the following report when these protocols are implemented as demonstrated above:
The text was updated successfully, but these errors were encountered: