File: witnesses_canonical.swift

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (58 lines) | stat: -rw-r--r-- 1,371 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
// RUN: %target-swift-emit-silgen %s | %FileCheck %s

// rdar://problem/20714534 -- we need to canonicalize an associated type's
// protocols when emitting witness method table for a conformance.

protocol _ST {}

protocol ST : _ST {}

protocol _CDT : ST {}

struct _S<T : _CDT> : CT {
  internal init(a: T, b: Int) {}
}

extension _CDT {
  subscript(b: Int) -> _S<Self> {
    return _S(a: self, b: b)
  }
}

protocol CT : ST, _CDT {
  associatedtype _SS : ST, _CDT

  subscript(_bounds: Int) -> _SS { get }
}

// CHECK: sil_witness_table hidden <T where T : _CDT> _S<T>: CT module witnesses_canonical {
// associated_conformance (_SS: _CDT): _S<_S<T>>: specialize <T = _S<T>> (<T where T : _CDT> _S<T>: _CDT module witnesses_canonical)

// rdar://problem/21599502 -- make sure we get requirements on
// associated types from protocols we inherit.
protocol P1 { }
protocol P2 { }

protocol Q1 {
  associatedtype Assoc : P1
}

protocol Q2 {
  associatedtype Assoc : P2
}

protocol Q3 : Q1, Q2 {
  associatedtype Assoc
}

struct XP : P1, P2 { }

struct XQ3 : Q3 {
  typealias Assoc = XP
}

// CHECK: sil_witness_table hidden XQ3: Q3 module witnesses_canonical {
// CHECK:  associated_conformance (Assoc: P1): XP: P1 module witnesses_canonical
// CHECK:  associated_conformance (Assoc: P2): XP: P2 module witnesses_canonical
// CHECK:  associated_type Assoc: XP
// CHECK: }