対象コード
public enum Event<E> {
case Next(E)
case Error(ErrorType)
case Completed
}
public class Subject {
var stoppedEvent: Event<Int>? = nil
func on(event: Event<Int>) {
guard stoppedEvent != nil else { return }
switch event {
case .Next(_): break
case .Error(_): stoppedEvent = event
case .Completed: stoppedEvent = event
}
}
}
func test() {
let subject = Subject()
subject.on(Event.Next(1))
subject.on(Event.Completed)
subject.on(Event.Completed)
}
test()
xcrun swiftc -O opt1.swift -o opt1
int _main(int arg0, int arg1) {
rbx = arg1;
*(int32_t *)__TZvOs7Process5_argcVs5Int32 = arg0;
if (*_globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_token5 != 0xffffffffffffffff) {
swift_once(_globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_token5, _globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_func5);
}
*__TZvOs7Process11_unsafeArgvGSpGSpVs4Int8__ = rbx;
if (*__TMLC6result7Subject == 0x0) {
*__TMLC6result7Subject = swift_getInitializedObjCClass(__TMC6result7Subject);
}
rax = swift_initStackObject();
*(rax + 0x10) = 0x0;
*(int8_t *)(rax + 0x18) = 0x0;
*(int8_t *)(rax + 0x19) = 0x1;
return 0x0;
}