Fix SR-5614, add check if importType succeds (#11698)

SwiftDeclConverter::importSwiftNewtype now check if the
storedUnderlyingType is null and return a nullptr
This commit is contained in:
Jacopo Andrea Giola
2017-09-01 22:41:48 +02:00
committed by Jordan Rose
parent 1e69d14f95
commit a598277ad3
3 changed files with 11 additions and 0 deletions

View File

@@ -4970,6 +4970,9 @@ SwiftDeclConverter::importSwiftNewtype(const clang::TypedefNameDecl *decl,
decl->getUnderlyingType(), ImportTypeKind::Value, isInSystemModule(dc),
Bridgeability::None, OTK_None);
if (!storedUnderlyingType)
return nullptr;
if (auto objTy = storedUnderlyingType->getAnyOptionalObjectType())
storedUnderlyingType = objTy;

View File

@@ -0,0 +1,4 @@
@import Foundation;
typedef NSString MyString __attribute__((swift_wrapper(struct)));
extern MyString * const MyStringOne;

View File

@@ -0,0 +1,4 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck %s -import-objc-header %S/Inputs/bad-ns-extensible-string-enum.h -verify
// REQUIRES: objc_interop
let string = MyString.MyStringOne // expected-error {{use of unresolved identifier 'MyString'}}