@@ -2041,10 +2041,11 @@ namespace {
20412041 decl->setImplicit ();
20422042 }
20432043
2044- // / Create a typealias for the Swift 2 name of a Clang type declaration.
2045- Decl *importSwift2TypeAlias (const clang::NamedDecl *decl,
2046- ImportedName swift2Name,
2047- ImportedName correctSwiftName);
2044+ // / Create a typealias for the name of a Clang type declaration in an
2045+ // / alternate version of Swift.
2046+ Decl *importCompatibilityTypeAlias (const clang::NamedDecl *decl,
2047+ ImportedName compatibilityName,
2048+ ImportedName correctSwiftName);
20482049
20492050 // / Create a swift_newtype struct corresponding to a typedef. Returns
20502051 // / nullptr if unable.
@@ -2062,7 +2063,8 @@ namespace {
20622063 // If we've been asked to produce a Swift 2 stub, handle it via a
20632064 // typealias.
20642065 if (correctSwiftName)
2065- return importSwift2TypeAlias (Decl, importedName, *correctSwiftName);
2066+ return importCompatibilityTypeAlias (Decl, importedName,
2067+ *correctSwiftName);
20662068
20672069 Type SwiftType;
20682070 if (Decl->getDeclContext ()->getRedeclContext ()->isTranslationUnit ()) {
@@ -2277,7 +2279,8 @@ namespace {
22772279 // If we've been asked to produce a Swift 2 stub, handle it via a
22782280 // typealias.
22792281 if (correctSwiftName)
2280- return importSwift2TypeAlias (decl, importedName, *correctSwiftName);
2282+ return importCompatibilityTypeAlias (decl, importedName,
2283+ *correctSwiftName);
22812284
22822285 auto dc =
22832286 Impl.importDeclContextOf (decl, importedName.getEffectiveContext ());
@@ -2693,7 +2696,8 @@ namespace {
26932696 // If we've been asked to produce a Swift 2 stub, handle it via a
26942697 // typealias.
26952698 if (correctSwiftName)
2696- return importSwift2TypeAlias (decl, importedName, *correctSwiftName);
2699+ return importCompatibilityTypeAlias (decl, importedName,
2700+ *correctSwiftName);
26972701
26982702 auto dc =
26992703 Impl.importDeclContextOf (decl, importedName.getEffectiveContext ());
@@ -3957,7 +3961,8 @@ namespace {
39573961 // If we've been asked to produce a Swift 2 stub, handle it via a
39583962 // typealias.
39593963 if (correctSwiftName)
3960- return importSwift2TypeAlias (decl, importedName, *correctSwiftName);
3964+ return importCompatibilityTypeAlias (decl, importedName,
3965+ *correctSwiftName);
39613966
39623967 Identifier name = importedName.getDeclName ().getBaseName ();
39633968
@@ -4092,7 +4097,8 @@ namespace {
40924097 // If we've been asked to produce a Swift 2 stub, handle it via a
40934098 // typealias.
40944099 if (correctSwiftName)
4095- return importSwift2TypeAlias (decl, importedName, *correctSwiftName);
4100+ return importCompatibilityTypeAlias (decl, importedName,
4101+ *correctSwiftName);
40964102
40974103 auto name = importedName.getDeclName ().getBaseName ();
40984104
@@ -4630,9 +4636,10 @@ SwiftDeclConverter::importCFClassType(const clang::TypedefNameDecl *decl,
46304636 return theClass;
46314637}
46324638
4633- Decl *SwiftDeclConverter::importSwift2TypeAlias (const clang::NamedDecl *decl,
4634- ImportedName swift2Name,
4635- ImportedName correctSwiftName) {
4639+ Decl *SwiftDeclConverter::importCompatibilityTypeAlias (
4640+ const clang::NamedDecl *decl,
4641+ ImportedName compatibilityName,
4642+ ImportedName correctSwiftName) {
46364643 // Import the referenced declaration. If it doesn't come in as a type,
46374644 // we don't care.
46384645 auto importedDecl = Impl.importDecl (decl, getActiveSwiftVersion ());
@@ -4665,19 +4672,14 @@ Decl *SwiftDeclConverter::importSwift2TypeAlias(const clang::NamedDecl *decl,
46654672
46664673 // Create the type alias.
46674674 auto alias = Impl.createDeclWithClangNode <TypeAliasDecl>(
4668- decl,
4669- Accessibility::Public, Impl.importSourceLoc (decl->getLocStart ()),
4670- SourceLoc (), swift2Name.getDeclName ().getBaseName (),
4671- Impl.importSourceLoc (decl->getLocation ()),
4672- genericParams, dc);
4675+ decl, Accessibility::Public, Impl.importSourceLoc (decl->getLocStart ()),
4676+ SourceLoc (), compatibilityName.getDeclName ().getBaseName (),
4677+ Impl.importSourceLoc (decl->getLocation ()), genericParams, dc);
46734678 alias->setUnderlyingType (underlyingType);
46744679 alias->setGenericEnvironment (genericEnv);
46754680
4676- // Record that this is the Swift 2 version of this declaration.
4677- Impl.ImportedDecls [{decl->getCanonicalDecl (), ImportNameVersion::Swift2}] =
4678- alias;
4679-
4680- // Mark it as the Swift 2 variant.
4681+ // Record that this is the official version of this declaration.
4682+ Impl.ImportedDecls [{decl->getCanonicalDecl (), getVersion ()}] = alias;
46814683 markAsVariant (alias, correctSwiftName);
46824684 return alias;
46834685}
@@ -6516,7 +6518,7 @@ getSwiftNameFromClangName(StringRef replacement) {
65166518 if (!clangDecl)
65176519 return " " ;
65186520
6519- auto importedName = importFullName (clangDecl, ImportNameVersion::Swift3 );
6521+ auto importedName = importFullName (clangDecl, CurrentVersion );
65206522 if (!importedName)
65216523 return " " ;
65226524
@@ -6758,7 +6760,7 @@ ClangImporter::Implementation::importDeclImpl(const clang::NamedDecl *ClangDecl,
67586760 Result = converter.Visit (ClangDecl);
67596761 HadForwardDeclaration = converter.hadForwardDeclaration ();
67606762 }
6761- if (!Result && version > ImportNameVersion::Swift2 ) {
6763+ if (!Result && version == CurrentVersion ) {
67626764 // If we couldn't import this Objective-C entity, determine
67636765 // whether it was a required member of a protocol.
67646766 bool hasMissingRequiredMember = false ;
@@ -7568,7 +7570,7 @@ ClangImporter::Implementation::getSpecialTypedefKind(clang::TypedefNameDecl *dec
75687570
75697571Identifier
75707572ClangImporter::getEnumConstantName (const clang::EnumConstantDecl *enumConstant){
7571- return Impl.importFullName (enumConstant, ImportNameVersion::Swift3 )
7573+ return Impl.importFullName (enumConstant, Impl. CurrentVersion )
75727574 .getDeclName ()
75737575 .getBaseName ();
75747576}
0 commit comments