File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -427,7 +427,8 @@ bool BridgedProperty::matchMethodCall(SILBasicBlock::iterator It) {
427
427
SILValue Instance =
428
428
FirstInst != ObjCMethod ? FirstInst : ObjCMethod->getOperand ();
429
429
if (!ObjCMethod || !ObjCMethod->hasOneUse () ||
430
- ObjCMethod->getOperand () != Instance)
430
+ ObjCMethod->getOperand () != Instance ||
431
+ ObjCMethod->getFunction ()->getLoweredFunctionType ()->isPolymorphic ())
431
432
return false ;
432
433
433
434
// Don't outline in the outlined function.
@@ -568,7 +569,7 @@ bool BridgedProperty::matchInstSequence(SILBasicBlock::iterator It) {
568
569
if (!Load) {
569
570
// Try to match without the load/strong_retain prefix.
570
571
auto *CMI = dyn_cast<ObjCMethodInst>(It);
571
- if (!CMI)
572
+ if (!CMI || CMI-> getFunction ()-> getLoweredFunctionType ()-> isPolymorphic () )
572
573
return false ;
573
574
FirstInst = CMI;
574
575
} else
@@ -1104,7 +1105,8 @@ bool ObjCMethodCall::matchInstSequence(SILBasicBlock::iterator I) {
1104
1105
clearState ();
1105
1106
1106
1107
ObjCMethod = dyn_cast<ObjCMethodInst>(I);
1107
- if (!ObjCMethod)
1108
+ if (!ObjCMethod ||
1109
+ ObjCMethod->getFunction ()->getLoweredFunctionType ()->isPolymorphic ())
1108
1110
return false ;
1109
1111
auto *Use = ObjCMethod->getSingleUse ();
1110
1112
if (!Use)
Original file line number Diff line number Diff line change 1
1
#import < Foundation/Foundation.h>
2
2
3
+ @protocol Proto
4
+ - (id )requirement ;
5
+ @end
6
+
3
7
@interface Gizmo : NSObject
4
8
@property (nonatomic )NSString *stringProperty;
5
9
- (NSString *) modifyString : (NSString *)str withNumber : (NSInteger ) num withFoobar : (id )foobar ;
6
10
- (id ) doSomething : (NSArray <NSString*>*) arr ;
7
11
@end
8
12
13
+ @interface Gizmo2 <ObjectType: id<Proto>> : NSObject
14
+ - (NSString *) doSomething ;
15
+ @end
16
+
9
17
Original file line number Diff line number Diff line change @@ -134,3 +134,9 @@ public func testOutlining() {
134
134
// CHECK: %7 = apply %2(%6, %1) : $@convention(objc_method) (Optional<NSArray>, Gizmo) -> @autoreleased Optional<AnyObject>
135
135
// CHECK: strong_release %4 : $NSArray
136
136
// CHECK: return %7 : $Optional<AnyObject>
137
+
138
+ public func dontCrash< T: Proto > ( x : Gizmo2 < T > ) {
139
+ let s = x. doSomething ( )
140
+ print ( s)
141
+
142
+ }
You can’t perform that action at this time.
0 commit comments