mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
In the statement
optional1?.objc_setter = optional2?.objc_getter?.objc_getter
we can eliminate all optional switches expect for the first switch on
optional1. We must only execute the setter if optional1 has some value.
We can simplify the following switch_enum with a branch as long all
sideffecting instructions in someBB are objc_method calls on the
optional payload or on another objc_method call that transitively uses
the payload.
switch_enum %optionalValue, case #Optional.some!enumelt.1: someBB,
case #Optional.none: noneBB
someBB(%optionalPayload):
%1 = objc_method %optionalPayload
%2 = apply %1(..., %optionalPayload) // self position
br mergeBB(%2)
noneBB:
%4 = enum #Optional.none
br mergeBB(%4)
rdar://48007302
6 lines
93 B
Objective-C
6 lines
93 B
Objective-C
@import Foundation;
|
|
|
|
@interface Test : NSObject
|
|
@property (nullable) Test *otherTest;
|
|
@end
|