Skip to content

Commit 8f9871a

Browse files
invert fallback logic
1 parent 0251836 commit 8f9871a

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,18 @@ getSwiftStdlibType(const clang::TypedefNameDecl *D,
438438
else
439439
M = Impl.getNamedModule(SwiftModuleName);
440440

441+
if (!M) {
442+
// User did not import the library module that contains the type we want to
443+
// substitute.
444+
*IsError = true;
445+
return std::make_pair(Type(), "");
446+
}
447+
441448
Type SwiftType = Impl.getNamedSwiftType(M, SwiftTypeName);
442449

443450
if (!SwiftType && CTypeKind == MappedCTypeKind::CGFloat) {
444-
// Fall back to looking for CGFloat in Core Graphics.
445-
M = Impl.getNamedModule("CoreGraphics");
451+
// Look for CGFloat in CoreFoundation.
452+
M = Impl.getNamedModule("CoreFoundation");
446453
SwiftType = Impl.getNamedSwiftType(M, SwiftTypeName);
447454
}
448455

lib/ClangImporter/MappedTypes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ MAP_STDLIB_TYPE(
156156
UnsignedWord, 0, "Int", false, DoNothing)
157157

158158
// CGFloat.
159-
MAP_TYPE("CGFloat", CGFloat, 0, "CoreFoundation", "CGFloat", false, DoNothing)
159+
MAP_TYPE("CGFloat", CGFloat, 0, "CoreGraphics", "CGFloat", false, DoNothing)
160160

161161
// CoreFoundation types.
162162
// Note that we're preserving the typealias for CFIndex.

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,3 @@ public class Test: NSObject {
3030
@objc public func isEnabled() -> Bool { true }
3131
// CHECK-NEXT: init
3232
} // CHECK-NEXT: @end
33-
// Rebuild modules without -DCGFLOAT_IN_COREFOUNDATION
34-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t %clang-importer-sdk-path/swift-modules/CoreFoundation.swift
35-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -emit-module -o %t %clang-importer-sdk-path/swift-modules/CoreGraphics.swift

0 commit comments

Comments
 (0)