mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
In Swift 4, we only gave custom overload types to properties defined in extensions of generic types, using the null type for any other var decl. This meant that a property defined in such an extension would never shadow a property not defined in such an extension. As a result, this permitted cross-module overloads of properties of different types on generic types in certain cases. This patch adds an exception to the shadowing rules for properties defined in generic type extensions under Swift 4 mode. Permitting cross-module property overloads in the general case would also be source breaking (causing ambiguity errors), so this can be handled in a follow-up Swift 5 mode PR if desired. Resolves SR-7341.
17 lines
254 B
Swift
17 lines
254 B
Swift
|
|
public struct HasFooGeneric<T> {
|
|
public var foo: Int = 0
|
|
}
|
|
|
|
extension HasFooGeneric {
|
|
public var bar: Int { return 0 }
|
|
}
|
|
|
|
public class HasFooNonGeneric {
|
|
public var foo: Int = 0
|
|
}
|
|
|
|
extension HasFooNonGeneric {
|
|
public var bar: Int { return 0 }
|
|
}
|