[Sema] Downgrade the redundant conformance error to a warning for conformances

originally stated in CoreGraphics.
This commit is contained in:
Holly Borla
2022-07-21 12:03:12 -07:00
parent 2f78f5a7b3
commit 25f10b9164
4 changed files with 12 additions and 2 deletions

View File

@@ -6563,7 +6563,8 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
if (existingModule != dc->getParentModule() &&
(existingModule->getName() ==
extendedNominal->getParentModule()->getName() ||
existingModule == diag.Protocol->getParentModule())) {
existingModule == diag.Protocol->getParentModule() ||
existingModule->getName().is("CoreGraphics"))) {
// Warn about the conformance.
auto diagID = differentlyConditional
? diag::redundant_conformance_adhoc_conditional

View File

@@ -17,3 +17,6 @@ func test() -> UnsafeMutablePointer<CGFloat>? {
return CGColorGetComponents(color)
}
// Allow redundant conformances on CoreFoundation
// types where the conformance is in CoreGraphics.
extension CGFloat: CustomStringConvertible {}

View File

@@ -52,3 +52,9 @@ public extension Double {
}
}
#endif
import CoreFoundation
extension CGFloat: CustomStringConvertible {
public var description: String { "" }
}

View File

@@ -10,7 +10,7 @@
// RUN: %target-swift-frontend -typecheck %s -parse-as-library -emit-objc-header-path %t/swift.h
// RUN: %FileCheck %s < %t/swift.h
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -DCGFLOAT_IN_COREFOUNDATION -emit-module -o %t %clang-importer-sdk-path/swift-modules/CoreFoundation.swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -DCGFLOAT_IN_COREFOUNDATION -emit-module -o %t %clang-importer-sdk-path/swift-modules/CoreGraphics.swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -DCGFLOAT_IN_COREFOUNDATION -emit-module -o %t %clang-importer-sdk-path/swift-modules/CoreGraphics.swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t %clang-importer-sdk-path/swift-modules/Foundation.swift
// REQUIRES: objc_interop