Skip to content

Commit b38500b

Browse files
committed
[test] Add a test for the tricky circularity in SR-5191. (#11685)
This was fixed by 897effe, which I had originally thought would be a no-functionality-change commit because it just made things lazier. Turns out requirement signature deserialization can result in circularity with sufficiently cross-referential conformances. This isn't exactly a reduced test case because it still depends on subclassing NSObject, which probably means there are hidden dependencies on conforming to standard library protocols. But it's better than nothing. https://bugs.swift.org/browse/SR-5191
1 parent d6a2e30 commit b38500b

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
protocol FooBaseProto {}
2+
3+
protocol FooProto: FooBaseProto {}
4+
5+
protocol BarProto {
6+
associatedtype Foo: FooProto
7+
init(foo: Foo)
8+
}
9+
10+
protocol BazProto {
11+
associatedtype Bar: BarProto
12+
init(bar: Bar)
13+
}
14+
15+
struct BarImpl: BarProto {
16+
init(foo: FooImpl) {}
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift -module-name SwiftCrash -emit-module -o %t/SR5191.swiftmodule %s %S/Inputs/SR5191-other.swift
3+
// RUN: %target-build-swift -module-name SwiftCrash -emit-module -o %t/SR5191_reversed.swiftmodule %S/Inputs/SR5191-other.swift %s
4+
5+
// REQUIRES: objc_interop
6+
// The module name is significant here; it must be later ASCIIbetically than
7+
// "Swift". This has to do with the canonical ordering of protocols, including
8+
// those inherited by extending NSObject.
9+
10+
import Foundation
11+
12+
class FooImpl: NSObject, FooProto, BazProto {
13+
required init(bar: BarImpl) {}
14+
}

0 commit comments

Comments
 (0)