Skip to content

Commit b9ccde3

Browse files
committed
SILFunctionType: Loosened assert.
Allowed SILFunctionType instances for pseudogeneric coroutines without signatures to be created. Such instances are created by SILTypeSubstituter::substSILFunctionType when SILGen'ing a conformance of a pseudogeneric type to a protocol featuring a coroutine requirement. rdar://81421394
1 parent 44c3d61 commit b9ccde3

File tree

4 files changed

+78
-2
lines changed

4 files changed

+78
-2
lines changed

lib/AST/ASTContext.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4594,8 +4594,9 @@ CanSILFunctionType SILFunctionType::get(
45944594
ProtocolConformanceRef witnessMethodConformance) {
45954595
assert(coroutineKind == SILCoroutineKind::None || normalResults.empty());
45964596
assert(coroutineKind != SILCoroutineKind::None || yields.empty());
4597-
assert(!ext.isPseudogeneric() || genericSig);
4598-
4597+
assert(!ext.isPseudogeneric() || genericSig ||
4598+
coroutineKind != SILCoroutineKind::None);
4599+
45994600
patternSubs = patternSubs.getCanonical();
46004601
invocationSubs = invocationSubs.getCanonical();
46014602

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <Foundation/Foundation.h>
2+
3+
#pragma clang assume_nonnull begin
4+
5+
@interface Ranger<__covariant SectionType, __covariant ItemType> : NSObject {
6+
NSRange _range;
7+
}
8+
@property(nonatomic) NSRange range;
9+
@end
10+
#pragma clang assume_nonnull end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "rdar81421394.h"
2+
3+
#pragma clang assume_nonnull begin
4+
@implementation Ranger
5+
- (instancetype)init {
6+
if (self = [super init]) {
7+
NSLog(@"calling init");
8+
self->_range = NSMakeRange(0, 0);
9+
}
10+
return self;
11+
}
12+
- (void)setRange:(NSRange)newRange {
13+
NSLog(@"%s: %@->%@", __PRETTY_FUNCTION__, NSStringFromRange(_range),
14+
NSStringFromRange(newRange));
15+
_range = newRange;
16+
}
17+
- (NSRange)range {
18+
NSLog(@"%s: %@", __PRETTY_FUNCTION__, NSStringFromRange(_range));
19+
return _range;
20+
}
21+
@end
22+
#pragma clang assume_nonnull end
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-clang %S/Inputs/rdar81421394.m -I %S/Inputs -c -o %t/rdar81421394.o
3+
// RUN: %target-build-swift -Xfrontend -disable-availability-checking -import-objc-header %S/Inputs/rdar81421394.h -Xlinker %t/rdar81421394.o %s -o %t/main
4+
// RUN: %target-codesign %t/main
5+
// RUN: %target-run %t/main | %FileCheck %s
6+
7+
// REQUIRES: executable_test
8+
// REQUIRES: objc_interop
9+
10+
// UNSUPPORTED: use_os_stdlib
11+
// UNSUPPORTED: back_deployment_runtime
12+
13+
protocol RangeFinder {
14+
var range: NSRange { get set }
15+
}
16+
17+
extension Ranger : RangeFinder {}
18+
19+
class Wrapper {
20+
let instance: Ranger<AnyObject, NSObject>
21+
22+
init() {
23+
instance = Ranger()
24+
}
25+
26+
var range: NSRange {
27+
_read {
28+
yield instance.range
29+
}
30+
_modify {
31+
print("staring modify")
32+
yield &instance.range
33+
print("ending modify")
34+
}
35+
}
36+
}
37+
38+
let w = Wrapper()
39+
print("begin:", w.range)
40+
// CHECK: begin: {0, 0}
41+
w.range = NSRange(location: 3, length: 5)
42+
// CHECK: end: {3, 5}
43+
print("end:", w.range)

0 commit comments

Comments
 (0)