Skip to content

Commit 85d4d12

Browse files
[Serialization] Serialize Clang types for non-modular headers.
1 parent aef00fb commit 85d4d12

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

lib/ClangImporter/Serializability.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ class SerializationPathFinder {
5353
Impl.SwiftContext.getSwiftDeclForExportedClangDecl(decl))
5454
return swiftDecl;
5555

56-
// Otherwise we have no way to find it.
57-
return StableSerializationPath();
56+
// Allow serialization for non-modular headers as well, with the hope that
57+
// we find the same header when doing unqualified lookup during
58+
// deserialization.
59+
return findImportedPath(named);
5860
}
5961

6062
private:

test/ClangImporter/unserializable-clang-function-types.swift

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/Serialization/non-modular-clang-type.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: not --crash %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -enable-testing -module-name NonModularApp -emit-module -o %t/NonModularApp.swiftmodule -import-objc-header %S/Inputs/non-modular-header.h -DNON_MODULAR_APP -use-clang-function-types 2>&1 | %FileCheck %s
2+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -enable-testing -module-name NonModularApp -emit-module -o %t/NonModularApp.swiftmodule -import-objc-header %S/Inputs/non-modular-header.h -DNON_MODULAR_APP -use-clang-function-types
3+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -typecheck -module-name NonModularAppTest -I %t -DNON_MODULAR_APP_TEST
34

45
// CHECK: Clang function type is not serializable
56

@@ -9,3 +10,9 @@ struct S {
910
static func f(_ : @convention(c, cType: "void (*)(PlaceholderType, size_t)") (PlaceholderType, Int) -> ()) {}
1011
}
1112
#endif
13+
14+
#if NON_MODULAR_APP_TEST
15+
@testable import NonModularApp
16+
17+
S.f({ _, _ in })
18+
#endif

0 commit comments

Comments
 (0)