From e9a3218a650c15e314916bde4dee30c4e7844155 Mon Sep 17 00:00:00 2001 From: Holly Borla Date: Mon, 12 Jun 2023 23:07:21 -0700 Subject: [PATCH] [GenericEnvironment] Don't apply outer context substitutions before type.subst in mapTypeIntoContext. The outer context substitutions are already applied when invoking QueryInterfaceTypeSubstitutions. Applying the context substitutions before subst also causes problems because QueryInterfaceTypeSubstitutions will return a null type if given an archetype, which manifested with opened pack element environments. (cherry picked from commit d6fe62542af18b3fa7bbbd91edc1b88d409b96eb) --- lib/AST/GenericEnvironment.cpp | 1 - test/Constraints/pack-expansion-expressions.swift | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/AST/GenericEnvironment.cpp b/lib/AST/GenericEnvironment.cpp index 88957a6abe737..aecf75826e670 100644 --- a/lib/AST/GenericEnvironment.cpp +++ b/lib/AST/GenericEnvironment.cpp @@ -635,7 +635,6 @@ Type GenericEnvironment::mapTypeIntoContext( assert((!type->hasArchetype() || type->hasLocalArchetype()) && "already have a contextual type"); - type = maybeApplyOuterContextSubstitutions(type); Type result = type.subst(QueryInterfaceTypeSubstitutions(this), lookupConformance, SubstFlags::AllowLoweredTypes | diff --git a/test/Constraints/pack-expansion-expressions.swift b/test/Constraints/pack-expansion-expressions.swift index 22de5f7b3b5df..b47a94b2bec48 100644 --- a/test/Constraints/pack-expansion-expressions.swift +++ b/test/Constraints/pack-expansion-expressions.swift @@ -552,3 +552,11 @@ do { _ = (repeat overloaded(1, each a)) } } + +func configure( + _ item: T, + with configuration: repeat (ReferenceWritableKeyPath, each Element) +) -> T { + repeat item[keyPath: (each configuration).0] = (each configuration).1 + return item +}