[SR-8619] Reject bare references to cross-module property overloads in Swift 5 mode #51134
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
regression
swift 5.0
type checker
Area → compiler: Semantic analysis
Additional Detail from JIRA
md5: 04793bdded2833dcbbec9817d61fdd9c
Issue Description:
In Swift 4.1 we had the following overloading behaviour for a very specific case of cross-module overloading where one property was in an extension of a generic type, and the other property wasn't:
In any other case (e.g if the type is non-generic, or if both properties are defined in extensions), we have this behaviour:
And this is also the behaviour that both examples will now exhibit in Swift 5 mode. The property from the current module always shadows the property from the other module.
IMO this behaviour is unintuitive – we should change the behaviour to act more like the behaviour of the first example in Swift 4.1. That is, we should reject bare reference to such property overloads as ambiguous and allow the user to disambiguate by type (and if we ever introduce syntax to disambiguate such cases by module, we could require the user to do that instead).
For more context, see https://forums.swift.org/t/should-we-allow-cross-module-overloading-of-variables-and-properties/15096.
The text was updated successfully, but these errors were encountered: