-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselffeatureA feature request or implementationA feature request or implementation
Description
Previous ID | SR-453 |
Radar | None |
Original Reporter | flashspys (JIRA User) |
Type | Bug |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, LanguageFeatureRequest |
Assignee | None |
Priority | Medium |
md5: 973efe727beed10b6f2ae35767f6d7b6
Issue Description:
I don't like the way how Swift handles structs which implements protocols:
Simple demonstration:
protocol Prot {}
struct A : Prot {}
let arr = [A(), A()] // 1: ok
let arr2 = [A(), A()] as [Prot] // 2: ok
let arr3 = arr as [Prot] // 3: compile error
let arr4 = arr2 as! [A] // 4: runtime error
It was discussed here. I think it's mandatory to support casting here and should not be a language limitation. I really like structs in swift but it is very hard to implement sth. like a hierarchy of structs cause they can't inherit from each other and it's hard to work with protocols as you see above.
Does anyone feels similar ?
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselffeatureA feature request or implementationA feature request or implementation