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
Sema: Ban shadowing generic parameters from outer scopes
Code like that is usually indicative of programmer error, and does not
round-trip through module interface files since there is no source
syntax to refer to an outer generic parameter.
For source compatibility this is a warning, but becomes an error with
-swift-version 6.
Fixes rdar://problem/108385980 and #62767.
Copy file name to clipboardExpand all lines: test/Compatibility/accessibility.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -516,8 +516,8 @@ public struct PublicGenericIPReq<T: InternalProto> where T: PrivateProto {} // e
516
516
517
517
publicfunc genericFunc<T:InternalProto>(_:T){} // expected-error {{function cannot be declared public because its generic parameter uses an internal type}} {}
518
518
publicclassGenericClass<T:InternalProto>{ // expected-error {{generic class cannot be declared public because its generic parameter uses an internal type}}
519
-
publicinit<T:PrivateProto>(_:T){} // expected-error {{initializer cannot be declared public because its generic parameter uses a private type}}
520
-
publicfunc genericMethod<T:PrivateProto>(_:T){} // expected-error {{instance method cannot be declared public because its generic parameter uses a private type}}
519
+
publicinit<U:PrivateProto>(_:U){} // expected-error {{initializer cannot be declared public because its generic parameter uses a private type}}
520
+
publicfunc genericMethod<U:PrivateProto>(_:U){} // expected-error {{instance method cannot be declared public because its generic parameter uses a private type}}
521
521
}
522
522
publicenumGenericEnum<T:InternalProto>{ // expected-error {{generic enum cannot be declared public because its generic parameter uses an internal type}}
// expected-error@-1 {{cannot convert value of type 'T' (generic parameter of instance method 'bar(_:)') to expected argument type 'T' (generic parameter of generic struct 'S_24329052')}}
516
+
// expected-warning@-2 {{generic parameter 'T' shadows generic parameter from outer scope with the same name; this is an error in Swift 6}}
0 commit comments