mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Diagnose retroactive conditional conformances
Passing in the declared interface type to checkConformance() here masked a silent failure where if the type declaration was generic and the conformance conditional, the conditional requirement check would fail. As a result, we did not diagnose the absence of @retroactive, nor the unnecessary presence of it. Since we only care about the existence of some conformance, we can use lookupConformance() instead.
This commit is contained in:
@@ -1653,7 +1653,7 @@ static void diagnoseRetroactiveConformances(
|
||||
proto->walkInheritedProtocols([&](ProtocolDecl *decl) {
|
||||
|
||||
// Get the original conformance of the extended type to this protocol.
|
||||
auto conformanceRef = ext->getParentModule()->checkConformance(
|
||||
auto conformanceRef = ext->getParentModule()->lookupConformance(
|
||||
extendedType, decl);
|
||||
if (!conformanceRef.isConcrete()) {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
public protocol MyBitwiseCopyable : _BitwiseCopyable {}
|
||||
|
||||
extension SIMD16 : @retroactive MyBitwiseCopyable where Scalar.SIMD16Storage : MyBitwiseCopyable {}
|
||||
extension SIMD16 : MyBitwiseCopyable where Scalar.SIMD16Storage : MyBitwiseCopyable {}
|
||||
extension UInt8.SIMD16Storage : MyBitwiseCopyable {}
|
||||
|
||||
func doit() {
|
||||
|
||||
@@ -15,6 +15,9 @@ public struct Sample5 {}
|
||||
public struct Sample6 {}
|
||||
|
||||
public struct SampleAlreadyConforms: SampleProtocol1 {}
|
||||
|
||||
public struct GenericSample1<T> {}
|
||||
|
||||
#else
|
||||
|
||||
import Library
|
||||
@@ -81,4 +84,9 @@ extension OriginallyDefinedInLibrary: SampleProtocol1 {} // ok, @_originallyDefi
|
||||
|
||||
#endif
|
||||
|
||||
// conditional conformances
|
||||
extension GenericSample1: SampleProtocol1 where T: SampleProtocol1 {}
|
||||
// expected-warning@-1 {{extension declares a conformance of imported type 'GenericSample1' to imported protocol 'SampleProtocol1'; this will not behave correctly if the owners of 'Library' introduce this conformance in the future}}
|
||||
// expected-note@-2 {{add '@retroactive' to silence this warning}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
extension SIMD2: AdditiveArithmetic where Scalar: FloatingPoint { }
|
||||
extension SIMD3: AdditiveArithmetic where Scalar: FloatingPoint { }
|
||||
extension SIMD4: AdditiveArithmetic where Scalar: FloatingPoint { }
|
||||
extension SIMD8: AdditiveArithmetic where Scalar: FloatingPoint { }
|
||||
extension SIMD2: @retroactive AdditiveArithmetic where Scalar: FloatingPoint { }
|
||||
extension SIMD3: @retroactive AdditiveArithmetic where Scalar: FloatingPoint { }
|
||||
extension SIMD4: @retroactive AdditiveArithmetic where Scalar: FloatingPoint { }
|
||||
extension SIMD8: @retroactive AdditiveArithmetic where Scalar: FloatingPoint { }
|
||||
|
||||
Reference in New Issue
Block a user