File: rdar62903491.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (87 lines) | stat: -rw-r--r-- 3,489 bytes parent folder | download
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// RUN: %target-typecheck-verify-swift
// RUN: %target-swift-frontend -typecheck -debug-generic-signatures %s 2>&1 | %FileCheck %s

protocol P {
  associatedtype X : P
}

// Anything that mentions 'T : P' and 'U : P' minimizes to 'U : P'.

func oneProtocol1<T, U>(_: T, _: U) where T : P, U : P, T.X == U, U.X == T {}
// CHECK-LABEL: oneProtocol1
// CHECK: Generic signature: <T, U where T : P, T == U.[P]X, U == T.[P]X>

func oneProtocol2<T, U>(_: T, _: U) where U : P, T : P, T.X == U, U.X == T {}
// CHECK-LABEL: oneProtocol2
// CHECK: Generic signature: <T, U where T : P, T == U.[P]X, U == T.[P]X>

func oneProtocol3<T, U>(_: T, _: U) where T : P, T.X == U, U : P, U.X == T {}
// CHECK-LABEL: oneProtocol3
// CHECK: Generic signature: <T, U where T : P, T == U.[P]X, U == T.[P]X>

func oneProtocol4<T, U>(_: T, _: U) where U : P, T.X == U, T : P, U.X == T {}
// CHECK-LABEL: oneProtocol4
// CHECK: Generic signature: <T, U where T : P, T == U.[P]X, U == T.[P]X>

// Anything that only mentions 'T : P' minimizes to 'T : P'.

func oneProtocol5<T, U>(_: T, _: U) where T : P, T.X == U, U.X == T {}
// CHECK-LABEL: oneProtocol5
// CHECK: Generic signature: <T, U where T : P, T == U.[P]X, U == T.[P]X>

func oneProtocol6<T, U>(_: T, _: U) where T.X == U, U.X == T, T : P {}
// CHECK-LABEL: oneProtocol6
// CHECK: Generic signature: <T, U where T : P, T == U.[P]X, U == T.[P]X>

// Anything that only mentions 'U : P' minimizes to 'U : P'.

func oneProtocol7<T, U>(_: T, _: U) where U : P, T.X == U, U.X == T {}
// CHECK-LABEL: oneProtocol7
// CHECK: Generic signature: <T, U where T == U.[P]X, U : P, U == T.[P]X>

func oneProtocol8<T, U>(_: T, _: U) where T.X == U, U.X == T, U : P {}
// CHECK-LABEL: oneProtocol8
// CHECK: Generic signature: <T, U where T == U.[P]X, U : P, U == T.[P]X>

protocol P1 {
  associatedtype X : P2
}

protocol P2 {
  associatedtype Y : P1
}

func twoProtocols1<T, U>(_: T, _: U) where T : P1, U : P2, T.X == U, U.Y == T {}
// CHECK-LABEL: twoProtocols1
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>

func twoProtocols2<T, U>(_: T, _: U) where U : P2, T : P1, T.X == U, U.Y == T {}
// CHECK-LABEL: twoProtocols2
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>

func twoProtocols3<T, U>(_: T, _: U) where T : P1, T.X == U, U : P2, U.Y == T {}
// CHECK-LABEL: twoProtocols3
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>

func twoProtocols4<T, U>(_: T, _: U) where U : P2, T.X == U, T : P1, U.Y == T {}
// CHECK-LABEL: twoProtocols4
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>

func twoProtocols5<T, U>(_: T, _: U) where T : P1, T.X == U, U.Y == T, U : P2 {}
// CHECK-LABEL: twoProtocols5
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>

// The GenericSignatureBuilder minimized this signature down to
// <T, U where T == U.[P2]Y, U : P2, U == T.[P1]X>.
//
// The Requirement Machine instead emits
// <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>.
//
// This is a hypothetical ABI break, but it is such a silly edge case that
// it shouldn't matter in practice. Given that either of the two conformance
// requirements here are redundant, the user can omit one or the other to
// specify the result that they desire.

func twoProtocols6<T, U>(_: T, _: U) where U : P2, T.X == U, U.Y == T, T : P1 {}
// CHECK-LABEL: twoProtocols6
// CHECK: Generic signature: <T, U where T : P1, T == U.[P2]Y, U == T.[P1]X>