Skip to content

Commit f38b90e

Browse files
committed
Sema: Remove obsolete cycle-breaking hack
1 parent 91fd5f8 commit f38b90e

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2837,7 +2837,6 @@ AllMembersRequest::evaluate(
28372837
}
28382838

28392839
bool TypeChecker::isPassThroughTypealias(TypeAliasDecl *typealias,
2840-
Type underlyingType,
28412840
NominalTypeDecl *nominal) {
28422841
// Pass-through only makes sense when the typealias refers to a nominal
28432842
// type.
@@ -2872,7 +2871,8 @@ bool TypeChecker::isPassThroughTypealias(TypeAliasDecl *typealias,
28722871
// If neither is generic at this level, we have a pass-through typealias.
28732872
if (!typealias->isGeneric()) return true;
28742873

2875-
auto boundGenericType = underlyingType->getAs<BoundGenericType>();
2874+
auto boundGenericType = typealias->getUnderlyingType()
2875+
->getAs<BoundGenericType>();
28762876
if (!boundGenericType) return false;
28772877

28782878
// If our arguments line up with our innermost generic parameters, it's
@@ -2919,24 +2919,13 @@ ExtendedTypeRequest::evaluate(Evaluator &eval, ExtensionDecl *ext) const {
29192919
// Hack to allow extending a generic typealias.
29202920
if (auto *unboundGeneric = extendedType->getAs<UnboundGenericType>()) {
29212921
if (auto *aliasDecl = dyn_cast<TypeAliasDecl>(unboundGeneric->getDecl())) {
2922-
// Nested Hack to break cycles if this is called before validation has
2923-
// finished.
2924-
if (aliasDecl->hasInterfaceType()) {
2925-
auto extendedNominal =
2926-
aliasDecl->getDeclaredInterfaceType()->getAnyNominal();
2927-
if (extendedNominal)
2928-
return TypeChecker::isPassThroughTypealias(
2929-
aliasDecl, aliasDecl->getUnderlyingType(), extendedNominal)
2930-
? extendedType
2931-
: extendedNominal->getDeclaredType();
2932-
} else {
2933-
if (auto ty = aliasDecl->getStructuralType()
2934-
->getAs<NominalOrBoundGenericNominalType>())
2935-
return TypeChecker::isPassThroughTypealias(aliasDecl, ty,
2936-
ty->getDecl())
2937-
? extendedType
2938-
: ty->getDecl()->getDeclaredType();
2939-
}
2922+
auto extendedNominal =
2923+
aliasDecl->getUnderlyingType()->getAnyNominal();
2924+
if (extendedNominal)
2925+
return TypeChecker::isPassThroughTypealias(
2926+
aliasDecl, extendedNominal)
2927+
? extendedType
2928+
: extendedNominal->getDeclaredType();
29402929
}
29412930
}
29422931

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,7 @@ static void collectAdditionalExtensionRequirements(
530530

531531
// If we have a passthrough typealias, add the requirements from its
532532
// generic signature.
533-
if (typealias && TypeChecker::isPassThroughTypealias(
534-
typealias, typealias->getUnderlyingType(), nominal)) {
533+
if (typealias && TypeChecker::isPassThroughTypealias(typealias, nominal)) {
535534
for (auto req : typealias->getGenericSignature().getRequirements())
536535
sameTypeReqs.push_back(req);
537536
}

lib/Sema/TypeChecker.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,7 @@ Type substMemberTypeWithBase(ModuleDecl *module, TypeDecl *member, Type baseTy,
341341
/// typealias GX2<A> = X<A, A>
342342
/// typealias GX3<A, B> = X<B, A>
343343
/// \endcode
344-
bool isPassThroughTypealias(TypeAliasDecl *typealias, Type underlyingType,
345-
NominalTypeDecl *nominal);
344+
bool isPassThroughTypealias(TypeAliasDecl *typealias, NominalTypeDecl *nominal);
346345

347346
/// Determine whether one type is a subtype of another.
348347
///

0 commit comments

Comments
 (0)