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
macOS Sierra 10.12.5 (16F73), Xcode 9.0 beta 2 (9M137d)
Additional Detail from JIRA
Votes
0
Component/s
Compiler
Labels
Bug
Assignee
None
Priority
Medium
md5: 503457675ee4c46224ec7dac3e0dc725
duplicates:
SR-55 non-@objc protocol existentials do not conform to their own protocol type
Issue Description:
Given a generic type X<Y> where Y is constrained to some type Z and a protocol A that constrains Self to Z, a variable or constant declaration of X<A> should be considered valid. Currently, as of Xcode 9 beta 2, the compiler gives a warning similar to "'X' requires that 'A' inherit from 'Z'" even though that is already true.
// Imagine these sheet classes and the bed struct in a separate module somewhereclassSheet {
funcpullOver() {
print("sleep time")
}
}
classComfySheet : Sheet {
publicstaticletveryComfy: ComfySheet = {
returnComfySheet()
}()
funccomfort() {
print("comfortable")
}
}
classBouncySheet : Sheet {
publicstaticletveryBouncy: BouncySheet = {
returnBouncySheet()
}()
funcbounce() {
print("bounce")
}
}
classAwfulSheet : Sheet {
overridefuncpullOver() {
print("ew")
}
}
structBed<SheetType> whereSheetType : Sheet {
publicletsize: Doublepublicletsheets: SheetType
}
// This protocol and the corresponding extensions are editableprotocolEnjoymentMeasurablewhereSelf : Sheet {
funcenjoy()
}
extensionComfySheet : EnjoymentMeasurable {
funcenjoy() {
print("8/10")
}
}
extensionBouncySheet : EnjoymentMeasurable {
funcenjoy() {
print("11/10")
}
}
funcdoSomething() {
letbed: Bed<EnjoymentMeasurable> // error here: "'Bed' requires that 'EnjoymentMeasurable' inherit from 'Sheet'"bed = Bed(size: 4.0, sheets: ComfySheet.veryComfy)
bed.sheets.enjoy()
}
The text was updated successfully, but these errors were encountered:
This is arguably correct because EnjoymentMeasurable could have static requirements, and then Bed wouldn't be able to call those methods because the protocol type doesn't implement them. But it is a little frustrating when the protocol does not have static requirements.
Environment
macOS Sierra 10.12.5 (16F73), Xcode 9.0 beta 2 (9M137d)
Additional Detail from JIRA
md5: 503457675ee4c46224ec7dac3e0dc725
duplicates:
Issue Description:
Given a generic type X<Y> where Y is constrained to some type Z and a protocol A that constrains Self to Z, a variable or constant declaration of X<A> should be considered valid. Currently, as of Xcode 9 beta 2, the compiler gives a warning similar to "'X' requires that 'A' inherit from 'Z'" even though that is already true.
The text was updated successfully, but these errors were encountered: