Skip to content

Commit dd40e14

Browse files
authored
Merge pull request #60181 from hborla/restated-coregraphics-conformance
[Sema] Downgrade the redundant conformance error to a warning for conformances originally stated in CoreGraphics.
2 parents 8893b3b + 25f10b9 commit dd40e14

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 2 additions & 1 deletion
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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)