Skip to content

Commit f240b95

Browse files
authored
Merge pull request swiftlang#36407 from slavapestov/tjw-regression-from-sr11153
Add regression tests for fixed crashers
2 parents a3ad4c6 + 2930734 commit f240b95

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
protocol Snapshotting {
2+
associatedtype NativeType: NativeInserting where NativeType.SnapshotType == Self
3+
associatedtype ChangeType: SnapshotChange where ChangeType.SnapshotType == Self
4+
}
5+
6+
protocol NativeInserting {
7+
associatedtype SnapshotType : Snapshotting where SnapshotType.NativeType == Self
8+
}
9+
10+
protocol SnapshotProperties : OptionSet where RawValue == Int {
11+
static var all: Self { get }
12+
}
13+
14+
protocol SnapshotChange {
15+
associatedtype SnapshotType : Snapshotting where SnapshotType.ChangeType == Self
16+
associatedtype PropertiesType : SnapshotProperties
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-ir -primary-file %S/Inputs/sr11153_2_other.swift -primary-file %s
2+
// RUN: %target-swift-frontend -emit-ir %S/Inputs/sr11153_2_other.swift %s
3+
4+
class WatchRegistry {
5+
func single<S: Snapshotting>(objectType: S.Type) throws -> Watch<S>
6+
{
7+
return try Watch<S>.singleObject(objectType: S.self, properties: S.ChangeType.PropertiesType.all)
8+
}
9+
}
10+
11+
class Watch<SnapshotType : Snapshotting> {
12+
static func singleObject(objectType: SnapshotType.Type, properties: SnapshotType.ChangeType.PropertiesType) throws -> Watch<SnapshotType> {
13+
fatalError()
14+
}
15+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: %target-swift-frontend -emit-ir %s
2+
3+
public protocol SomeProto {
4+
associatedtype ThingType
5+
func getThing() -> ThingType
6+
}
7+
8+
public protocol SpecialThing: RandomAccessCollection {
9+
}
10+
11+
public protocol Castable {
12+
associatedtype Source
13+
static func cast(from: Source) -> Self
14+
}
15+
16+
public struct ThingGetter<P: SomeProto, T> {
17+
public let thing: P
18+
}
19+
20+
extension ThingGetter where P.ThingType: SpecialThing, T: Castable, P.ThingType.Iterator.Element == T.Source {
21+
22+
public func getView() -> ThingView {
23+
return ThingView(thing: thing.getThing())
24+
}
25+
26+
public struct ThingView: SpecialThing {
27+
let thing: P.ThingType
28+
29+
public typealias Index = P.ThingType.Index
30+
public var startIndex: Index { return thing.startIndex }
31+
public var endIndex: Index { return thing.startIndex }
32+
public var count: Int { return thing.count }
33+
public func index(after i: Index) -> Index {
34+
return thing.index(after: i)
35+
}
36+
public func index(before i: Index) -> Index {
37+
return thing.index(before: i)
38+
}
39+
public subscript(i: Index) -> T {
40+
return T.cast(from: thing[i])
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)