mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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 https://github.com/apple/swift/issues/62767.
17 lines
1.0 KiB
Swift
17 lines
1.0 KiB
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
struct Outer<T, U> { // expected-note 2{{'T' previously declared here}}
|
|
struct Inner<V> { // expected-note 2{{'V' previously declared here}}
|
|
func foo<T>(_: T) {} // expected-warning {{generic parameter 'T' shadows generic parameter from outer scope with the same name; this is an error in Swift 6}}
|
|
func bar<V>(_: V) {} // expected-warning {{generic parameter 'V' shadows generic parameter from outer scope with the same name; this is an error in Swift 6}}
|
|
}
|
|
}
|
|
|
|
extension Outer.Inner {
|
|
func baz<T>(_: T) {} // expected-warning {{generic parameter 'T' shadows generic parameter from outer scope with the same name; this is an error in Swift 6}}
|
|
func quux<V>(_: V) {} // expected-warning {{generic parameter 'V' shadows generic parameter from outer scope with the same name; this is an error in Swift 6}}
|
|
}
|
|
|
|
extension Sequence {
|
|
func bing<Self>(_: Self) {} // expected-warning {{generic parameter 'Self' shadows generic parameter from outer scope with the same name; this is an error in Swift 6}}
|
|
} |