You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For containment issues, where an unconditionally or conditionally
Copyable type contains a fixed noncopyable element, remind users about
the conditional conformance in addition to the fix-it to add ~Copyable
Copy file name to clipboardExpand all lines: test/Generics/inverse_copyable_generics.swift
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,7 @@ protocol RemovedAgain where Self: ~Copyable {
47
47
48
48
structStructContainment<T:~Copyable>:Copyable{
49
49
// expected-note@-1 {{consider adding '~Copyable' to generic struct 'StructContainment'}}{{50-50=, ~Copyable}}
50
+
// expected-note@-2 {{generic struct 'StructContainment' has '~Copyable' constraint on a generic parameter, making its 'Copyable' conformance conditional}}
50
51
51
52
varstorage:Maybe<T>
52
53
// expected-error@-1 {{stored property 'storage' of 'Copyable'-conforming generic struct 'StructContainment' has noncopyable type 'Maybe<T>'}}
// expected-note@-1 {{'T' has '~Copyable' constraint preventing implicit 'Copyable' conformance}}
57
58
// expected-note@-2{{consider adding '~Copyable' to generic enum 'EnumContainment'}}{{46-46=, ~Copyable}}
59
+
// expected-note@-3{{generic enum 'EnumContainment' has '~Copyable' constraint on a generic parameter, making its 'Copyable' conformance conditional}}
58
60
59
61
case some(T) // expected-error {{associated value 'some' of 'Copyable'-conforming generic enum 'EnumContainment' has noncopyable type 'T'}}
60
62
case other(Int)
@@ -69,6 +71,7 @@ class ClassContainment<T: ~Copyable> {
69
71
}
70
72
}
71
73
74
+
// expected-note@+2 {{generic struct 'ConditionalContainment' has '~Copyable' constraint on a generic parameter, making its 'Copyable' conformance conditional}}
72
75
// expected-note@+1 {{consider adding '~Copyable' to generic struct 'ConditionalContainment'}}{{45-45=: ~Copyable}}
73
76
structConditionalContainment<T:~Copyable>{
74
77
varx:T
@@ -116,6 +119,7 @@ extension Maybe where Self: Copyable {
116
119
func check2(_ t:RequireCopyable<Self>){}
117
120
}
118
121
122
+
// expected-note@+2 {{generic struct 'CornerCase' has '~Copyable' constraint on a generic parameter, making its 'Copyable' conformance conditional}}
119
123
// expected-note@+1 {{consider adding '~Copyable' to generic struct 'CornerCase'}}{{33-33=: ~Copyable}}
0 commit comments