Skip to content

Commit 25f10b9

Browse files
committed
[Sema] Downgrade the redundant conformance error to a warning for conformances
originally stated in CoreGraphics.
1 parent 2f78f5a commit 25f10b9

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

lib/Sema/TypeCheckProtocol.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -6563,7 +6563,8 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
65636563
if (existingModule != dc->getParentModule() &&
65646564
(existingModule->getName() ==
65656565
extendedNominal->getParentModule()->getName() ||
6566-
existingModule == diag.Protocol->getParentModule())) {
6566+
existingModule == diag.Protocol->getParentModule() ||
6567+
existingModule->getName().is("CoreGraphics"))) {
65676568
// Warn about the conformance.
65686569
auto diagID = differentlyConditional
65696570
? diag::redundant_conformance_adhoc_conditional

test/ClangImporter/import-cgfloat-api.swift

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ func test() -> UnsafeMutablePointer<CGFloat>? {
1717
return CGColorGetComponents(color)
1818
}
1919

20+
// Allow redundant conformances on CoreFoundation
21+
// types where the conformance is in CoreGraphics.
22+
extension CGFloat: CustomStringConvertible {}

test/Inputs/clang-importer-sdk/swift-modules/CoreGraphics.swift

+6
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ public extension Double {
5252
}
5353
}
5454
#endif
55+
56+
import CoreFoundation
57+
58+
extension CGFloat: CustomStringConvertible {
59+
public var description: String { "" }
60+
}

test/PrintAsObjC/bridged-known-types-cf-cgfloat.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// RUN: %target-swift-frontend -typecheck %s -parse-as-library -emit-objc-header-path %t/swift.h
1111
// RUN: %FileCheck %s < %t/swift.h
1212
// 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
13-
// 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
13+
// 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
1414
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t %clang-importer-sdk-path/swift-modules/Foundation.swift
1515

1616
// REQUIRES: objc_interop

0 commit comments

Comments
 (0)