Skip to content

Commit a8cfb77

Browse files
authored
Merge pull request #12680 from DougGregor/importer-bridged-typedef-4.1
[Clang importer] Fix bridging of the underlying types of typedefs.
2 parents 3821f6e + f896b91 commit a8cfb77

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -684,18 +684,13 @@ namespace {
684684
auto typedefBridgeability = getTypedefBridgeability(underlyingType);
685685

686686
// Figure out the typedef we should actually use.
687-
auto underlyingBridgeability =
688-
(Bridging == Bridgeability::Full
689-
? typedefBridgeability : Bridgeability::None);
690-
SwiftTypeConverter innerConverter(Impl, AllowNSUIntegerAsInt,
691-
underlyingBridgeability);
687+
SwiftTypeConverter innerConverter(Impl, AllowNSUIntegerAsInt, Bridging);
692688
auto underlyingResult = innerConverter.Visit(underlyingType);
693689

694690
// If we used different bridgeability than this typedef normally
695-
// would because we're in a non-bridgeable context, and therefore
696-
// the underlying type is different from the mapping of the typedef,
697-
// use the underlying type.
698-
if (underlyingBridgeability != typedefBridgeability &&
691+
// would, and therefore the underlying type is different from the
692+
// mapping of the typedef, use the underlying type.
693+
if (Bridging != typedefBridgeability &&
699694
!underlyingResult.AbstractType->isEqual(mappedType)) {
700695
return underlyingResult;
701696
}

test/ClangImporter/Inputs/custom-modules/ObjCParseExtras.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,9 @@ typedef SomeCell <NSCopying> *CopyableSomeCell;
203203
@property (class, readonly) InstancetypeAccessor *prop;
204204
+ (instancetype)prop;
205205
@end
206+
207+
typedef NSArray<NSString *> *NSStringArray;
208+
209+
@interface BridgedTypedefs : NSObject
210+
@property (readonly,nonnull) NSArray<NSStringArray> *arrayOfArrayOfStrings;
211+
@end

test/ClangImporter/objc_parse.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,3 +638,8 @@ func testTypeAndValue() {
638638
let _: () -> testStruct = testStruct.init
639639
let _: (CInt) -> testStruct = testStruct.init
640640
}
641+
642+
// rdar://problem/34913507
643+
func testBridgedTypedef(bt: BridgedTypedefs) {
644+
let _: Int = bt.arrayOfArrayOfStrings // expected-error{{'[[String]]'}}
645+
}

0 commit comments

Comments
 (0)