@@ -2041,10 +2041,11 @@ namespace {
2041
2041
decl->setImplicit ();
2042
2042
}
2043
2043
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);
2048
2049
2049
2050
// / Create a swift_newtype struct corresponding to a typedef. Returns
2050
2051
// / nullptr if unable.
@@ -2062,7 +2063,8 @@ namespace {
2062
2063
// If we've been asked to produce a Swift 2 stub, handle it via a
2063
2064
// typealias.
2064
2065
if (correctSwiftName)
2065
- return importSwift2TypeAlias (Decl, importedName, *correctSwiftName);
2066
+ return importCompatibilityTypeAlias (Decl, importedName,
2067
+ *correctSwiftName);
2066
2068
2067
2069
Type SwiftType;
2068
2070
if (Decl->getDeclContext ()->getRedeclContext ()->isTranslationUnit ()) {
@@ -2277,7 +2279,8 @@ namespace {
2277
2279
// If we've been asked to produce a Swift 2 stub, handle it via a
2278
2280
// typealias.
2279
2281
if (correctSwiftName)
2280
- return importSwift2TypeAlias (decl, importedName, *correctSwiftName);
2282
+ return importCompatibilityTypeAlias (decl, importedName,
2283
+ *correctSwiftName);
2281
2284
2282
2285
auto dc =
2283
2286
Impl.importDeclContextOf (decl, importedName.getEffectiveContext ());
@@ -2693,7 +2696,8 @@ namespace {
2693
2696
// If we've been asked to produce a Swift 2 stub, handle it via a
2694
2697
// typealias.
2695
2698
if (correctSwiftName)
2696
- return importSwift2TypeAlias (decl, importedName, *correctSwiftName);
2699
+ return importCompatibilityTypeAlias (decl, importedName,
2700
+ *correctSwiftName);
2697
2701
2698
2702
auto dc =
2699
2703
Impl.importDeclContextOf (decl, importedName.getEffectiveContext ());
@@ -3957,7 +3961,8 @@ namespace {
3957
3961
// If we've been asked to produce a Swift 2 stub, handle it via a
3958
3962
// typealias.
3959
3963
if (correctSwiftName)
3960
- return importSwift2TypeAlias (decl, importedName, *correctSwiftName);
3964
+ return importCompatibilityTypeAlias (decl, importedName,
3965
+ *correctSwiftName);
3961
3966
3962
3967
Identifier name = importedName.getDeclName ().getBaseName ();
3963
3968
@@ -4092,7 +4097,8 @@ namespace {
4092
4097
// If we've been asked to produce a Swift 2 stub, handle it via a
4093
4098
// typealias.
4094
4099
if (correctSwiftName)
4095
- return importSwift2TypeAlias (decl, importedName, *correctSwiftName);
4100
+ return importCompatibilityTypeAlias (decl, importedName,
4101
+ *correctSwiftName);
4096
4102
4097
4103
auto name = importedName.getDeclName ().getBaseName ();
4098
4104
@@ -4630,9 +4636,10 @@ SwiftDeclConverter::importCFClassType(const clang::TypedefNameDecl *decl,
4630
4636
return theClass;
4631
4637
}
4632
4638
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) {
4636
4643
// Import the referenced declaration. If it doesn't come in as a type,
4637
4644
// we don't care.
4638
4645
auto importedDecl = Impl.importDecl (decl, getActiveSwiftVersion ());
@@ -4665,19 +4672,14 @@ Decl *SwiftDeclConverter::importSwift2TypeAlias(const clang::NamedDecl *decl,
4665
4672
4666
4673
// Create the type alias.
4667
4674
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);
4673
4678
alias->setUnderlyingType (underlyingType);
4674
4679
alias->setGenericEnvironment (genericEnv);
4675
4680
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;
4681
4683
markAsVariant (alias, correctSwiftName);
4682
4684
return alias;
4683
4685
}
0 commit comments