|
2 | 2 | // Exceptions. See /LICENSE for license information. |
3 | 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
4 | 4 | // |
5 | | -// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon |
| 5 | +// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon |
6 | 6 | // |
7 | 7 | // AUTOUPDATE |
8 | 8 | // TIP: To test this file alone, run: |
|
13 | 13 | // --- fail_incomplete_interface.carbon |
14 | 14 | library "[[@TEST_NAME]]"; |
15 | 15 |
|
16 | | -interface A; |
17 | | -interface B {} |
| 16 | +interface X; |
18 | 17 | class C {} |
19 | 18 |
|
20 | | -fn G[T:! A](t: T) {} |
21 | | -fn H[T:! A & B](t: T) {} |
| 19 | +// Requires X identified. |
| 20 | +impl C as X; |
22 | 21 |
|
23 | | -fn F() { |
24 | | - // CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE+4]]:3: error: cannot convert type `C` into type implementing `A` [ConversionFailureTypeToFacet] |
25 | | - // CHECK:STDERR: C as A; |
26 | | - // CHECK:STDERR: ^~~~~~ |
27 | | - // CHECK:STDERR: |
28 | | - C as A; |
| 22 | +// Requires X complete. |
| 23 | +// CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE+7]]:1: error: definition of impl as incomplete facet type `X` [ImplAsIncompleteFacetTypeDefinition] |
| 24 | +// CHECK:STDERR: impl C as X {} |
| 25 | +// CHECK:STDERR: ^~~~~~~~~~~~~ |
| 26 | +// CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE-10]]:1: note: interface was forward declared here [InterfaceForwardDeclaredHere] |
| 27 | +// CHECK:STDERR: interface X; |
| 28 | +// CHECK:STDERR: ^~~~~~~~~~~~ |
| 29 | +// CHECK:STDERR: |
| 30 | +impl C as X {} |
29 | 31 |
|
30 | | - // CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE+4]]:3: error: cannot convert type `C` into type implementing `A & B` [ConversionFailureTypeToFacet] |
31 | | - // CHECK:STDERR: C as (A & B); |
32 | | - // CHECK:STDERR: ^~~~~~~~~~~~ |
33 | | - // CHECK:STDERR: |
34 | | - C as (A & B); |
35 | | - |
36 | | - // CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE+7]]:3: error: cannot convert type `C` into type implementing `A` [ConversionFailureTypeToFacet] |
37 | | - // CHECK:STDERR: G({} as C); |
38 | | - // CHECK:STDERR: ^~~~~~~~~~ |
39 | | - // CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE-19]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] |
40 | | - // CHECK:STDERR: fn G[T:! A](t: T) {} |
41 | | - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ |
42 | | - // CHECK:STDERR: |
43 | | - G({} as C); |
44 | | - |
45 | | - // CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE+7]]:3: error: cannot convert type `C` into type implementing `A & B` [ConversionFailureTypeToFacet] |
46 | | - // CHECK:STDERR: H({} as C); |
47 | | - // CHECK:STDERR: ^~~~~~~~~~ |
48 | | - // CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE-27]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] |
49 | | - // CHECK:STDERR: fn H[T:! A & B](t: T) {} |
50 | | - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~ |
51 | | - // CHECK:STDERR: |
52 | | - H({} as C); |
| 32 | +// --- fail_incomplete_interface_without_forward_decl.carbon |
| 33 | +library "[[@TEST_NAME]]"; |
| 34 | + |
| 35 | +interface X; |
| 36 | +class C {} |
| 37 | + |
| 38 | +// Requires X complete. |
| 39 | +// CHECK:STDERR: fail_incomplete_interface_without_forward_decl.carbon:[[@LINE+7]]:1: error: definition of impl as incomplete facet type `X` [ImplAsIncompleteFacetTypeDefinition] |
| 40 | +// CHECK:STDERR: impl C as X {} |
| 41 | +// CHECK:STDERR: ^~~~~~~~~~~~~ |
| 42 | +// CHECK:STDERR: fail_incomplete_interface_without_forward_decl.carbon:[[@LINE-7]]:1: note: interface was forward declared here [InterfaceForwardDeclaredHere] |
| 43 | +// CHECK:STDERR: interface X; |
| 44 | +// CHECK:STDERR: ^~~~~~~~~~~~ |
| 45 | +// CHECK:STDERR: |
| 46 | +impl C as X {} |
| 47 | + |
| 48 | +// --- fail_unidentified_constraint.carbon |
| 49 | +library "[[@TEST_NAME]]"; |
| 50 | + |
| 51 | +constraint X; |
| 52 | +class C {} |
| 53 | + |
| 54 | +// Requires X identified. |
| 55 | +// CHECK:STDERR: fail_unidentified_constraint.carbon:[[@LINE+7]]:1: error: facet type `X` cannot be identified in `impl as` [ImplOfUnidentifiedFacetType] |
| 56 | +// CHECK:STDERR: impl C as X; |
| 57 | +// CHECK:STDERR: ^~~~~~~~~~~~ |
| 58 | +// CHECK:STDERR: fail_unidentified_constraint.carbon:[[@LINE-7]]:1: note: constraint was forward declared here [NamedConstraintForwardDeclaredHere] |
| 59 | +// CHECK:STDERR: constraint X; |
| 60 | +// CHECK:STDERR: ^~~~~~~~~~~~~ |
| 61 | +// CHECK:STDERR: |
| 62 | +impl C as X; |
| 63 | + |
| 64 | +// --- nested_require_incomplete_interface.carbon |
| 65 | +library "[[@TEST_NAME]]"; |
| 66 | + |
| 67 | +interface Z; |
| 68 | +constraint Y { |
| 69 | + require impls Z; |
53 | 70 | } |
| 71 | +interface X { |
| 72 | + require impls Y; |
| 73 | +} |
| 74 | + |
| 75 | +class C {} |
| 76 | + |
| 77 | +// Requires X identified. |
| 78 | +impl C as X; |
| 79 | + |
| 80 | +// Requires X complete. |
| 81 | +impl C as X {} |
54 | 82 |
|
55 | | -// --- fail_incomplete_constraint.carbon |
| 83 | +// --- fail_incomplete_through_constraint.carbon |
56 | 84 | library "[[@TEST_NAME]]"; |
57 | 85 |
|
58 | | -constraint A; |
59 | | -interface B {} |
| 86 | +interface Z; |
| 87 | +constraint Y { |
| 88 | + extend require impls Z; |
| 89 | +} |
| 90 | + |
60 | 91 | class C {} |
61 | 92 |
|
62 | | -fn G[T:! A](t: T) {} |
63 | | -fn H[T:! A & B](t: T) {} |
| 93 | +// Requires Y identified. |
| 94 | +impl C as Y; |
64 | 95 |
|
65 | | -fn F() { |
66 | | - // CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE+7]]:3: error: facet type `A` is incomplete [ImplLookupInIncompleteFacetType] |
67 | | - // CHECK:STDERR: C as A; |
68 | | - // CHECK:STDERR: ^~~~~~ |
69 | | - // CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-11]]:1: note: constraint was forward declared here [NamedConstraintForwardDeclaredHere] |
70 | | - // CHECK:STDERR: constraint A; |
71 | | - // CHECK:STDERR: ^~~~~~~~~~~~~ |
72 | | - // CHECK:STDERR: |
73 | | - C as A; |
| 96 | +// Requires Y complete. |
| 97 | +// CHECK:STDERR: fail_incomplete_through_constraint.carbon:[[@LINE+7]]:1: error: definition of impl as incomplete facet type `Y` [ImplAsIncompleteFacetTypeDefinition] |
| 98 | +// CHECK:STDERR: impl C as Y {} |
| 99 | +// CHECK:STDERR: ^~~~~~~~~~~~~ |
| 100 | +// CHECK:STDERR: fail_incomplete_through_constraint.carbon:[[@LINE-14]]:1: note: interface was forward declared here [InterfaceForwardDeclaredHere] |
| 101 | +// CHECK:STDERR: interface Z; |
| 102 | +// CHECK:STDERR: ^~~~~~~~~~~~ |
| 103 | +// CHECK:STDERR: |
| 104 | +impl C as Y {} |
74 | 105 |
|
75 | | - // CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE+7]]:3: error: facet type `B & A` is incomplete [ImplLookupInIncompleteFacetType] |
76 | | - // CHECK:STDERR: C as (A & B); |
77 | | - // CHECK:STDERR: ^~~~~~~~~~~~ |
78 | | - // CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-20]]:1: note: constraint was forward declared here [NamedConstraintForwardDeclaredHere] |
79 | | - // CHECK:STDERR: constraint A; |
80 | | - // CHECK:STDERR: ^~~~~~~~~~~~~ |
81 | | - // CHECK:STDERR: |
82 | | - C as (A & B); |
| 106 | +// --- fail_impl_lookup_incomplete.carbon |
| 107 | +library "[[@TEST_NAME]]"; |
83 | 108 |
|
84 | | - // CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE+10]]:3: error: facet type `A` is incomplete [ImplLookupInIncompleteFacetType] |
85 | | - // CHECK:STDERR: G({} as C); |
86 | | - // CHECK:STDERR: ^~~~~~~~~~ |
87 | | - // CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-29]]:1: note: constraint was forward declared here [NamedConstraintForwardDeclaredHere] |
88 | | - // CHECK:STDERR: constraint A; |
89 | | - // CHECK:STDERR: ^~~~~~~~~~~~~ |
90 | | - // CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-28]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] |
91 | | - // CHECK:STDERR: fn G[T:! A](t: T) {} |
92 | | - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ |
93 | | - // CHECK:STDERR: |
94 | | - G({} as C); |
| 109 | +constraint Z; |
95 | 110 |
|
96 | | - // CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE+10]]:3: error: facet type `B & A` is incomplete [ImplLookupInIncompleteFacetType] |
97 | | - // CHECK:STDERR: H({} as C); |
98 | | - // CHECK:STDERR: ^~~~~~~~~~ |
99 | | - // CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-41]]:1: note: constraint was forward declared here [NamedConstraintForwardDeclaredHere] |
100 | | - // CHECK:STDERR: constraint A; |
| 111 | +fn AsZ(T:! Z) {} |
| 112 | + |
| 113 | +fn F() { |
| 114 | + // Requires Z identified. |
| 115 | + // CHECK:STDERR: fail_impl_lookup_incomplete.carbon:[[@LINE+10]]:3: error: facet type `Z` can not be identified [ImplLookupInUnidentifiedFacetType] |
| 116 | + // CHECK:STDERR: AsZ(()); |
| 117 | + // CHECK:STDERR: ^~~~~~~ |
| 118 | + // CHECK:STDERR: fail_impl_lookup_incomplete.carbon:[[@LINE-9]]:1: note: constraint was forward declared here [NamedConstraintForwardDeclaredHere] |
| 119 | + // CHECK:STDERR: constraint Z; |
101 | 120 | // CHECK:STDERR: ^~~~~~~~~~~~~ |
102 | | - // CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-39]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] |
103 | | - // CHECK:STDERR: fn H[T:! A & B](t: T) {} |
104 | | - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~ |
| 121 | + // CHECK:STDERR: fail_impl_lookup_incomplete.carbon:[[@LINE-10]]:8: note: initializing generic parameter `T` declared here [InitializingGenericParam] |
| 122 | + // CHECK:STDERR: fn AsZ(T:! Z) {} |
| 123 | + // CHECK:STDERR: ^ |
105 | 124 | // CHECK:STDERR: |
106 | | - H({} as C); |
| 125 | + AsZ(()); |
107 | 126 | } |
0 commit comments