Re: [swift-users] Protocol composition results in EXC_BAD_ACCESS

2017-04-03 Thread Rudolf Adamkovič via swift-users
Because it’s a value and has no identity. R+ > On 3 Apr 2017, at 17:58, Zhao Xin wrote: > > Why not making State as a class? EffectiveState should be subclass of State. > > Zhaoxin > > On Mon, Apr 3, 2017 at 11:08 PM, Rudolf Adamkovič via swift-users > mailto:swift-users@swift.org>> wrote: >

Re: [swift-users] Protocol composition results in EXC_BAD_ACCESS

2017-04-03 Thread Rudolf Adamkovič via swift-users
Thanks! Done: https://bugs.swift.org/browse/SR-4477 R+ > On 3 Apr 2017, at 17:53, Joe Groff wrote: > > >> On Apr 3, 2017, at 7:53 AM, Adrian Zubarev > > wrote: >> >> However I kinda think this is a bug. >> >>

Re: [swift-users] Protocol composition results in EXC_BAD_ACCESS

2017-04-03 Thread Zhao Xin via swift-users
Why not making State as a class? EffectiveState should be subclass of State. Zhaoxin On Mon, Apr 3, 2017 at 11:08 PM, Rudolf Adamkovič via swift-users < swift-users@swift.org> wrote: > On 3 Apr 2017, at 16:48, Adrian Zubarev > wrote: > > Why do you cast against an existential in first place? >

Re: [swift-users] Protocol composition results in EXC_BAD_ACCESS

2017-04-03 Thread Rudolf Adamkovič via swift-users
> On 3 Apr 2017, at 16:48, Adrian Zubarev > wrote: > > Why do you cast against an existential in first place? To avoid force-unwrap at the end here: class Store { var state: State // ... func processScheduledActions() { guard var effectfulState = state as? Effectful els

Re: [swift-users] Protocol composition results in EXC_BAD_ACCESS

2017-04-03 Thread Adrian Zubarev via swift-users
Why do you cast against an existential in first place? This solves the given example: protocol Something {} protocol IntContainer { var ints: [Int] { get set } } func processSomething(_ state: Something) { if let intContainer = state as? IntContainer { print(intContainer.ints)

[swift-users] Protocol composition results in EXC_BAD_ACCESS

2017-04-03 Thread Rudolf Adamkovič via swift-users
I'm getting an `EXC_BAD_ACCESS` here: protocol Something {} protocol IntContainer { var ints: [Int] { get set } } func processSomething(_ state: Something) { if let intContainer = state as? Something & IntContainer { print(intContainer.ints) } } struct MySomething: Something