@@ -5188,18 +5188,6 @@ Decl *SwiftDeclConverter::importCompatibilityTypeAlias(
5188
5188
if (!typeDecl)
5189
5189
return nullptr ;
5190
5190
5191
- // Deliberately use an UnboundGenericType to avoid having to translate over
5192
- // generic parameters.
5193
- Type underlyingType;
5194
- if (auto *underlyingAlias = dyn_cast<TypeAliasDecl>(typeDecl)) {
5195
- if (underlyingAlias->isGeneric ())
5196
- underlyingType = underlyingAlias->getUnboundGenericType ();
5197
- else
5198
- underlyingType = Impl.getSugaredTypeReference (underlyingAlias);
5199
- } else {
5200
- underlyingType = cast<NominalTypeDecl>(typeDecl)->getDeclaredType ();
5201
- }
5202
-
5203
5191
auto dc = Impl.importDeclContextOf (decl,
5204
5192
compatibilityName.getEffectiveContext ());
5205
5193
if (!dc)
@@ -5210,7 +5198,15 @@ Decl *SwiftDeclConverter::importCompatibilityTypeAlias(
5210
5198
decl, AccessLevel::Public, Impl.importSourceLoc (decl->getLocStart ()),
5211
5199
SourceLoc (), compatibilityName.getDeclName ().getBaseIdentifier (),
5212
5200
Impl.importSourceLoc (decl->getLocation ()), /* generic params*/ nullptr , dc);
5213
- alias->setUnderlyingType (underlyingType);
5201
+
5202
+ auto *GTD = dyn_cast<GenericTypeDecl>(typeDecl);
5203
+ if (GTD && !isa<ProtocolDecl>(GTD)) {
5204
+ alias->setGenericEnvironment (GTD->getGenericEnvironment ());
5205
+ if (GTD->isGeneric ())
5206
+ alias->setGenericParams (GTD->getGenericParams ()->clone (alias));
5207
+ }
5208
+
5209
+ alias->setUnderlyingType (Impl.getSugaredTypeReference (typeDecl));
5214
5210
5215
5211
// Record that this is the official version of this declaration.
5216
5212
Impl.ImportedDecls [{decl->getCanonicalDecl (), getVersion ()}] = alias;
0 commit comments