Skip to content

Commit cf44889

Browse files
committed
[ClangImporter] When importing ObjC pointer types, wrap protocol
compositions in ExistentialType when explicit existentials are enabled.
1 parent b4faed4 commit cf44889

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,9 @@ namespace {
10521052
Type importedTypeArg = ProtocolCompositionType::get(
10531053
Impl.SwiftContext, memberTypes,
10541054
hasExplicitAnyObject);
1055+
if (Impl.SwiftContext.LangOpts.EnableExplicitExistentialTypes) {
1056+
importedTypeArg = ExistentialType::get(importedTypeArg);
1057+
}
10551058
importedTypeArgs.push_back(importedTypeArg);
10561059
}
10571060
}
@@ -1203,6 +1206,10 @@ namespace {
12031206
importedType = ProtocolCompositionType::get(Impl.SwiftContext,
12041207
members,
12051208
/*HasExplicitAnyObject=*/false);
1209+
1210+
if (Impl.SwiftContext.LangOpts.EnableExplicitExistentialTypes) {
1211+
importedType = ExistentialType::get(importedType);
1212+
}
12061213
}
12071214

12081215
// Class or Class<P> maps to an existential metatype.

test/ClangImporter/objc_bridging_generics.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -verify -swift-version 4 -I %S/Inputs/custom-modules %s
2+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -enable-explicit-existential-types -verify -swift-version 4 -I %S/Inputs/custom-modules %s
23

34
// REQUIRES: objc_interop
45

0 commit comments

Comments
 (0)