From 672135b0533d51b13c51331bc131a64d289612e1 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 28 Aug 2025 15:59:25 -0400 Subject: [PATCH 1/2] AST: Remove old hack that appears to be obsolete The FIXME was originally introduced in 2017 by commit c0805a2bc84ed8098374a10451ba859ad4885edc. Good riddance! --- lib/AST/SubstitutionMap.cpp | 14 -------------- .../174f557922f5c3cc.swift | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) rename validation-test/{compiler_crashers_2 => compiler_crashers_2_fixed}/174f557922f5c3cc.swift (89%) diff --git a/lib/AST/SubstitutionMap.cpp b/lib/AST/SubstitutionMap.cpp index c5588a9767b15..8204ab20f5ad9 100644 --- a/lib/AST/SubstitutionMap.cpp +++ b/lib/AST/SubstitutionMap.cpp @@ -283,20 +283,6 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const { // For each remaining step, project an associated conformance. while (iter != path.end()) { - // FIXME: Remove this hack. It is unsound, because we may not have diagnosed - // anything but still end up with an ErrorType in the AST. - if (conformance.isConcrete()) { - auto concrete = conformance.getConcrete(); - if (auto normal = dyn_cast(concrete->getRootConformance())) { - if (!normal->hasComputedAssociatedConformances()) { - if (proto->getASTContext().evaluator.hasActiveRequest( - ResolveTypeWitnessesRequest{normal})) { - return ProtocolConformanceRef::forInvalid(); - } - } - } - } - const auto step = *iter++; conformance = conformance.getAssociatedConformance(step.first, step.second); } diff --git a/validation-test/compiler_crashers_2/174f557922f5c3cc.swift b/validation-test/compiler_crashers_2_fixed/174f557922f5c3cc.swift similarity index 89% rename from validation-test/compiler_crashers_2/174f557922f5c3cc.swift rename to validation-test/compiler_crashers_2_fixed/174f557922f5c3cc.swift index bb3d379def568..72c539f629e14 100644 --- a/validation-test/compiler_crashers_2/174f557922f5c3cc.swift +++ b/validation-test/compiler_crashers_2_fixed/174f557922f5c3cc.swift @@ -1,5 +1,5 @@ // {"kind":"typecheck","original":"2fdf1565","signature":"(anonymous namespace)::TypeSubstituter::transformDependentMemberType(swift::DependentMemberType*, swift::TypePosition)","stackOverflow":true} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s protocol a { typealias b = c associatedtype d: b From 161c6f5692f8b1ef84aead6a1c61a6daeaa21a68 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 28 Aug 2025 11:57:23 -0400 Subject: [PATCH 2/2] Revert "Revert "AST: Re-enable TypeSubstituter::transformSubstitutionMap() again"" This reverts commit 47684cb2a1527eb419cd2104288671e3a7264ac8. --- lib/AST/TypeSubstitution.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/AST/TypeSubstitution.cpp b/lib/AST/TypeSubstitution.cpp index 2c04ea3de0517..ab8d1ddfeaf5c 100644 --- a/lib/AST/TypeSubstitution.cpp +++ b/lib/AST/TypeSubstitution.cpp @@ -358,7 +358,7 @@ class TypeSubstituter : public TypeTransform { std::optional transformLocalArchetypeType(LocalArchetypeType *local, TypePosition pos); - // SubstitutionMap transformSubstitutionMap(SubstitutionMap subs); + SubstitutionMap transformSubstitutionMap(SubstitutionMap subs); CanType transformSILField(CanType fieldTy, TypePosition pos); }; @@ -474,13 +474,10 @@ Type TypeSubstituter::transformDependentMemberType(DependentMemberType *dependen return result; } -// FIXME: This exposes a scalability issue; see test/SILGen/opaque_result_type_slow.swift. -/* SubstitutionMap TypeSubstituter::transformSubstitutionMap(SubstitutionMap subs) { // FIXME: Take level into account? Move level down into IFS? return subs.subst(IFS); } -*/ CanType TypeSubstituter::transformSILField(CanType fieldTy, TypePosition pos) { // Type substitution does not walk into the SILBoxType's field types, because