Skip to content

Commit 0e8a606

Browse files
Merge pull request #65306 from nate-chandler/rdar81421394
Address asserts raised when conforming pseudogeneric type to protocol with coroutine requirement.
2 parents 02e57d5 + b9ccde3 commit 0e8a606

File tree

6 files changed

+80
-4
lines changed

6 files changed

+80
-4
lines changed

lib/AST/ASTContext.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4598,8 +4598,9 @@ CanSILFunctionType SILFunctionType::get(
45984598
ProtocolConformanceRef witnessMethodConformance) {
45994599
assert(coroutineKind == SILCoroutineKind::None || normalResults.empty());
46004600
assert(coroutineKind != SILCoroutineKind::None || yields.empty());
4601-
assert(!ext.isPseudogeneric() || genericSig);
4602-
4601+
assert(!ext.isPseudogeneric() || genericSig ||
4602+
coroutineKind != SILCoroutineKind::None);
4603+
46034604
patternSubs = patternSubs.getCanonical();
46044605
invocationSubs = invocationSubs.getCanonical();
46054606

lib/Demangling/Remangler.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,8 +1212,7 @@ ManglingError Remangler::mangleDependentMemberType(Node *node, unsigned depth) {
12121212

12131213
ManglingError Remangler::mangleDependentPseudogenericSignature(Node *node,
12141214
unsigned depth) {
1215-
// handled inline
1216-
return MANGLING_ERROR(ManglingError::UnsupportedNodeKind, node);
1215+
return mangleDependentGenericSignature(node, depth + 1);
12171216
}
12181217

12191218
ManglingError Remangler::mangleDestructor(Node *node, unsigned depth) {

test/Demangle/Inputs/manglings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,3 +456,4 @@ $s9MacroUser016testFreestandingA9ExpansionyyF4Foo3L_V23bitwidthNumberedStructsfM
456456
@__swiftmacro_1a13testStringifyAA1bySi_SitF9stringifyfMf_ ---> freestanding macro expansion #1 of stringify in a.testStringify(a: Swift.Int, b: Swift.Int) -> ()
457457
@__swiftmacro_18macro_expand_peers1SV1f20addCompletionHandlerfMp_ ---> peer macro @addCompletionHandler expansion #1 of f in macro_expand_peers.S
458458
@__swiftmacro_9MacroUser16MemberNotCoveredV33_4361AD9339943F52AE6186DD51E04E91Ll0dE0fMf0_ ---> freestanding macro expansion #2 of NotCovered(in _4361AD9339943F52AE6186DD51E04E91) in MacroUser.MemberNotCovered
459+
$sxSo8_NSRangeVRlzCRl_Cr0_llySo12ModelRequestCyxq_GIsPetWAlYl_TC ---> coroutine continuation prototype for @escaping @convention(thin) @convention(witness_method) @yield_once <A, B where A: AnyObject, B: AnyObject> @substituted <A> (@inout A) -> (@yields @inout __C._NSRange) for <__C.ModelRequest<A, B>>
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)