mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #17392 from huonw/redefinition-swift-4-compat
Swift 4 compatibility hack for redeclaration of properties in generic type and extension
This commit is contained in:
@@ -1747,7 +1747,30 @@ bool swift::conflicting(ASTContext &ctx,
|
||||
}
|
||||
|
||||
// Otherwise, the declarations conflict if the overload types are the same.
|
||||
return sig1Type == sig2Type;
|
||||
if (sig1Type != sig2Type)
|
||||
return false;
|
||||
|
||||
// The Swift 5 overload types are the same, but similar to the above, prior to
|
||||
// Swift 5, a variable not in an extension of a generic type got a null
|
||||
// overload type instead of a function type as it does now, so we really
|
||||
// follow that behaviour and warn if there's going to be a conflict in future.
|
||||
if (!ctx.isSwiftVersionAtLeast(5)) {
|
||||
auto swift4Sig1Type = sig1.IsVariable && !sig1.InExtensionOfGenericType
|
||||
? CanType()
|
||||
: sig1Type;
|
||||
auto swift4Sig2Type = sig1.IsVariable && !sig2.InExtensionOfGenericType
|
||||
? CanType()
|
||||
: sig1Type;
|
||||
if (swift4Sig1Type != swift4Sig2Type) {
|
||||
// Old was different to the new behaviour!
|
||||
if (wouldConflictInSwift5)
|
||||
*wouldConflictInSwift5 = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static Type mapSignatureFunctionType(ASTContext &ctx, Type type,
|
||||
|
||||
Reference in New Issue
Block a user