-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy path0093-issue-47048.swift
42 lines (29 loc) · 1015 Bytes
/
0093-issue-47048.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// RUN: %target-swift-frontend -primary-file %s -emit-ir
// https://github.com/apple/swift/issues/47048
protocol P: AnyObject {}
protocol Foo {
// The compiler crash goes away if you remove the P constraint on this associated type
associatedtype ObjectType: P
}
protocol UpcastHelper {
associatedtype Sub: Foo
associatedtype Super: Foo
// ObjectIdentifier(object) == ObjectIdentifier(Self.cast(object))
static func cast(_ object: Sub.ObjectType) -> Super.ObjectType
}
struct AnyFoo<Object: P>: Foo {
typealias ObjectType = Object
class Base {}
final class Derived<Helper: UpcastHelper>: Base where Helper.Super == AnyFoo<Object> {
init(_ foo: Helper.Sub) {
self.foo = foo
}
let foo: Helper.Sub
}
init<Helper: UpcastHelper>
(foo: Helper.Sub, helper: Helper.Type)
where Helper.Super == AnyFoo<Object> {
// This is the expression that causes the crash
_ = Derived<Helper>(foo)
}
}