File: rdar79564324.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 (55 lines) | stat: -rw-r--r-- 2,456 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
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module %S/Inputs/rdar79564324_other.swift -emit-module-path %t/rdar79564324_other.swiftmodule -dump-requirement-machine 2>&1 | %FileCheck %s
// RUN: %target-swift-frontend -emit-silgen %s -I %t

import rdar79564324_other

public func test<T : P>(_ t: T) where T == T.A {
  foo(from: t, to: t)
}

// foo(from:to:) has minimal signature <T, U where T == T.A, U : P, T.A == U.A>.
//
// The GSB had trouble re-building after deserialization because of the two
// requirements 'T == T.A' and 'T.A == U.A'.
//
// What should happen is that these two imply that 'T == U.A', and 'U : P'
// implies the existence of 'U.A' and thus the conformance of T to P.
//
// Instead what happens is that 'T == T.A' and 'T.A == U.A' both get delayed
// because T does not yet have a nested type A, so it gets stuck.
//
// The rewrite system handles this correctly though:

// CHECK-LABEL: Requirement machine for fresh signature < T U >
// CHECK-NEXT: Rewrite system: {
// CHECK-NEXT: - [P].[P] => [P] [permanent]
// CHECK-NEXT: - [P].A => [P:A] [permanent]
// CHECK-NEXT: - [P:A].[P] => [P:A]
// CHECK-NEXT: - [P].[Copyable] => [P] [explicit]
// CHECK-NEXT: - [P].[Escapable] => [P] [explicit]
// CHECK-NEXT: - [P:A].[Copyable] => [P:A] [explicit]
// CHECK-NEXT: - [P:A].[Escapable] => [P:A] [explicit]
// CHECK-NEXT: - [P].[P:A] => [P:A]
// CHECK-NEXT: - [P:A].A => [P:A].[P:A]
// CHECK-NEXT: - [Copyable].[Copyable] => [Copyable] [permanent]
// CHECK-NEXT: - [Escapable].[Escapable] => [Escapable] [permanent]
// CHECK-NEXT: - τ_0_0.A => τ_0_0
// CHECK-NEXT: - τ_0_1.[P] => τ_0_1
// CHECK-NEXT: - τ_0_1.A => τ_0_0
// CHECK-NEXT: - τ_0_0.[Copyable] => τ_0_0 [explicit]
// CHECK-NEXT: - τ_0_0.[Escapable] => τ_0_0 [explicit]
// CHECK-NEXT: - τ_0_1.[Copyable] => τ_0_1 [explicit]
// CHECK-NEXT: - τ_0_1.[Escapable] => τ_0_1 [explicit]
// CHECK-NEXT: - τ_0_1.[P:A] => τ_0_0
// CHECK-NEXT: - τ_0_0.[P] => τ_0_0
// CHECK-NEXT: - τ_0_0.[P:A] => τ_0_0
// CHECK-NEXT: }
// CHECK: Property map: {
// CHECK-NEXT:   [P] => { conforms_to: [P Copyable Escapable] }
// CHECK-NEXT:   [P:A] => { conforms_to: [P Copyable Escapable] }
// CHECK-NEXT:   [Copyable] => { conforms_to: [Copyable] }
// CHECK-NEXT:   [Escapable] => { conforms_to: [Escapable] }
// CHECK-NEXT:   τ_0_1 => { conforms_to: [P Copyable Escapable] }
// CHECK-NEXT:   τ_0_0 => { conforms_to: [Copyable Escapable P] }
// CHECK-NEXT: }