diff --git a/SwiftCompilerSources/Sources/AST/GenericSignature.swift b/SwiftCompilerSources/Sources/AST/GenericSignature.swift index 64b858e9b4bd2..f7d6b4d8da2ab 100644 --- a/SwiftCompilerSources/Sources/AST/GenericSignature.swift +++ b/SwiftCompilerSources/Sources/AST/GenericSignature.swift @@ -30,8 +30,8 @@ public struct GenericSignature: CustomStringConvertible, NoReflectionChildren { TypeArray(bridged: bridged.getGenericParams()) } - public func mapTypeIntoContext(_ type: Type) -> Type { - Type(bridged: bridged.mapTypeIntoContext(type.bridged)) + public func mapTypeIntoEnvironment(_ type: Type) -> Type { + Type(bridged: bridged.mapTypeIntoEnvironment(type.bridged)) } public var isEmpty: Bool { bridged.impl == nil } diff --git a/SwiftCompilerSources/Sources/SIL/Function.swift b/SwiftCompilerSources/Sources/SIL/Function.swift index a500cb63befaf..f3f7ef2974d1e 100644 --- a/SwiftCompilerSources/Sources/SIL/Function.swift +++ b/SwiftCompilerSources/Sources/SIL/Function.swift @@ -86,8 +86,8 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash SubstitutionMap(bridged: bridged.getForwardingSubstitutionMap()) } - public func mapTypeIntoContext(_ type: AST.`Type`) -> AST.`Type` { - return AST.`Type`(bridged: bridged.mapTypeIntoContext(type.bridged)) + public func mapTypeIntoEnvironment(_ type: AST.`Type`) -> AST.`Type` { + return AST.`Type`(bridged: bridged.mapTypeIntoEnvironment(type.bridged)) } /// Returns true if the function is a definition and not only an external declaration. diff --git a/SwiftCompilerSources/Sources/SIL/Type.swift b/SwiftCompilerSources/Sources/SIL/Type.swift index 1cf1f14e3da38..0bc78d1ab6fd9 100644 --- a/SwiftCompilerSources/Sources/SIL/Type.swift +++ b/SwiftCompilerSources/Sources/SIL/Type.swift @@ -144,7 +144,7 @@ public struct Type : TypeProperties, CustomStringConvertible, NoReflectionChildr public var hasValidSignatureForEmbedded: Bool { let genericSignature = invocationGenericSignatureOfFunction for genParam in genericSignature.genericParameters { - let mappedParam = genericSignature.mapTypeIntoContext(genParam) + let mappedParam = genericSignature.mapTypeIntoEnvironment(genParam) if mappedParam.isArchetype && !mappedParam.archetypeRequiresClass { return false } diff --git a/include/swift/AST/ASTBridging.h b/include/swift/AST/ASTBridging.h index 946116e750dc2..e529082f034a8 100644 --- a/include/swift/AST/ASTBridging.h +++ b/include/swift/AST/ASTBridging.h @@ -3074,7 +3074,7 @@ struct BridgedGenericSignature { BRIDGED_INLINE swift::GenericSignature unbridged() const; BridgedOwnedString getDebugDescription() const; SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTTypeArray getGenericParams() const; - SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType mapTypeIntoContext(BridgedASTType type) const; + SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType mapTypeIntoEnvironment(BridgedASTType type) const; }; struct BridgedFingerprint { diff --git a/include/swift/AST/ASTBridgingImpl.h b/include/swift/AST/ASTBridgingImpl.h index 4b19480088f9a..aa2bf1dbbd9fd 100644 --- a/include/swift/AST/ASTBridgingImpl.h +++ b/include/swift/AST/ASTBridgingImpl.h @@ -869,8 +869,8 @@ BridgedASTTypeArray BridgedGenericSignature::getGenericParams() const { return {unbridged().getGenericParams()}; } -BridgedASTType BridgedGenericSignature::mapTypeIntoContext(BridgedASTType type) const { - return {unbridged().getGenericEnvironment()->mapTypeIntoContext(type.unbridged()).getPointer()}; +BridgedASTType BridgedGenericSignature::mapTypeIntoEnvironment(BridgedASTType type) const { + return {unbridged().getGenericEnvironment()->mapTypeIntoEnvironment(type.unbridged()).getPointer()}; } //===----------------------------------------------------------------------===// diff --git a/include/swift/AST/AnyFunctionRef.h b/include/swift/AST/AnyFunctionRef.h index 3bcfbe1e6023e..9cd4597d8efac 100644 --- a/include/swift/AST/AnyFunctionRef.h +++ b/include/swift/AST/AnyFunctionRef.h @@ -96,7 +96,7 @@ class AnyFunctionRef { Type getBodyResultType() const { if (auto *AFD = TheFunction.dyn_cast()) { if (auto *FD = dyn_cast(AFD)) - return FD->mapTypeIntoContext(FD->getResultInterfaceType()); + return FD->mapTypeIntoEnvironment(FD->getResultInterfaceType()); return TupleType::getEmpty(AFD->getASTContext()); } return cast(TheFunction)->getResultType(); @@ -308,7 +308,7 @@ class AnyFunctionRef { auto valueTy = AD->getStorage()->getValueInterfaceType() ->getReferenceStorageReferent(); if (mapIntoContext) - valueTy = AD->mapTypeIntoContext(valueTy); + valueTy = AD->mapTypeIntoEnvironment(valueTy); YieldTypeFlags flags(isYieldingMutableAccessor(AD->getAccessorKind()) ? ParamSpecifier::InOut : ParamSpecifier::LegacyShared); diff --git a/include/swift/AST/DeclContext.h b/include/swift/AST/DeclContext.h index b7c52ee785143..d5fb128eaf2e7 100644 --- a/include/swift/AST/DeclContext.h +++ b/include/swift/AST/DeclContext.h @@ -441,7 +441,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext GenericEnvironment *getGenericEnvironmentOfContext() const; /// Map an interface type to a contextual type within this context. - Type mapTypeIntoContext(Type type) const; + Type mapTypeIntoEnvironment(Type type) const; /// Returns this or the first local parent context, or nullptr if it is not /// contained in one. diff --git a/include/swift/AST/GenericEnvironment.h b/include/swift/AST/GenericEnvironment.h index b5578631bb535..f1809776338fc 100644 --- a/include/swift/AST/GenericEnvironment.h +++ b/include/swift/AST/GenericEnvironment.h @@ -75,10 +75,10 @@ struct ElementEnvironmentData { /// Describes the mapping between archetypes and interface types for the /// generic parameters of a DeclContext. /// -/// The most frequently used method here is mapTypeIntoContext(), which +/// The most frequently used method here is mapTypeIntoEnvironment(), which /// maps an interface type to a type written in terms of the generic /// environment's archetypes; to go in the other direction, use -/// TypeBase::mapTypeOutOfContext(). +/// TypeBase::mapTypeOutOfEnvironment(). /// class alignas(1 << DeclAlignInBits) GenericEnvironment final : private llvm::TrailingObjects< @@ -279,14 +279,14 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final Type maybeApplyOuterContextSubstitutions(Type type) const; /// Map an interface type to a contextual type. - static Type mapTypeIntoContext(GenericEnvironment *genericEnv, + static Type mapTypeIntoEnvironment(GenericEnvironment *genericEnv, Type type); /// Map an interface type to a contextual type. - Type mapTypeIntoContext(Type type) const; + Type mapTypeIntoEnvironment(Type type) const; /// Map a generic parameter type to a contextual type. - Type mapTypeIntoContext(GenericTypeParamType *type) const; + Type mapTypeIntoEnvironment(GenericTypeParamType *type) const; /// Map a type parameter type to a contextual type. Type getOrCreateArchetypeFromInterfaceType(Type depType); @@ -327,7 +327,7 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final /// /// This operation will also reabstract dependent types according to the /// abstraction level of their associated type requirements. - SILType mapTypeIntoContext(SILModule &M, SILType type) const; + SILType mapTypeIntoEnvironment(SILModule &M, SILType type) const; /// Returns a substitution map that sends every generic parameter to its /// corresponding archetype in this generic environment. diff --git a/include/swift/AST/ProtocolConformanceRef.h b/include/swift/AST/ProtocolConformanceRef.h index f7fde1e87b8a1..08c406a13435a 100644 --- a/include/swift/AST/ProtocolConformanceRef.h +++ b/include/swift/AST/ProtocolConformanceRef.h @@ -199,7 +199,7 @@ class ProtocolConformanceRef { ProtocolConformanceRef subst(InFlightSubstitution &IFS) const; /// Map contextual types to interface types in the conformance. - ProtocolConformanceRef mapConformanceOutOfContext() const; + ProtocolConformanceRef mapConformanceOutOfEnvironment() const; /// Look up the type witness for an associated type declaration in this /// conformance. diff --git a/include/swift/AST/SubstitutionMap.h b/include/swift/AST/SubstitutionMap.h index 868d59ef265b7..816d7d82c04b4 100644 --- a/include/swift/AST/SubstitutionMap.h +++ b/include/swift/AST/SubstitutionMap.h @@ -209,7 +209,7 @@ class SubstitutionMap { /// Swap archetypes in the substitution map's replacement types with their /// interface types. - SubstitutionMap mapReplacementTypesOutOfContext() const; + SubstitutionMap mapReplacementTypesOutOfEnvironment() const; /// Verify that the conformances stored in this substitution map match the /// replacement types provided. diff --git a/include/swift/AST/TypeTransform.h b/include/swift/AST/TypeTransform.h index a1558d15a54c3..ff18afac60e8b 100644 --- a/include/swift/AST/TypeTransform.h +++ b/include/swift/AST/TypeTransform.h @@ -184,7 +184,7 @@ case TypeKind::Id: auto *newEnv = GenericEnvironment::forOpenedExistential( genericSig, existentialTy, newSubMap, uuid); - return newEnv->mapTypeIntoContext(local->getInterfaceType()); + return newEnv->mapTypeIntoEnvironment(local->getInterfaceType()); } case TypeKind::ElementArchetype: { diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h index 1b4a9b2571b09..b3cb7f8eff60a 100644 --- a/include/swift/AST/Types.h +++ b/include/swift/AST/Types.h @@ -842,7 +842,7 @@ class alignas(1 << TypeAlignInBits) TypeBase Type addCurriedSelfType(const DeclContext *dc); /// Map a contextual type to an interface type. - Type mapTypeOutOfContext(); + Type mapTypeOutOfEnvironment(); /// Compute and return the set of type variables that occur within this /// type. @@ -4774,8 +4774,8 @@ class SILParameterInfo { return getWithInterfaceType(fn(getInterfaceType())); } - SILParameterInfo mapTypeOutOfContext() const { - return getWithInterfaceType(getInterfaceType()->mapTypeOutOfContext() + SILParameterInfo mapTypeOutOfEnvironment() const { + return getWithInterfaceType(getInterfaceType()->mapTypeOutOfEnvironment() ->getCanonicalType()); } @@ -5047,8 +5047,8 @@ class SILResultInfo { return getWithInterfaceType(fn(getInterfaceType())); } - SILResultInfo mapTypeOutOfContext() const { - return getWithInterfaceType(getInterfaceType()->mapTypeOutOfContext() + SILResultInfo mapTypeOutOfEnvironment() const { + return getWithInterfaceType(getInterfaceType()->mapTypeOutOfEnvironment() ->getCanonicalType()); } @@ -5114,8 +5114,8 @@ class SILYieldInfo : public SILParameterInfo { return getWithInterfaceType(fn(getInterfaceType())); } - SILYieldInfo mapTypeOutOfContext() const { - return getWithInterfaceType(getInterfaceType()->mapTypeOutOfContext() + SILYieldInfo mapTypeOutOfEnvironment() const { + return getWithInterfaceType(getInterfaceType()->mapTypeOutOfEnvironment() ->getCanonicalType()); } diff --git a/include/swift/SIL/SILBridging.h b/include/swift/SIL/SILBridging.h index 76c5d345898b2..3c1151f3b46f8 100644 --- a/include/swift/SIL/SILBridging.h +++ b/include/swift/SIL/SILBridging.h @@ -536,7 +536,7 @@ struct BridgedFunction { SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedCanType getLoweredFunctionTypeInContext() const; SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedGenericSignature getGenericSignature() const; SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getForwardingSubstitutionMap() const; - SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType mapTypeIntoContext(BridgedASTType ty) const; + SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType mapTypeIntoEnvironment(BridgedASTType ty) const; SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedBasicBlock getFirstBlock() const; SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedBasicBlock getLastBlock() const; SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclRef getDeclRef() const; diff --git a/include/swift/SIL/SILBridgingImpl.h b/include/swift/SIL/SILBridgingImpl.h index 6ffae27431580..f38feab6e6c46 100644 --- a/include/swift/SIL/SILBridgingImpl.h +++ b/include/swift/SIL/SILBridgingImpl.h @@ -781,8 +781,8 @@ BridgedSubstitutionMap BridgedFunction::getForwardingSubstitutionMap() const { return {getFunction()->getForwardingSubstitutionMap()}; } -BridgedASTType BridgedFunction::mapTypeIntoContext(BridgedASTType ty) const { - return {getFunction()->mapTypeIntoContext(ty.unbridged()).getPointer()}; +BridgedASTType BridgedFunction::mapTypeIntoEnvironment(BridgedASTType ty) const { + return {getFunction()->mapTypeIntoEnvironment(ty.unbridged()).getPointer()}; } OptionalBridgedBasicBlock BridgedFunction::getFirstBlock() const { diff --git a/include/swift/SIL/SILCloner.h b/include/swift/SIL/SILCloner.h index 621ac4cdefff8..29029b1634e1d 100644 --- a/include/swift/SIL/SILCloner.h +++ b/include/swift/SIL/SILCloner.h @@ -71,7 +71,7 @@ struct SubstitutionMapWithLocalArchetypes { auto *newEnv = found->second; auto interfaceTy = local->getInterfaceType(); - return newEnv->mapTypeIntoContext(interfaceTy); + return newEnv->mapTypeIntoEnvironment(interfaceTy); } if (SubsMap) @@ -89,7 +89,7 @@ struct SubstitutionMapWithLocalArchetypes { if (SubsMap) { if (origType->is() || origType->is()) { - origType = origType->mapTypeOutOfContext(); + origType = origType->mapTypeOutOfEnvironment(); } return SubsMap->lookupConformance( diff --git a/include/swift/SIL/SILFunction.h b/include/swift/SIL/SILFunction.h index 6c544f6db17bc..e1eab346091b1 100644 --- a/include/swift/SIL/SILFunction.h +++ b/include/swift/SIL/SILFunction.h @@ -1357,12 +1357,12 @@ class SILFunction /// Map the given type, which is based on an interface SILFunctionType and may /// therefore be dependent, to a type based on the context archetypes of this /// SILFunction. - Type mapTypeIntoContext(Type type) const; + Type mapTypeIntoEnvironment(Type type) const; /// Map the given type, which is based on an interface SILFunctionType and may /// therefore be dependent, to a type based on the context archetypes of this /// SILFunction. - SILType mapTypeIntoContext(SILType type) const; + SILType mapTypeIntoEnvironment(SILType type) const; /// Converts the given function definition to a declaration. void convertToDeclaration() { diff --git a/include/swift/SIL/SILType.h b/include/swift/SIL/SILType.h index 76c7baf0f6c49..baddb63dcb85e 100644 --- a/include/swift/SIL/SILType.h +++ b/include/swift/SIL/SILType.h @@ -872,12 +872,12 @@ class SILType { SILType removingAnyMoveOnlyWrapping(const SILFunction *fn); /// Returns a SILType with any archetypes mapped out of context. - SILType mapTypeOutOfContext() const; + SILType mapTypeOutOfEnvironment() const; /// Given a lowered type (but without any particular value category), /// map it out of its current context. Equivalent to - /// SILType::getPrimitiveObjectType(type).mapTypeOutOfContext().getASTType(). - static CanType mapTypeOutOfContext(CanType type); + /// SILType::getPrimitiveObjectType(type).mapTypeOutOfEnvironment().getASTType(). + static CanType mapTypeOutOfEnvironment(CanType type); /// Given two SIL types which are representations of the same type, /// check whether they have an abstraction difference. diff --git a/include/swift/SIL/TypeSubstCloner.h b/include/swift/SIL/TypeSubstCloner.h index fb7e5ac679570..af7d6eed56e2c 100644 --- a/include/swift/SIL/TypeSubstCloner.h +++ b/include/swift/SIL/TypeSubstCloner.h @@ -416,7 +416,7 @@ class TypeSubstCloner : public SILClonerWithScopes { }); } - SubsMap = SubsMap.mapReplacementTypesOutOfContext(); + SubsMap = SubsMap.mapReplacementTypesOutOfEnvironment(); } // One abstract function in the debug info can only have one set of variables @@ -427,7 +427,7 @@ class TypeSubstCloner : public SILClonerWithScopes { !SubsMap.getRecursiveProperties().hasTypeParameter()) return ParentFunction; - // Note that mapReplacementTypesOutOfContext() can't do anything for + // Note that mapReplacementTypesOutOfEnvironment() can't do anything for // opened existentials, and since archetypes can't be mangled, ignore // this case for now. if (SubsMap.getRecursiveProperties().hasLocalArchetype()) diff --git a/include/swift/SILOptimizer/Analysis/DifferentiableActivityAnalysis.h b/include/swift/SILOptimizer/Analysis/DifferentiableActivityAnalysis.h index 3b8ec8387219f..e2d5120360762 100644 --- a/include/swift/SILOptimizer/Analysis/DifferentiableActivityAnalysis.h +++ b/include/swift/SILOptimizer/Analysis/DifferentiableActivityAnalysis.h @@ -136,7 +136,7 @@ class DifferentiableActivityInfo { // Remap archetypes in the derivative generic signature, if it exists. if (type->hasArchetype()) { type = derivativeGenericSignature.getReducedType( - type->mapTypeOutOfContext()); + type->mapTypeOutOfEnvironment()); } // Look up conformance in the current module. auto lookupConformance = LookUpConformanceInModule(); diff --git a/include/swift/SILOptimizer/Differentiation/Common.h b/include/swift/SILOptimizer/Differentiation/Common.h index ec0b7784cbab9..3a63775658832 100644 --- a/include/swift/SILOptimizer/Differentiation/Common.h +++ b/include/swift/SILOptimizer/Differentiation/Common.h @@ -274,21 +274,21 @@ inline void createEntryArguments(SILFunction *f) { for (auto indResTy : conv.getIndirectSILResultTypes(f->getTypeExpansionContext())) { if (indResTy.hasArchetype()) - indResTy = indResTy.mapTypeOutOfContext(); - createFunctionArgument(f->mapTypeIntoContext(indResTy).getAddressType()); + indResTy = indResTy.mapTypeOutOfEnvironment(); + createFunctionArgument(f->mapTypeIntoEnvironment(indResTy).getAddressType()); } if (auto indErrorResTy = conv.getIndirectErrorResultType(f->getTypeExpansionContext())) { if (indErrorResTy.hasArchetype()) - indErrorResTy = indErrorResTy.mapTypeOutOfContext(); + indErrorResTy = indErrorResTy.mapTypeOutOfEnvironment(); createFunctionArgument( - f->mapTypeIntoContext(indErrorResTy).getAddressType()); + f->mapTypeIntoEnvironment(indErrorResTy).getAddressType()); } for (auto paramTy : conv.getParameterSILTypes(f->getTypeExpansionContext())) { if (paramTy.hasArchetype()) - paramTy = paramTy.mapTypeOutOfContext(); - createFunctionArgument(f->mapTypeIntoContext(paramTy)); + paramTy = paramTy.mapTypeOutOfEnvironment(); + createFunctionArgument(f->mapTypeIntoEnvironment(paramTy)); } } diff --git a/include/swift/SILOptimizer/Utils/Generics.h b/include/swift/SILOptimizer/Utils/Generics.h index 0dc4743ef3811..8b320ce92da27 100644 --- a/include/swift/SILOptimizer/Utils/Generics.h +++ b/include/swift/SILOptimizer/Utils/Generics.h @@ -342,7 +342,7 @@ class ReabstractionInfo { SILFunction *getNonSpecializedFunction() const { return Callee; } /// Map SIL type into a context of the specialized function. - SILType mapTypeIntoContext(SILType type) const; + SILType mapTypeIntoEnvironment(SILType type) const; SILModule &getModule() const { return *M; } diff --git a/include/swift/Sema/ConstraintSystem.h b/include/swift/Sema/ConstraintSystem.h index 29ef2ac059686..39fae6870932f 100644 --- a/include/swift/Sema/ConstraintSystem.h +++ b/include/swift/Sema/ConstraintSystem.h @@ -951,7 +951,7 @@ class FunctionArgApplyInfo { if (!interfaceFnTy) { // If the interface type isn't a function, then just return the resolved // parameter type. - return getParamType(lookThroughAutoclosure)->mapTypeOutOfContext(); + return getParamType(lookThroughAutoclosure)->mapTypeOutOfEnvironment(); } return getParamTypeImpl(interfaceFnTy, lookThroughAutoclosure); } diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index a883605557108..11ee2866f8bfb 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -5812,7 +5812,7 @@ CanExistentialArchetypeType ExistentialArchetypeType::get(CanType existential) { existentialSig.Generalization, UUID::fromTime()); return cast( - genericEnv->mapTypeIntoContext(existentialSig.SelfType) + genericEnv->mapTypeIntoEnvironment(existentialSig.SelfType) ->getCanonicalType()); } diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index 104ddd8a3a896..23c9019700934 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -261,7 +261,7 @@ std::string typeUSR(Type type) { return ""; if (type->hasArchetype()) { - type = type->mapTypeOutOfContext(); + type = type->mapTypeOutOfEnvironment(); } if (type->hasLocalArchetype()) { type = replaceLocalArchetypesWithExistentials(type); @@ -6821,7 +6821,7 @@ void GenericEnvironment::dump(raw_ostream &os) const { os << "Generic environment:\n"; for (auto gp : getGenericParams()) { gp->dump(os); - mapTypeIntoContext(gp)->dump(os); + mapTypeIntoEnvironment(gp)->dump(os); } os << "Generic parameters:\n"; for (auto paramTy : getGenericParams()) diff --git a/lib/AST/ASTMangler.cpp b/lib/AST/ASTMangler.cpp index 2e8fd65c2c0cc..9f55cb3a46ebe 100644 --- a/lib/AST/ASTMangler.cpp +++ b/lib/AST/ASTMangler.cpp @@ -392,7 +392,7 @@ std::string ASTMangler::mangleKeyPathGetterThunkHelper( // Subscripts can be generic, and different key paths could // capture the same subscript at different generic arguments. for (auto sub : subs.getReplacementTypes()) { - sub = sub->mapTypeOutOfContext(); + sub = sub->mapTypeOutOfEnvironment(); // FIXME: This seems wrong. We used to just mangle opened archetypes as // their interface type. Let's make that explicit now. @@ -428,7 +428,7 @@ std::string ASTMangler::mangleKeyPathSetterThunkHelper( // Subscripts can be generic, and different key paths could capture the same // subscript at different generic arguments. for (auto sub : subs.getReplacementTypes()) { - sub = sub->mapTypeOutOfContext(); + sub = sub->mapTypeOutOfEnvironment(); // FIXME: This seems wrong. We used to just mangle opened archetypes as // their interface type. Let's make that explicit now. @@ -464,7 +464,7 @@ std::string ASTMangler::mangleKeyPathAppliedMethodThunkHelper( // Methods can be generic, and different key paths could capture the same // method at different generic arguments. for (auto sub : subs.getReplacementTypes()) { - sub = sub->mapTypeOutOfContext(); + sub = sub->mapTypeOutOfEnvironment(); // FIXME: This seems wrong. We used to just mangle opened archetypes as // their interface type. Let's make that explicit now. @@ -498,7 +498,7 @@ std::string ASTMangler::mangleKeyPathUnappliedMethodThunkHelper( // Methods can be generic, and different key paths could capture the same // method at different generic arguments. for (auto sub : subs.getReplacementTypes()) { - sub = sub->mapTypeOutOfContext(); + sub = sub->mapTypeOutOfEnvironment(); // FIXME: This seems wrong. We used to just mangle opened archetypes as // their interface type. Let's make that explicit now. @@ -1961,7 +1961,7 @@ void ASTMangler::appendFlatGenericArgs(SubstitutionMap subs, for (auto replacement : subs.getReplacementTypes()) { if (replacement->hasArchetype()) - replacement = replacement->mapTypeOutOfContext(); + replacement = replacement->mapTypeOutOfEnvironment(); if (DWARFMangling) { appendType(replacement, sig, forDecl); } else { @@ -2023,7 +2023,7 @@ unsigned ASTMangler::appendBoundGenericArgs(DeclContext *dc, ++currentGenericParamIdx) { Type replacementType = replacements[currentGenericParamIdx]; if (replacementType->hasArchetype()) - replacementType = replacementType->mapTypeOutOfContext(); + replacementType = replacementType->mapTypeOutOfEnvironment(); appendType(replacementType, sig, forDecl); } @@ -2524,7 +2524,7 @@ void ASTMangler::appendOpaqueTypeArchetype(ArchetypeType *archetype, appendOperator("Qo", Index(genericParam->getIndex())); } else { auto *env = archetype->getGenericEnvironment(); - appendType(env->mapTypeIntoContext(interfaceType->getRootGenericParam()), + appendType(env->mapTypeIntoEnvironment(interfaceType->getRootGenericParam()), sig, forDecl); // Mangle associated types of opaque archetypes like dependent member @@ -4645,7 +4645,7 @@ void ASTMangler::appendConcreteProtocolConformance( // Conforming type. Type conformingType = conformance->getType(); if (conformingType->hasArchetype()) - conformingType = conformingType->mapTypeOutOfContext(); + conformingType = conformingType->mapTypeOutOfEnvironment(); appendType(conformingType->getReducedType(sig), sig); // Protocol conformance reference. @@ -4656,7 +4656,7 @@ void ASTMangler::appendConcreteProtocolConformance( forEachConditionalConformance(conformance, [&](Type substType, ProtocolConformanceRef substConf) -> bool { if (substType->hasArchetype()) - substType = substType->mapTypeOutOfContext(); + substType = substType->mapTypeOutOfEnvironment(); CanType canType = substType->getReducedType(sig); appendAnyProtocolConformance(sig, canType, substConf); appendListSeparator(firstRequirement); diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index 31f300f4aade9..f9d99543705cd 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -1182,7 +1182,7 @@ class PrintAST : public ASTVisitor { Type CurrentType = Options.TransformContext->getBaseType(); if (CurrentType && CurrentType->hasArchetype()) { // ExistentialArchetypeTypes get replaced by a GenericTypeParamType without a - // name in mapTypeOutOfContext. The GenericTypeParamType has no children + // name in mapTypeOutOfEnvironment. The GenericTypeParamType has no children // so we can't use it for TypeTransformContext. // To work around this, replace the ExistentialArchetypeType with the type of // the protocol itself. @@ -1190,7 +1190,7 @@ class PrintAST : public ASTVisitor { assert(Opened->isRoot()); CurrentType = Opened->getExistentialType(); } - CurrentType = CurrentType->mapTypeOutOfContext(); + CurrentType = CurrentType->mapTypeOutOfEnvironment(); } setCurrentType(CurrentType); } @@ -3538,7 +3538,7 @@ void PrintAST::visitExtensionDecl(ExtensionDecl *decl) { Options.TransformContext->isPrintingSynthesizedExtension()) { auto extendedType = Options.TransformContext->getBaseType(); if (extendedType->hasArchetype()) - extendedType = extendedType->mapTypeOutOfContext(); + extendedType = extendedType->mapTypeOutOfEnvironment(); printSynthesizedExtension(extendedType, decl); } else printExtension(decl); @@ -6503,14 +6503,14 @@ class TypePrinter : public TypeVisitorgetBaseType()) { auto printingType = T; if (currentType->hasArchetype()) - currentType = currentType->mapTypeOutOfContext(); + currentType = currentType->mapTypeOutOfEnvironment(); if (auto errorTy = printingType->getAs()) if (auto origTy = errorTy->getOriginalType()) printingType = origTy; if (printingType->hasArchetype()) - printingType = printingType->mapTypeOutOfContext(); + printingType = printingType->mapTypeOutOfEnvironment(); if (currentType->isEqual(printingType)) return; @@ -7499,7 +7499,7 @@ class TypePrinter : public TypeVisitorgetAs()) { if (Options.AlternativeTypeNames) { - auto archetypeTy = env->mapTypeIntoContext(paramTy)->getAs(); + auto archetypeTy = env->mapTypeIntoEnvironment(paramTy)->getAs(); if (archetypeTy) { auto found = Options.AlternativeTypeNames->find(CanType(archetypeTy)); if (found != Options.AlternativeTypeNames->end()) { @@ -7517,7 +7517,7 @@ class TypePrinter : public TypeVisitorcastTo(); if (auto *paramTy = memberTy->getBase()->getAs()) - printParentType(env->mapTypeIntoContext(paramTy)); + printParentType(env->mapTypeIntoEnvironment(paramTy)); else { printArchetypeCommon(memberTy->getBase(), env); Printer << "."; @@ -7693,7 +7693,7 @@ class TypePrinter : public TypeVisitorgetDeclContext()->mapTypeIntoContext( + auto archetypeType = decl->getDeclContext()->mapTypeIntoEnvironment( decl->getDeclaredInterfaceType())->castTo(); auto constraintType = archetypeType->getExistentialType(); if (auto *existentialType = constraintType->getAs()) diff --git a/lib/AST/ASTVerifier.cpp b/lib/AST/ASTVerifier.cpp index 2888fe022b9a9..e0a1a257881a5 100644 --- a/lib/AST/ASTVerifier.cpp +++ b/lib/AST/ASTVerifier.cpp @@ -688,7 +688,7 @@ class Verifier : public ASTWalker { // Mapping the archetype out and back in should produce the // same archetype. auto interfaceType = archetype->getInterfaceType(); - auto contextType = archetypeEnv->mapTypeIntoContext(interfaceType); + auto contextType = archetypeEnv->mapTypeIntoEnvironment(interfaceType); if (!contextType->isEqual(archetype)) { Out << "Archetype " << archetype->getString() << " does not appear" @@ -1101,7 +1101,7 @@ class Verifier : public ASTWalker { if (auto *FD = dyn_cast(func)) { resultType = FD->getResultInterfaceType(); - resultType = FD->mapTypeIntoContext(resultType); + resultType = FD->mapTypeIntoEnvironment(resultType); hasInOutResult = FD->getInterfaceType() ->castTo() ->getExtInfo() diff --git a/lib/AST/ActorIsolation.cpp b/lib/AST/ActorIsolation.cpp index 9c7f1816a86d4..8ec568592f115 100644 --- a/lib/AST/ActorIsolation.cpp +++ b/lib/AST/ActorIsolation.cpp @@ -20,7 +20,7 @@ using namespace swift; ActorIsolation ActorIsolation::forMainActor(ASTContext &ctx) { return ActorIsolation::forGlobalActor( - ctx.getMainActorType()->mapTypeOutOfContext()); + ctx.getMainActorType()->mapTypeOutOfEnvironment()); } // These constructors are defined out-of-line so that including ActorIsolation.h diff --git a/lib/AST/ConformanceLookup.cpp b/lib/AST/ConformanceLookup.cpp index aa26434073d08..8124ada22553d 100644 --- a/lib/AST/ConformanceLookup.cpp +++ b/lib/AST/ConformanceLookup.cpp @@ -960,7 +960,7 @@ bool TypeBase::isEscapable() { bool TypeBase::isEscapable(GenericSignature sig) { Type contextTy = this; if (sig) { - contextTy = sig.getGenericEnvironment()->mapTypeIntoContext(contextTy); + contextTy = sig.getGenericEnvironment()->mapTypeIntoEnvironment(contextTy); } return contextTy->isEscapable(); } @@ -978,7 +978,7 @@ bool TypeBase::isBitwiseCopyable() { bool TypeBase::isBitwiseCopyable(GenericSignature sig) { Type contextTy = this; if (sig) { - contextTy = sig.getGenericEnvironment()->mapTypeIntoContext(contextTy); + contextTy = sig.getGenericEnvironment()->mapTypeIntoEnvironment(contextTy); } return contextTy->isBitwiseCopyable(); } diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 7b6774729a8e0..dc2c050fb27b9 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -8037,7 +8037,7 @@ VarDecl::VarDecl(DeclKind kind, bool isStatic, VarDecl::Introducer introducer, } Type VarDecl::getTypeInContext() const { - return getDeclContext()->mapTypeIntoContext(getInterfaceType()); + return getDeclContext()->mapTypeIntoEnvironment(getInterfaceType()); } /// Translate an "is mutable" bit into a StorageMutability value. @@ -8911,7 +8911,7 @@ Type VarDecl::getPropertyWrapperInitValueInterfaceType() const { Type valueInterfaceTy = initInfo.getWrappedValuePlaceholder()->getType(); if (valueInterfaceTy->hasPrimaryArchetype()) - valueInterfaceTy = valueInterfaceTy->mapTypeOutOfContext(); + valueInterfaceTy = valueInterfaceTy->mapTypeOutOfEnvironment(); return valueInterfaceTy; } @@ -9221,7 +9221,7 @@ void ParamDecl::setDefaultArgumentKind(DefaultArgumentKind K) { /// Retrieve the type of 'self' for the given context. Type DeclContext::getSelfTypeInContext() const { - return mapTypeIntoContext(getSelfInterfaceType()); + return mapTypeIntoEnvironment(getSelfInterfaceType()); } TupleType *BuiltinTupleDecl::getTupleSelfType(const ExtensionDecl *owner) const { @@ -13047,7 +13047,7 @@ std::optional CatchNode::getThrownErrorTypeInContext(ASTContext &ctx) const { if (auto func = dyn_cast()) { if (auto thrownError = func->getEffectiveThrownErrorType()) - return func->mapTypeIntoContext(*thrownError); + return func->mapTypeIntoEnvironment(*thrownError); return std::nullopt; } diff --git a/lib/AST/DeclContext.cpp b/lib/AST/DeclContext.cpp index 272b3ff6b8a50..0d86426843241 100644 --- a/lib/AST/DeclContext.cpp +++ b/lib/AST/DeclContext.cpp @@ -104,7 +104,7 @@ VarDecl *DeclContext::getNonLocalVarDecl() const { Type DeclContext::getDeclaredTypeInContext() const { if (auto declaredType = getDeclaredInterfaceType()) - return mapTypeIntoContext(declaredType); + return mapTypeIntoEnvironment(declaredType); return Type(); } @@ -175,8 +175,8 @@ GenericEnvironment *DeclContext::getGenericEnvironmentOfContext() const { return nullptr; } -Type DeclContext::mapTypeIntoContext(Type type) const { - return GenericEnvironment::mapTypeIntoContext( +Type DeclContext::mapTypeIntoEnvironment(Type type) const { + return GenericEnvironment::mapTypeIntoEnvironment( getGenericEnvironmentOfContext(), type); } diff --git a/lib/AST/DistributedDecl.cpp b/lib/AST/DistributedDecl.cpp index 4569b29ee194b..2830ca90c27dd 100644 --- a/lib/AST/DistributedDecl.cpp +++ b/lib/AST/DistributedDecl.cpp @@ -588,7 +588,7 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn) // Act.ID == Self.ActorID GenericTypeParamDecl *ActParam = genericParams->getParams()[0]; auto ActConformance = lookupConformance( - mapTypeIntoContext(ActParam->getDeclaredInterfaceType()), + mapTypeIntoEnvironment(ActParam->getDeclaredInterfaceType()), C.getProtocol(KnownProtocolKind::DistributedActor)); if (ActConformance.isInvalid()) { return false; @@ -597,7 +597,7 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn) // --- Check: Err: Error GenericTypeParamDecl *ErrParam = genericParams->getParams()[1]; auto ErrConformance = lookupConformance( - mapTypeIntoContext(ErrParam->getDeclaredInterfaceType()), + mapTypeIntoEnvironment(ErrParam->getDeclaredInterfaceType()), C.getProtocol(KnownProtocolKind::Error)); if (ErrConformance.isInvalid()) { return false; @@ -660,9 +660,9 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn) } else if (ResParam) { assert(ResParam && "Non void function, yet no Res generic parameter found"); if (auto func = dyn_cast(this)) { - auto resultType = func->mapTypeIntoContext(func->getResultInterfaceType()) + auto resultType = func->mapTypeIntoEnvironment(func->getResultInterfaceType()) ->getMetatypeInstanceType(); - auto resultParamType = func->mapTypeIntoContext( + auto resultParamType = func->mapTypeIntoEnvironment( ResParam->getDeclaredInterfaceType()); // The result of the function must be the `Res` generic argument. if (!resultType->isEqual(resultParamType)) { @@ -853,7 +853,7 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const } auto argumentTy = argumentParam->getInterfaceType(); - auto argumentInContextTy = mapTypeIntoContext(argumentTy); + auto argumentInContextTy = mapTypeIntoEnvironment(argumentTy); if (argumentInContextTy->getAnyNominal() == C.getRemoteCallArgumentDecl()) { auto argGenericParams = argumentInContextTy->getStructOrBoundGenericStruct() ->getGenericParams()->getParams(); @@ -863,9 +863,9 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const // the of the RemoteCallArgument auto remoteCallArgValueGenericTy = - mapTypeIntoContext(argGenericParams[0]->getDeclaredInterfaceType()); + mapTypeIntoEnvironment(argGenericParams[0]->getDeclaredInterfaceType()); // expected (the from the recordArgument) - auto expectedGenericParamTy = mapTypeIntoContext( + auto expectedGenericParamTy = mapTypeIntoEnvironment( ArgumentParam->getDeclaredInterfaceType()); if (!remoteCallArgValueGenericTy->isEqual(expectedGenericParamTy)) { @@ -1005,10 +1005,10 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordReturnType() con // conforms_to: Argument Encodable // ... - auto resultType = func->mapTypeIntoContext(argumentParam->getInterfaceType()) + auto resultType = func->mapTypeIntoEnvironment(argumentParam->getInterfaceType()) ->getMetatypeInstanceType(); - auto resultParamType = func->mapTypeIntoContext( + auto resultParamType = func->mapTypeIntoEnvironment( ArgumentParam->getDeclaredInterfaceType()); // The result of the function must be the `Res` generic argument. @@ -1118,7 +1118,7 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordErrorType() cons // --- Check: Err: Error GenericTypeParamDecl *ErrParam = genericParams->getParams()[0]; auto ErrConformance = lookupConformance( - mapTypeIntoContext(ErrParam->getDeclaredInterfaceType()), + mapTypeIntoEnvironment(ErrParam->getDeclaredInterfaceType()), C.getProtocol(KnownProtocolKind::Error)); if (ErrConformance.isInvalid()) { return false; @@ -1216,9 +1216,9 @@ AbstractFunctionDecl::isDistributedTargetInvocationDecoderDecodeNextArgument() c // === Check generic parameters in detail // --- Check: Argument: SerializationRequirement GenericTypeParamDecl *ArgumentParam = genericParams->getParams()[0]; - auto resultType = func->mapTypeIntoContext(func->getResultInterfaceType()) + auto resultType = func->mapTypeIntoEnvironment(func->getResultInterfaceType()) ->getMetatypeInstanceType(); - auto resultParamType = func->mapTypeIntoContext( + auto resultParamType = func->mapTypeIntoEnvironment( ArgumentParam->getDeclaredInterfaceType()); // The result of the function must be the `Res` generic argument. if (!resultType->isEqual(resultParamType)) { @@ -1316,9 +1316,9 @@ AbstractFunctionDecl::isDistributedTargetInvocationResultHandlerOnReturn() const // === Check generic parameters in detail // --- Check: Argument: SerializationRequirement GenericTypeParamDecl *ArgumentParam = genericParams->getParams()[0]; - auto argumentType = func->mapTypeIntoContext( + auto argumentType = func->mapTypeIntoEnvironment( valueParam->getInterfaceType()->getMetatypeInstanceType()); - auto resultParamType = func->mapTypeIntoContext( + auto resultParamType = func->mapTypeIntoEnvironment( ArgumentParam->getDeclaredInterfaceType()); // The result of the function must be the `Res` generic argument. if (!argumentType->isEqual(resultParamType)) { diff --git a/lib/AST/GenericEnvironment.cpp b/lib/AST/GenericEnvironment.cpp index f3633002506b8..1dd5c460c608c 100644 --- a/lib/AST/GenericEnvironment.cpp +++ b/lib/AST/GenericEnvironment.cpp @@ -155,7 +155,7 @@ void GenericEnvironment::forEachPackElementArchetype( auto packElements = getGenericSignature().getInnermostGenericParams(); for (auto eltInterfaceType: packElements) { auto *elementArchetype = - mapTypeIntoContext(eltInterfaceType)->castTo(); + mapTypeIntoEnvironment(eltInterfaceType)->castTo(); function(elementArchetype); } } @@ -194,7 +194,7 @@ void GenericEnvironment::forEachPackElementBinding( forEachPackElementGenericTypeParam([&](auto *genericParam) { assert(elementIt != packElements.end()); auto *elementArchetype = - mapTypeIntoContext(*elementIt++)->castTo(); + mapTypeIntoEnvironment(*elementIt++)->castTo(); auto *packSubstitution = maybeApplyOuterContextSubstitutions(genericParam) ->getPackSubstitutionAsPackType(); function(elementArchetype, packSubstitution); @@ -326,7 +326,7 @@ GenericEnvironment::maybeApplyOuterContextSubstitutions(Type type) const { } } -Type GenericEnvironment::mapTypeIntoContext(GenericEnvironment *env, +Type GenericEnvironment::mapTypeIntoEnvironment(GenericEnvironment *env, Type type) { assert(!type->hasPrimaryArchetype() && "already have a contextual type"); @@ -336,7 +336,7 @@ Type GenericEnvironment::mapTypeIntoContext(GenericEnvironment *env, return type; } - return env->mapTypeIntoContext(type); + return env->mapTypeIntoEnvironment(type); } Type MapTypeOutOfContext::operator()(SubstitutableType *type) const { @@ -348,7 +348,7 @@ Type MapTypeOutOfContext::operator()(SubstitutableType *type) const { return type; } -Type TypeBase::mapTypeOutOfContext() { +Type TypeBase::mapTypeOutOfEnvironment() { assert(!hasTypeParameter() && "already have an interface type"); return Type(this).subst(MapTypeOutOfContext(), LookUpConformanceInModule(), @@ -385,7 +385,7 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) { // If this type parameter is equivalent to a concrete type, // map the concrete type into context and cache the result. if (!reducedType->isTypeParameter()) { - auto result = mapTypeIntoContext(reducedType); + auto result = mapTypeIntoEnvironment(reducedType); addMapping(canType, result); return result; } @@ -553,7 +553,7 @@ struct MapTypeIntoContext: TypeTransform { } -Type GenericEnvironment::mapTypeIntoContext(Type type) const { +Type GenericEnvironment::mapTypeIntoEnvironment(Type type) const { assert(!type->hasPrimaryArchetype() && "already have a contextual type"); if (!type->hasTypeParameter()) return type; @@ -562,7 +562,7 @@ Type GenericEnvironment::mapTypeIntoContext(Type type) const { .doIt(type, TypePosition::Invariant); } -Type GenericEnvironment::mapTypeIntoContext(GenericTypeParamType *type) const { +Type GenericEnvironment::mapTypeIntoEnvironment(GenericTypeParamType *type) const { return const_cast(this) ->getOrCreateArchetypeFromInterfaceType(type); } @@ -596,7 +596,7 @@ struct FindElementArchetypeForOpenedPackParam { } Type operator()(Type interfaceType) const { - return env->mapTypeIntoContext(getInterfaceType(interfaceType)); + return env->mapTypeIntoEnvironment(getInterfaceType(interfaceType)); } }; @@ -637,7 +637,7 @@ GenericEnvironment::mapContextualPackTypeIntoElementContext(CanType type) const } /// Unlike mapContextualPackTypeIntoElementContext(), this also applies outer -/// substitutions, so it behaves like mapTypeIntoContext() in that respect. +/// substitutions, so it behaves like mapTypeIntoEnvironment() in that respect. Type GenericEnvironment::mapPackTypeIntoElementContext(Type type) const { assert(getKind() == Kind::Element); @@ -649,7 +649,7 @@ GenericEnvironment::mapPackTypeIntoElementContext(Type type) const { // substituted one, which is what mapContextualPackTypeIntoElementContext() // expects. auto contextualType = getOuterSubstitutions() - .getGenericSignature().getGenericEnvironment()->mapTypeIntoContext(type); + .getGenericSignature().getGenericEnvironment()->mapTypeIntoEnvironment(type); contextualType = mapContextualPackTypeIntoElementContext(contextualType); return maybeApplyOuterContextSubstitutions(contextualType); diff --git a/lib/AST/LifetimeDependence.cpp b/lib/AST/LifetimeDependence.cpp index 6e6612c29f5fe..c3589e6c9cd6e 100644 --- a/lib/AST/LifetimeDependence.cpp +++ b/lib/AST/LifetimeDependence.cpp @@ -543,7 +543,7 @@ class LifetimeDependenceChecker { auto *eed = cast(decl); auto *parentEnum = eed->getParentEnum(); auto enumType = - parentEnum->mapTypeIntoContext(parentEnum->getDeclaredInterfaceType()); + parentEnum->mapTypeIntoEnvironment(parentEnum->getDeclaredInterfaceType()); // Add early bailout for imported enums. if (parentEnum->hasClangNode()) { @@ -717,7 +717,7 @@ class LifetimeDependenceChecker { continue; } if (!isDiagnosedNonEscapable( - afd->mapTypeIntoContext(param->getInterfaceType()))) { + afd->mapTypeIntoEnvironment(param->getInterfaceType()))) { continue; } if (!depBuilder.hasTargetDeps(paramIndex)) { @@ -793,7 +793,7 @@ class LifetimeDependenceChecker { auto *afd = cast(decl); if (auto *accessor = dyn_cast(afd)) { if (accessor->isCoroutine()) { - auto yieldTyInContext = accessor->mapTypeIntoContext( + auto yieldTyInContext = accessor->mapTypeIntoEnvironment( accessor->getStorage()->getValueInterfaceType()); return yieldTyInContext; } @@ -805,7 +805,7 @@ class LifetimeDependenceChecker { auto ctor = cast(afd); resultType = ctor->getResultInterfaceType(); } - return afd->mapTypeIntoContext(resultType); + return afd->mapTypeIntoEnvironment(resultType); } // ========================================================================== @@ -1173,7 +1173,7 @@ class LifetimeDependenceChecker { auto *afd = cast(decl); auto *param = afd->getParameters()->get(newValIdx); Type paramTypeInContext = - afd->mapTypeIntoContext(param->getInterfaceType()); + afd->mapTypeIntoEnvironment(param->getInterfaceType()); if (paramTypeInContext->hasError()) { return; } @@ -1281,7 +1281,7 @@ class LifetimeDependenceChecker { for (auto *param : *afd->getParameters()) { SWIFT_DEFER { paramIndex++; }; Type paramTypeInContext = - afd->mapTypeIntoContext(param->getInterfaceType()); + afd->mapTypeIntoEnvironment(param->getInterfaceType()); if (paramTypeInContext->hasError()) { return; } @@ -1401,7 +1401,7 @@ class LifetimeDependenceChecker { // Do not infer non-escapable dependence kind -- it is ambiguous. auto *param = afd->getParameters()->get(0); Type paramTypeInContext = - afd->mapTypeIntoContext(param->getInterfaceType()); + afd->mapTypeIntoEnvironment(param->getInterfaceType()); if (paramTypeInContext->hasError()) { return; } @@ -1434,7 +1434,7 @@ class LifetimeDependenceChecker { for (auto *param : *afd->getParameters()) { SWIFT_DEFER { paramIndex++; }; Type paramTypeInContext = - afd->mapTypeIntoContext(param->getInterfaceType()); + afd->mapTypeIntoEnvironment(param->getInterfaceType()); if (paramTypeInContext->hasError()) { return; } @@ -1523,7 +1523,7 @@ class LifetimeDependenceChecker { for (unsigned paramIndex : range(afd->getParameters()->size())) { auto *param = afd->getParameters()->get(paramIndex); if (!isDiagnosedNonEscapable( - afd->mapTypeIntoContext(param->getInterfaceType()))) { + afd->mapTypeIntoEnvironment(param->getInterfaceType()))) { continue; } if (!param->isInOut()) @@ -1544,7 +1544,7 @@ class LifetimeDependenceChecker { return; } if (!isDiagnosedNonEscapable( - afd->mapTypeIntoContext(param->getInterfaceType()))) { + afd->mapTypeIntoEnvironment(param->getInterfaceType()))) { return; } depBuilder.inferInoutDependency(paramIndex); diff --git a/lib/AST/LocalArchetypeRequirementCollector.cpp b/lib/AST/LocalArchetypeRequirementCollector.cpp index 7ccdf504a7cc3..371ba460dfaaf 100644 --- a/lib/AST/LocalArchetypeRequirementCollector.cpp +++ b/lib/AST/LocalArchetypeRequirementCollector.cpp @@ -138,7 +138,7 @@ GenericSignature swift::buildGenericSignatureWithCapturedEnvironments( case GenericEnvironment::Kind::Existential: { auto existentialTy = genericEnv->maybeApplyOuterContextSubstitutions( genericEnv->getOpenedExistentialType()) - ->mapTypeOutOfContext(); + ->mapTypeOutOfEnvironment(); collector.addOpenedExistential(existentialTy); continue; } @@ -229,7 +229,7 @@ static Type mapIntoLocalContext(GenericTypeParamType *param, unsigned baseDepth, auto localInterfaceType = capturedEnv->getGenericSignature() .getInnermostGenericParams()[param->getIndex()]; assert(localInterfaceType->getIndex() == param->getIndex()); - return capturedEnvs[envIndex]->mapTypeIntoContext(localInterfaceType); + return capturedEnvs[envIndex]->mapTypeIntoEnvironment(localInterfaceType); } Type MapIntoLocalArchetypeContext::operator()(SubstitutableType *type) const { @@ -239,7 +239,7 @@ Type MapIntoLocalArchetypeContext::operator()(SubstitutableType *type) const { if (param->getDepth() >= baseDepth) return mapIntoLocalContext(param, baseDepth, capturedEnvs); - return baseGenericEnv->mapTypeIntoContext(param); + return baseGenericEnv->mapTypeIntoEnvironment(param); } /// Given a substitution map for a call to a local function or closure, extend diff --git a/lib/AST/ParameterPack.cpp b/lib/AST/ParameterPack.cpp index d6b69c13ea2ce..31d559269b443 100644 --- a/lib/AST/ParameterPack.cpp +++ b/lib/AST/ParameterPack.cpp @@ -168,7 +168,7 @@ void TypeBase::getTypeParameterPacks( auto *genericEnv = archetypeTy->getGenericEnvironment(); auto paramTy = archetypeTy->getInterfaceType()->getRootGenericParam(); rootParameterPacks.push_back( - genericEnv->mapTypeIntoContext(paramTy)); + genericEnv->mapTypeIntoEnvironment(paramTy)); } } diff --git a/lib/AST/Pattern.cpp b/lib/AST/Pattern.cpp index 790ac003f0bed..89619f45c9895 100644 --- a/lib/AST/Pattern.cpp +++ b/lib/AST/Pattern.cpp @@ -153,7 +153,7 @@ Type Pattern::getType() const { if (auto genericEnv = dc->getGenericEnvironmentOfContext()) { ctx.DelayedPatternContexts.erase(this); - Ty = genericEnv->mapTypeIntoContext(Ty); + Ty = genericEnv->mapTypeIntoEnvironment(Ty); const_cast(this)->Bits.Pattern.hasInterfaceType = false; } } diff --git a/lib/AST/ProtocolConformanceRef.cpp b/lib/AST/ProtocolConformanceRef.cpp index 0a1ecfa471b25..c7560ad495d91 100644 --- a/lib/AST/ProtocolConformanceRef.cpp +++ b/lib/AST/ProtocolConformanceRef.cpp @@ -114,7 +114,7 @@ ProtocolConformanceRef::subst(InFlightSubstitution &IFS) const { return IFS.lookupConformance(origType, proto, /*level=*/0); } -ProtocolConformanceRef ProtocolConformanceRef::mapConformanceOutOfContext() const { +ProtocolConformanceRef ProtocolConformanceRef::mapConformanceOutOfEnvironment() const { if (isConcrete()) { return getConcrete()->subst( MapTypeOutOfContext(), @@ -129,7 +129,7 @@ ProtocolConformanceRef ProtocolConformanceRef::mapConformanceOutOfContext() cons SubstFlags::SubstitutePrimaryArchetypes); } else if (isAbstract()) { auto *abstract = getAbstract(); - return forAbstract(abstract->getType()->mapTypeOutOfContext(), + return forAbstract(abstract->getType()->mapTypeOutOfEnvironment(), abstract->getProtocol()); } @@ -256,7 +256,7 @@ ProtocolConformanceRef::getAssociatedConformance(Type assocType, auto subjectType = computeSubjectType(archetypeType->getInterfaceType()); return lookupConformance( - genericEnv->mapTypeIntoContext(subjectType), + genericEnv->mapTypeIntoEnvironment(subjectType), protocol); } diff --git a/lib/AST/SubstitutionMap.cpp b/lib/AST/SubstitutionMap.cpp index e311b681ea5e7..b6327d0bdf46c 100644 --- a/lib/AST/SubstitutionMap.cpp +++ b/lib/AST/SubstitutionMap.cpp @@ -290,7 +290,7 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const { return conformance; } -SubstitutionMap SubstitutionMap::mapReplacementTypesOutOfContext() const { +SubstitutionMap SubstitutionMap::mapReplacementTypesOutOfEnvironment() const { return subst(MapTypeOutOfContext(), LookUpConformanceInModule(), SubstFlags::PreservePackExpansionLevel | @@ -412,14 +412,14 @@ OverrideSubsInfo::OverrideSubsInfo(const NominalTypeDecl *baseNominal, // substitution map to store the concrete conformance C: P // and not the abstract conformance T: P. if (genericEnv) { - derivedNominalTy = genericEnv->mapTypeIntoContext( + derivedNominalTy = genericEnv->mapTypeIntoEnvironment( derivedNominalTy); } BaseSubMap = derivedNominalTy->getContextSubstitutionMap( baseNominal, genericEnv); - BaseSubMap = BaseSubMap.mapReplacementTypesOutOfContext(); + BaseSubMap = BaseSubMap.mapReplacementTypesOutOfEnvironment(); } if (auto derivedNominalSig = derivedNominal->getGenericSignature()) diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 26de2d02a112d..abb8ff288c251 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -3067,7 +3067,7 @@ getObjCObjectRepresentable(Type type, const DeclContext *dc) { // The 'Self' parameter in a protocol is representable in Objective-C. if (auto *protoDecl = dyn_cast(tyContext)) - if (type->isEqual(dc->mapTypeIntoContext(protoDecl->getSelfInterfaceType()))) + if (type->isEqual(dc->mapTypeIntoEnvironment(protoDecl->getSelfInterfaceType()))) return ForeignRepresentableKind::Object; } @@ -3770,7 +3770,7 @@ Type ArchetypeType::getSuperclass() const { if (!Bits.ArchetypeType.HasSuperclass) return Type(); auto *genericEnv = getGenericEnvironment(); - return genericEnv->mapTypeIntoContext( + return genericEnv->mapTypeIntoEnvironment( *getSubclassTrailingObjects()); } @@ -3960,7 +3960,7 @@ PackArchetypeType::get(const ASTContext &Ctx, } CanType PackArchetypeType::getReducedShape() { - // mapTypeIntoContext() also calls getReducedShape() via + // mapTypeIntoEnvironment() also calls getReducedShape() via // PackExpansionType::get(), so avoid that by short-circuiting // the case where the pack archetype represents its own // shape class. @@ -3969,7 +3969,7 @@ CanType PackArchetypeType::getReducedShape() { return CanType(this); return getGenericEnvironment() - ->mapTypeIntoContext(shapeType) + ->mapTypeIntoEnvironment(shapeType) ->getCanonicalType(); } @@ -5314,7 +5314,7 @@ TypeBase::getMatchingParamKind() { } if (auto arch = dyn_cast(this)) { - return arch->mapTypeOutOfContext()->getMatchingParamKind(); + return arch->mapTypeOutOfEnvironment()->getMatchingParamKind(); } if (isa(this)) { diff --git a/lib/AST/TypeSubstitution.cpp b/lib/AST/TypeSubstitution.cpp index 410f633650194..2e467ab839b63 100644 --- a/lib/AST/TypeSubstitution.cpp +++ b/lib/AST/TypeSubstitution.cpp @@ -87,7 +87,7 @@ operator()(InFlightSubstitution &IFS, Type dependentType, ProtocolDecl *conformedProtocol) const { if (dependentType->is() || dependentType->is()) - dependentType = dependentType->mapTypeOutOfContext(); + dependentType = dependentType->mapTypeOutOfEnvironment(); auto result = Subs.lookupConformance( dependentType->getCanonicalType(), @@ -760,7 +760,7 @@ TypeBase::getContextSubstitutions(const DeclContext *dc, if (baseTy && baseTy->is()) substTy = ErrorType::get(baseTy->getASTContext()); else if (genericEnv) - substTy = genericEnv->mapTypeIntoContext(gp); + substTy = genericEnv->mapTypeIntoEnvironment(gp); if (gp->isParameterPack() && !substTy->hasError()) substTy = PackType::getSingletonPackExpansion(substTy); @@ -819,7 +819,7 @@ TypeSubstitutionMap TypeBase::getMemberSubstitutions( param); } if (genericEnv) { - substGenericParam = genericEnv->mapTypeIntoContext( + substGenericParam = genericEnv->mapTypeIntoEnvironment( substGenericParam); } diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index a3919ae483e1f..6dbe7e9c28523 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -6237,7 +6237,7 @@ makeBaseClassMemberAccessors(DeclContext *declContext, AbstractStorageDecl *baseClassVar) { auto &ctx = declContext->getASTContext(); auto computedType = computedVar->getInterfaceType(); - auto contextTy = declContext->mapTypeIntoContext(computedType); + auto contextTy = declContext->mapTypeIntoEnvironment(computedType); // Use 'address' or 'mutableAddress' accessors for non-copyable // types, unless the base accessor returns it by value. @@ -6392,7 +6392,7 @@ static ValueDecl *cloneBaseMemberDecl(ValueDecl *decl, DeclContext *newContext, if (auto subscript = dyn_cast(decl)) { auto contextTy = - newContext->mapTypeIntoContext(subscript->getElementInterfaceType()); + newContext->mapTypeIntoEnvironment(subscript->getElementInterfaceType()); // Subscripts that return non-copyable types are not yet supported. // See: https://github.com/apple/swift/issues/70047. if (contextTy->isNoncopyable()) diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 3daf14ee40ec3..f2cfffb9ba69b 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -632,7 +632,7 @@ synthesizeErrorDomainGetterBody(AbstractFunctionDecl *afd, void *context) { DeclRefExpr *domainDeclRef = new (ctx) DeclRefExpr(ConcreteDeclRef(swiftValueDecl), {}, isImplicit); domainDeclRef->setType( - getterDecl->mapTypeIntoContext(swiftValueDecl->getInterfaceType())); + getterDecl->mapTypeIntoEnvironment(swiftValueDecl->getInterfaceType())); auto *ret = ReturnStmt::createImplicit(ctx, domainDeclRef); return { BraceStmt::create(ctx, SourceLoc(), {ret}, SourceLoc(), isImplicit), diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp index 79d469ff55808..6988c78a462e2 100644 --- a/lib/ClangImporter/ImportType.cpp +++ b/lib/ClangImporter/ImportType.cpp @@ -1165,7 +1165,7 @@ namespace { auto *genericEnv = imported->getGenericEnvironment(); for (auto typeParam : imported->getGenericParams()->getParams()) { - Type importedTypeArg = genericEnv->mapTypeIntoContext( + Type importedTypeArg = genericEnv->mapTypeIntoEnvironment( typeParam->getDeclaredInterfaceType()) ->castTo() ->getExistentialType(); diff --git a/lib/ClangImporter/SwiftDeclSynthesizer.cpp b/lib/ClangImporter/SwiftDeclSynthesizer.cpp index 69a67dde67ec0..40ed851c99a31 100644 --- a/lib/ClangImporter/SwiftDeclSynthesizer.cpp +++ b/lib/ClangImporter/SwiftDeclSynthesizer.cpp @@ -358,7 +358,7 @@ synthesizeConstantGetterBody(AbstractFunctionDecl *afd, void *voidContext) { ASTContext &ctx = afd->getASTContext(); auto func = cast(afd); VarDecl *constantVar = cast(func->getStorage()); - Type type = func->mapTypeIntoContext(constantVar->getValueInterfaceType()); + Type type = func->mapTypeIntoEnvironment(constantVar->getValueInterfaceType()); auto contextData = ConstantGetterBodyContextData::getFromOpaqueValue(voidContext); @@ -1824,7 +1824,7 @@ SwiftDeclSynthesizer::makeDereferencedPointeeProperty(FuncDecl *getter, : rawElementTy; // Use 'address' or 'mutableAddress' accessors for non-copyable // types that are returned indirectly. - bool isNoncopyable = dc->mapTypeIntoContext(elementTy)->isNoncopyable(); + bool isNoncopyable = dc->mapTypeIntoEnvironment(elementTy)->isNoncopyable(); bool isImplicit = !(isNoncopyable || resultDependsOnSelf); bool useAddress = rawElementTy->getAnyPointerElementType() && (isNoncopyable || resultDependsOnSelf); diff --git a/lib/ConstExtract/ConstExtract.cpp b/lib/ConstExtract/ConstExtract.cpp index 7a11805cb9015..b6863915c54a8 100644 --- a/lib/ConstExtract/ConstExtract.cpp +++ b/lib/ConstExtract/ConstExtract.cpp @@ -112,7 +112,7 @@ std::string toFullyQualifiedProtocolNameString(const swift::ProtocolDecl &Protoc std::string toMangledTypeNameString(const swift::Type &Type) { auto PrintingType = Type; if (Type->hasArchetype()) - PrintingType = Type->mapTypeOutOfContext(); + PrintingType = Type->mapTypeOutOfEnvironment(); return Mangle::ASTMangler(Type->getASTContext()).mangleTypeWithoutPrefix(PrintingType->getCanonicalType()); } diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp index a7f40afde517a..47c4ae1782d01 100644 --- a/lib/IDE/CodeCompletion.cpp +++ b/lib/IDE/CodeCompletion.cpp @@ -188,7 +188,7 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks, CurDeclContext, /*ProduceDiagnostics=*/false); if (!ty->hasError()) { - ParsedTypeLoc.setType(CurDeclContext->mapTypeIntoContext(ty)); + ParsedTypeLoc.setType(CurDeclContext->mapTypeIntoEnvironment(ty)); return true; } @@ -883,7 +883,7 @@ static void addKeywordsAfterReturn(CodeCompletionResultSink &Sink, DeclContext * // Note that `TypeContext` must stay alive for the duration of // `~CodeCodeCompletionResultBuilder()`. ExpectedTypeContext TypeContext; - TypeContext.setPossibleTypes({DC->mapTypeIntoContext(resultType)}); + TypeContext.setPossibleTypes({DC->mapTypeIntoEnvironment(resultType)}); CodeCompletionResultBuilder Builder(Sink, CodeCompletionResultKind::Literal, SemanticContextKind::None); diff --git a/lib/IDE/CompletionLookup.cpp b/lib/IDE/CompletionLookup.cpp index 29b7e9b6df783..b7b0e3d31395a 100644 --- a/lib/IDE/CompletionLookup.cpp +++ b/lib/IDE/CompletionLookup.cpp @@ -2020,7 +2020,7 @@ void CompletionLookup::foundDecl(ValueDecl *D, DeclVisibilityKind Reason, if (auto *TAD = dyn_cast(D)) { addTypeAliasRef(TAD, Reason, dynamicLookupInfo); - auto type = TAD->mapTypeIntoContext(TAD->getDeclaredInterfaceType()); + auto type = TAD->mapTypeIntoEnvironment(TAD->getDeclaredInterfaceType()); if (type->mayHaveMembers()) addConstructorCallsForType(type, TAD->getName(), Reason, dynamicLookupInfo); @@ -2030,7 +2030,7 @@ void CompletionLookup::foundDecl(ValueDecl *D, DeclVisibilityKind Reason, if (auto *GP = dyn_cast(D)) { addGenericTypeParamRef(GP, Reason, dynamicLookupInfo); auto type = - CurrDeclContext->mapTypeIntoContext(GP->getDeclaredInterfaceType()); + CurrDeclContext->mapTypeIntoEnvironment(GP->getDeclaredInterfaceType()); addConstructorCallsForType(type, GP->getName(), Reason, dynamicLookupInfo); return; @@ -3119,7 +3119,7 @@ void CompletionLookup::getSelfTypeCompletionInDeclContext( return; Type selfType = - CurrDeclContext->mapTypeIntoContext(typeDC->getSelfInterfaceType()); + CurrDeclContext->mapTypeIntoEnvironment(typeDC->getSelfInterfaceType()); if (typeDC->getSelfClassDecl()) { // In classes, 'Self' can be used in result type of func, subscript and diff --git a/lib/IDE/ConformingMethodList.cpp b/lib/IDE/ConformingMethodList.cpp index 72987b054504f..2ce9314c7b931 100644 --- a/lib/IDE/ConformingMethodList.cpp +++ b/lib/IDE/ConformingMethodList.cpp @@ -135,7 +135,7 @@ void ConformingMethodListCallbacks::readyForTypeChecking(SourceFile *SrcFile) { auto interfaceTy = T; if (T->hasArchetype()) - interfaceTy = interfaceTy->mapTypeOutOfContext(); + interfaceTy = interfaceTy->mapTypeOutOfEnvironment(); llvm::SmallPtrSet expectedProtocols; for (auto Name: ExpectedTypeNames) { diff --git a/lib/IDE/CursorInfo.cpp b/lib/IDE/CursorInfo.cpp index 3e9dc9db6a345..5e925a4237833 100644 --- a/lib/IDE/CursorInfo.cpp +++ b/lib/IDE/CursorInfo.cpp @@ -325,7 +325,7 @@ class CursorInfoTypeCheckSolutionCallback : public TypeCheckCompletionCallback { return; } Type SolutionInterfaceTy = - S.simplifyType(S.getType(DeclToResolve))->mapTypeOutOfContext(); + S.simplifyType(S.getType(DeclToResolve))->mapTypeOutOfEnvironment(); addResult({/*BaseType=*/nullptr, /*IsDynamicRef=*/false, DeclToResolve, SolutionInterfaceTy}); diff --git a/lib/IDE/SelectedOverloadInfo.cpp b/lib/IDE/SelectedOverloadInfo.cpp index a1f65adca0ae5..c694b5f13bfcd 100644 --- a/lib/IDE/SelectedOverloadInfo.cpp +++ b/lib/IDE/SelectedOverloadInfo.cpp @@ -59,7 +59,7 @@ swift::ide::getSelectedOverloadInfo(const Solution &S, Params[0].getPlainType()->is()) { auto *KPDecl = CS.getASTContext().getKeyPathDecl(); Type KPTy = - KPDecl->mapTypeIntoContext(KPDecl->getDeclaredInterfaceType()); + KPDecl->mapTypeIntoEnvironment(KPDecl->getDeclaredInterfaceType()); Type KPValueTy = KPTy->castTo()->getGenericArgs()[1]; KPTy = BoundGenericType::get(KPDecl, Type(), {Result.BaseTy, KPValueTy}); diff --git a/lib/IDE/TypeContextInfo.cpp b/lib/IDE/TypeContextInfo.cpp index 4dad77c2a683a..94a8f94d0e4b6 100644 --- a/lib/IDE/TypeContextInfo.cpp +++ b/lib/IDE/TypeContextInfo.cpp @@ -136,7 +136,7 @@ void ContextInfoCallbacks::readyForTypeChecking(SourceFile *SrcFile) { auto interfaceTy = T; if (interfaceTy->hasArchetype()) - interfaceTy = interfaceTy->mapTypeOutOfContext(); + interfaceTy = interfaceTy->mapTypeOutOfEnvironment(); // TODO: Do we need '.none' for Optionals? auto objTy = T->lookThroughAllOptionalTypes(); diff --git a/lib/IRGen/GenArchetype.cpp b/lib/IRGen/GenArchetype.cpp index bb45efbfec026..63ec5ec8005e9 100644 --- a/lib/IRGen/GenArchetype.cpp +++ b/lib/IRGen/GenArchetype.cpp @@ -101,7 +101,7 @@ irgen::emitArchetypeTypeMetadataRef(IRGenFunction &IGF, auto *member = archetype->getInterfaceType()->castTo(); auto parent = cast( - archetype->getGenericEnvironment()->mapTypeIntoContext( + archetype->getGenericEnvironment()->mapTypeIntoEnvironment( member->getBase())->getCanonicalType()); auto *assocType = member->getAssocType(); @@ -235,7 +235,7 @@ llvm::Value *irgen::emitArchetypeWitnessTableRef(IRGenFunction &IGF, // The first entry in the path is a direct requirement of the signature, // for which we should always have local type data available. CanType rootArchetype = - environment->mapTypeIntoContext(i->first)->getCanonicalType(); + environment->mapTypeIntoEnvironment(i->first)->getCanonicalType(); ProtocolDecl *rootProtocol = i->second; // Turn the rest of the path into a MetadataPath. diff --git a/lib/IRGen/GenCall.cpp b/lib/IRGen/GenCall.cpp index 7a7e78e929f29..439300697a99b 100644 --- a/lib/IRGen/GenCall.cpp +++ b/lib/IRGen/GenCall.cpp @@ -3878,7 +3878,7 @@ void CallEmission::emitToMemory(Address addr, if (origResultType->hasTypeParameter()) origResultType = IGF.IGM.getGenericEnvironment() - ->mapTypeIntoContext(origResultType) + ->mapTypeIntoEnvironment(origResultType) ->getCanonicalType(); if (origResultType != substResultType) { diff --git a/lib/IRGen/GenClass.cpp b/lib/IRGen/GenClass.cpp index 9f1b7e2aa4bc0..931a45cb4fa2c 100644 --- a/lib/IRGen/GenClass.cpp +++ b/lib/IRGen/GenClass.cpp @@ -2188,7 +2188,7 @@ namespace { if (prop->getAttrs().hasAttribute()) outs << ",D"; - auto isObject = propDC->mapTypeIntoContext(propTy) + auto isObject = propDC->mapTypeIntoEnvironment(propTy) ->hasRetainablePointerRepresentation(); auto hasObjectEncoding = typeEnc[0] == '@'; diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index 88c5ab46897ad..7188bc566a556 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -3600,7 +3600,7 @@ llvm::CallBase *swift::irgen::emitCXXConstructorCall( bool swift::irgen::hasValidSignatureForEmbedded(SILFunction *f) { auto s = f->getLoweredFunctionType()->getInvocationGenericSignature(); for (auto genParam : s.getGenericParams()) { - auto mappedParam = f->getGenericEnvironment()->mapTypeIntoContext(genParam); + auto mappedParam = f->getGenericEnvironment()->mapTypeIntoEnvironment(genParam); if (auto archeTy = dyn_cast(mappedParam)) { if (archeTy->requiresClass()) continue; diff --git a/lib/IRGen/GenEnum.cpp b/lib/IRGen/GenEnum.cpp index 8b60df5ae7c07..8dddb86e70f04 100644 --- a/lib/IRGen/GenEnum.cpp +++ b/lib/IRGen/GenEnum.cpp @@ -231,7 +231,7 @@ const { // Empty payload addresses can be left undefined. if (payloadI == ElementsWithPayload.end()) { - auto payloadTy = elt->getParentEnum()->mapTypeIntoContext( + auto payloadTy = elt->getParentEnum()->mapTypeIntoEnvironment( elt->getPayloadInterfaceType()); return IGF.getTypeInfoForUnlowered(payloadTy) .getUndefAddress(); @@ -254,7 +254,7 @@ const { // Empty payload addresses can be left undefined. if (payloadI == ElementsWithPayload.end()) { - auto payloadTy = Case->getParentEnum()->mapTypeIntoContext( + auto payloadTy = Case->getParentEnum()->mapTypeIntoEnvironment( Case->getPayloadInterfaceType()); return IGF.getTypeInfoForUnlowered(payloadTy) .getUndefAddress(); @@ -6467,7 +6467,7 @@ EnumImplStrategy::get(TypeConverter &TC, SILType type, EnumDecl *theEnum) { // parameters, then we additionally need to constrain any layout // optimizations we perform to things that are reproducible by the runtime. Type origPayloadType = elt->getPayloadInterfaceType(); - origPayloadType = theEnum->mapTypeIntoContext(origPayloadType); + origPayloadType = theEnum->mapTypeIntoEnvironment(origPayloadType); auto origArgLoweredTy = TC.IGM.getLoweredType(origPayloadType); auto *origArgTI = &TC.getCompleteTypeInfo(origArgLoweredTy.getASTType()); diff --git a/lib/IRGen/GenFunc.cpp b/lib/IRGen/GenFunc.cpp index 8213dd9afcf0e..ac9b59fdd389b 100644 --- a/lib/IRGen/GenFunc.cpp +++ b/lib/IRGen/GenFunc.cpp @@ -1501,7 +1501,7 @@ class CoroPartialApplicationForwarderEmission auto prototype = subIGF.IGM.getOpaquePtr( subIGF.IGM.getAddrOfContinuationPrototype( cast( - unsubstType->mapTypeOutOfContext()->getCanonicalType()), + unsubstType->mapTypeOutOfEnvironment()->getCanonicalType()), origType->getInvocationGenericSignature())); diff --git a/lib/IRGen/GenHeap.cpp b/lib/IRGen/GenHeap.cpp index 131ec7a2d1f25..6b41ddebf8742 100644 --- a/lib/IRGen/GenHeap.cpp +++ b/lib/IRGen/GenHeap.cpp @@ -1594,7 +1594,7 @@ class FixedBoxTypeInfoBase : public BoxTypeInfo { // Allocate a new object using the layout. auto boxedInterfaceType = boxedType; if (env) { - boxedInterfaceType = boxedType.mapTypeOutOfContext(); + boxedInterfaceType = boxedType.mapTypeOutOfEnvironment(); } auto boxDescriptor = IGF.IGM.getAddrOfBoxDescriptor( diff --git a/lib/IRGen/GenKeyPath.cpp b/lib/IRGen/GenKeyPath.cpp index 314c59149fd6b..ce65f64c0d2ff 100644 --- a/lib/IRGen/GenKeyPath.cpp +++ b/lib/IRGen/GenKeyPath.cpp @@ -204,7 +204,7 @@ getLayoutFunctionForComputedComponent(IRGenModule &IGM, for (auto &index : component.getArguments()) { auto ty = genericEnv - ? genericEnv->mapTypeIntoContext(IGM.getSILModule(), index.LoweredType) + ? genericEnv->mapTypeIntoEnvironment(IGM.getSILModule(), index.LoweredType) : index.LoweredType; auto &ti = IGM.getTypeInfo(ty); auto indexSize = ti.getSize(IGF, ty); @@ -259,7 +259,7 @@ getWitnessTableForComputedComponent(IRGenModule &IGM, bool isTrivial = true; for (auto &component : component.getArguments()) { auto ty = genericEnv - ? genericEnv->mapTypeIntoContext(IGM.getSILModule(), component.LoweredType) + ? genericEnv->mapTypeIntoEnvironment(IGM.getSILModule(), component.LoweredType) : component.LoweredType; auto &ti = IGM.getTypeInfo(ty); isTrivial &= ti.isTriviallyDestroyable(ResilienceExpansion::Minimal); @@ -297,7 +297,7 @@ getWitnessTableForComputedComponent(IRGenModule &IGM, llvm::Value *offset = nullptr; for (auto &component : component.getArguments()) { auto ty = genericEnv - ? genericEnv->mapTypeIntoContext(IGM.getSILModule(), + ? genericEnv->mapTypeIntoEnvironment(IGM.getSILModule(), component.LoweredType) : component.LoweredType; auto &ti = IGM.getTypeInfo(ty); @@ -348,7 +348,7 @@ getWitnessTableForComputedComponent(IRGenModule &IGM, llvm::Value *offset = nullptr; for (auto &component : component.getArguments()) { auto ty = genericEnv - ? genericEnv->mapTypeIntoContext(IGM.getSILModule(), + ? genericEnv->mapTypeIntoEnvironment(IGM.getSILModule(), component.LoweredType) : component.LoweredType; auto &ti = IGM.getTypeInfo(ty); @@ -479,7 +479,7 @@ getInitializerForComputedComponent(IRGenModule &IGM, // Figure out the offsets of the operands in the source buffer. for (int i = 0; i <= lastOperandNeeded; ++i) { auto ty = genericEnv - ? genericEnv->mapTypeIntoContext(IGM.getSILModule(), + ? genericEnv->mapTypeIntoEnvironment(IGM.getSILModule(), operands[i].LoweredType) : operands[i].LoweredType; @@ -508,7 +508,7 @@ getInitializerForComputedComponent(IRGenModule &IGM, auto &index = component.getArguments()[i]; auto ty = genericEnv - ? genericEnv->mapTypeIntoContext(IGM.getSILModule(), + ? genericEnv->mapTypeIntoEnvironment(IGM.getSILModule(), index.LoweredType) : index.LoweredType; @@ -673,7 +673,7 @@ emitKeyPathComponent(IRGenModule &IGM, // Recover class decl from superclass constraint if (!classDecl && genericEnv) { - auto ty = genericEnv->mapTypeIntoContext(baseTy)->getCanonicalType(); + auto ty = genericEnv->mapTypeIntoEnvironment(baseTy)->getCanonicalType(); auto archetype = dyn_cast(ty); if (archetype && archetype->requiresClass()) { auto superClassTy = ty->getSuperclass(false)->getCanonicalType(); @@ -702,7 +702,7 @@ emitKeyPathComponent(IRGenModule &IGM, SILType::getPrimitiveObjectType(loweredClassTy.getASTType()); if (!loweredClassTy.getASTType()->hasArchetype()) loweredBaseContextTy = SILType::getPrimitiveObjectType( - GenericEnvironment::mapTypeIntoContext(genericEnv, + GenericEnvironment::mapTypeIntoEnvironment(genericEnv, loweredClassTy.getASTType()) ->getCanonicalType()); @@ -928,7 +928,7 @@ emitKeyPathComponent(IRGenModule &IGM, auto loweredClassTy = loweredBaseTy; // Recover class decl from superclass constraint if (!classDecl && genericEnv) { - auto ty = genericEnv->mapTypeIntoContext(baseTy)->getCanonicalType(); + auto ty = genericEnv->mapTypeIntoEnvironment(baseTy)->getCanonicalType(); auto archetype = dyn_cast(ty); if (archetype && archetype->requiresClass()) { auto superClassTy = ty->getSuperclass(false)->getCanonicalType(); @@ -961,7 +961,7 @@ emitKeyPathComponent(IRGenModule &IGM, // and start counting at the Swift native root. if (loweredClassTy.getASTType()->hasTypeParameter()) loweredClassTy = SILType::getPrimitiveObjectType( - GenericEnvironment::mapTypeIntoContext( + GenericEnvironment::mapTypeIntoEnvironment( genericEnv, loweredClassTy.getASTType()) ->getCanonicalType()); switch (getClassFieldAccess(IGM, loweredClassTy, property)) { diff --git a/lib/IRGen/GenMeta.cpp b/lib/IRGen/GenMeta.cpp index 8d6ecbb8e43a1..7467f91c14ede 100644 --- a/lib/IRGen/GenMeta.cpp +++ b/lib/IRGen/GenMeta.cpp @@ -1162,7 +1162,7 @@ namespace { continue; auto witness = - entry.getAssociatedTypeWitness().Witness->mapTypeOutOfContext(); + entry.getAssociatedTypeWitness().Witness->mapTypeOutOfEnvironment(); return IGM.getAssociatedTypeWitness(witness, Proto->getGenericSignature(), /*inProtocolContext=*/true); @@ -1243,7 +1243,7 @@ namespace { // For an abstract table, emit a reference to the witness table. CanType associatedTypeInContext - = Proto->mapTypeIntoContext(requirement.getAssociation()) + = Proto->mapTypeIntoEnvironment(requirement.getAssociation()) ->getCanonicalType(); auto returnValue = emitArchetypeWitnessTableRef( @@ -2836,7 +2836,7 @@ namespace { ->getReducedType(O->getOpaqueInterfaceGenericSignature()); type = genericEnv - ? genericEnv->mapTypeIntoContext(type)->getCanonicalType() + ? genericEnv->mapTypeIntoEnvironment(type)->getCanonicalType() : type; return IGF.emitTypeMetadataRef(type); @@ -2876,7 +2876,7 @@ namespace { substitutions.lookupConformance(underlyingDependentType, P); if (underlyingType->hasTypeParameter()) { - underlyingType = genericEnv->mapTypeIntoContext( + underlyingType = genericEnv->mapTypeIntoEnvironment( underlyingType); underlyingConformance = underlyingConformance.subst( genericEnv->getForwardingSubstitutionMap()); @@ -4316,7 +4316,7 @@ namespace { CanType getSuperclassTypeForMetadata() { if (auto superclass = getSuperclassForMetadata(IGM, Target)) - return Target->mapTypeIntoContext(superclass)->getCanonicalType(); + return Target->mapTypeIntoEnvironment(superclass)->getCanonicalType(); return CanType(); } @@ -5248,7 +5248,7 @@ namespace { void addFieldOffset(VarDecl *var) { assert(!isPureObjC()); addFixedFieldOffset(IGM, B, var, [&](DeclContext *dc) { - return dc->mapTypeIntoContext(type); + return dc->mapTypeIntoEnvironment(type); }); } diff --git a/lib/IRGen/GenPointerAuth.cpp b/lib/IRGen/GenPointerAuth.cpp index 66a6b6408036a..d1c518ed70d87 100644 --- a/lib/IRGen/GenPointerAuth.cpp +++ b/lib/IRGen/GenPointerAuth.cpp @@ -533,7 +533,7 @@ static void hashStringForList(IRGenModule &IGM, const ArrayRef &list, CanType Ty = paramOrRetVal.getArgumentType( IGM.getSILModule(), fnType, IGM.getMaximalTypeExpansionContext()); if (Ty->hasTypeParameter()) - Ty = genericEnv->mapTypeIntoContext(Ty)->getCanonicalType(); + Ty = genericEnv->mapTypeIntoEnvironment(Ty)->getCanonicalType(); hashStringForType(IGM, Ty, Out, genericEnv); } Out << ":"; @@ -552,7 +552,7 @@ static void hashStringForList(IRGenModule &IGM, CanType Ty = paramOrRetVal.getReturnValueType( IGM.getSILModule(), fnType, IGM.getMaximalTypeExpansionContext()); if (Ty->hasTypeParameter()) - Ty = genericEnv->mapTypeIntoContext(Ty)->getCanonicalType(); + Ty = genericEnv->mapTypeIntoEnvironment(Ty)->getCanonicalType(); hashStringForType(IGM, Ty, Out, genericEnv); } Out << ":"; @@ -628,7 +628,7 @@ getCoroutineYieldTypesDiscriminator(IRGenModule &IGM, CanSILFunctionType type) { CanType Ty = yield.getArgumentType(IGM.getSILModule(), type, IGM.getMaximalTypeExpansionContext()); if (Ty->hasTypeParameter()) - Ty = genericEnv->mapTypeIntoContext(Ty)->getCanonicalType(); + Ty = genericEnv->mapTypeIntoEnvironment(Ty)->getCanonicalType(); hashStringForType(IGM, Ty, out, genericEnv); } out << ":"; diff --git a/lib/IRGen/GenPoly.cpp b/lib/IRGen/GenPoly.cpp index a57487fc108e4..bed2bb0c71ab7 100644 --- a/lib/IRGen/GenPoly.cpp +++ b/lib/IRGen/GenPoly.cpp @@ -44,7 +44,7 @@ static SILType applyPrimaryArchetypes(IRGenFunction &IGF, } auto substType = - IGF.IGM.getGenericEnvironment()->mapTypeIntoContext(type.getASTType()) + IGF.IGM.getGenericEnvironment()->mapTypeIntoEnvironment(type.getASTType()) ->getCanonicalType(); return SILType::getPrimitiveType(substType, type.getCategory()); } diff --git a/lib/IRGen/GenProto.cpp b/lib/IRGen/GenProto.cpp index 997be92e5ca2e..ba8a02bb801ae 100644 --- a/lib/IRGen/GenProto.cpp +++ b/lib/IRGen/GenProto.cpp @@ -596,7 +596,7 @@ EmitPolymorphicParameters::EmitPolymorphicParameters(IRGenFunction &IGF, CanType EmitPolymorphicParameters::getTypeInContext(CanType type) const { - return Fn.mapTypeIntoContext(type)->getCanonicalType(); + return Fn.mapTypeIntoEnvironment(type)->getCanonicalType(); } CanType EmitPolymorphicParameters::getArgTypeInContext(unsigned paramIndex) const { @@ -1480,7 +1480,7 @@ class AccessorConformanceInfo : public ConformanceInfo { Conformance(*SILWT->getConformance()->getRootConformance()), ConformanceInContext(*mapConformanceIntoContext(SILWT->getConformance()->getRootConformance())), ConcreteType(Conformance.getDeclContext() - ->mapTypeIntoContext(Conformance.getType()) + ->mapTypeIntoEnvironment(Conformance.getType()) ->getCanonicalType()) {} void defineAssociatedTypeWitnessTableAccessFunction( @@ -1955,7 +1955,7 @@ void WitnessTableBuilderBase::defineAssociatedTypeWitnessTableAccessFunction( &Conformance, destTable.getAddress(), [&](CanType type) { - return Conformance.getDeclContext()->mapTypeIntoContext(type) + return Conformance.getDeclContext()->mapTypeIntoEnvironment(type) ->getCanonicalType(); }); @@ -2123,7 +2123,7 @@ llvm::Function *FragileWitnessTableBuilder::buildInstantiationFunction() { const auto &condConformance = SILConditionalConformances[idx]; CanType reqTypeInContext = Conformance.getDeclContext() - ->mapTypeIntoContext(condConformance.getType()) + ->mapTypeIntoEnvironment(condConformance.getType()) ->getCanonicalType(); if (auto archetype = dyn_cast(reqTypeInContext)) { auto condProto = condConformance.getProtocol(); diff --git a/lib/IRGen/GenReflection.cpp b/lib/IRGen/GenReflection.cpp index 8b0f5860a55a4..204ff5737e1cf 100644 --- a/lib/IRGen/GenReflection.cpp +++ b/lib/IRGen/GenReflection.cpp @@ -348,7 +348,7 @@ getTypeRefByFunction(IRGenModule &IGM, CanGenericSignature sig, CanType t, auto bindingsBufPtr = IGF.collectParameters().claimNext(); auto substT = genericEnv - ? genericEnv->mapTypeIntoContext(t)->getCanonicalType() + ? genericEnv->mapTypeIntoEnvironment(t)->getCanonicalType() : t; // If a type is noncopyable, lie about the resolved type to reflection @@ -497,7 +497,7 @@ getTypeRefImpl(IRGenModule &IGM, // exposing their metadata to them. Type contextualTy = type; if (sig) { - contextualTy = sig.getGenericEnvironment()->mapTypeIntoContext(type); + contextualTy = sig.getGenericEnvironment()->mapTypeIntoEnvironment(type); } bool isAlwaysNoncopyable = false; @@ -640,7 +640,7 @@ IRGenModule::emitWitnessTableRefString(CanType type, Address(bindingsBufPtr, Int8Ty, getPointerAlignment()), MetadataState::Complete, genericEnv->getForwardingSubstitutionMap()); - type = genericEnv->mapTypeIntoContext(type)->getCanonicalType(); + type = genericEnv->mapTypeIntoEnvironment(type)->getCanonicalType(); } if (origType->hasTypeParameter()) { conformance = conformance.subst( @@ -1475,7 +1475,7 @@ class CaptureDescriptorBuilder : public ReflectionMetadataBuilder { auto Source = SourceBuilder.createClosureBinding(i); auto BindingType = Bindings[i].getTypeParameter().subst(Subs); - auto InterfaceType = BindingType->mapTypeOutOfContext(); + auto InterfaceType = BindingType->mapTypeOutOfEnvironment(); SourceMap.emplace_back(Kind, InterfaceType->getCanonicalType(), Source); break; } @@ -1545,7 +1545,7 @@ class CaptureDescriptorBuilder : public ReflectionMetadataBuilder { auto Src = Path.getMetadataSource(SourceBuilder, Root); auto SubstType = Req.getTypeParameter().subst(Subs); - auto InterfaceType = SubstType->mapTypeOutOfContext(); + auto InterfaceType = SubstType->mapTypeOutOfEnvironment(); SourceMap.emplace_back(Kind, InterfaceType->getCanonicalType(), Src); }); @@ -1599,7 +1599,7 @@ class CaptureDescriptorBuilder : public ReflectionMetadataBuilder { // Now add typerefs of all of the captures. for (auto CaptureType : CaptureTypes) { - addLoweredTypeRef(CaptureType.mapTypeOutOfContext(), sig); + addLoweredTypeRef(CaptureType.mapTypeOutOfEnvironment(), sig); } // Add the pairs that make up the generic param -> metadata source map diff --git a/lib/IRGen/GenType.cpp b/lib/IRGen/GenType.cpp index 51767c715660e..ad46b6e20bdc3 100644 --- a/lib/IRGen/GenType.cpp +++ b/lib/IRGen/GenType.cpp @@ -1993,7 +1993,7 @@ ArchetypeType *TypeConverter::getExemplarArchetype(ArchetypeType *t) { // Map the archetype out of its own generic environment and into the // canonical generic environment. auto interfaceType = t->getInterfaceType(); - auto exemplar = canGenericEnv->mapTypeIntoContext(interfaceType) + auto exemplar = canGenericEnv->mapTypeIntoEnvironment(interfaceType) ->castTo(); assert(isExemplarArchetype(exemplar)); return exemplar; @@ -2051,7 +2051,7 @@ const TypeInfo *TypeConverter::getTypeEntry(CanType canonicalTy) { auto contextTy = canonicalTy; if (contextTy->hasTypeParameter()) { // The type we got should be lowered, so lower it like a SILType. - contextTy = getGenericEnvironment()->mapTypeIntoContext( + contextTy = getGenericEnvironment()->mapTypeIntoEnvironment( IGM.getSILModule(), SILType::getPrimitiveAddressType(contextTy)).getASTType(); } diff --git a/lib/IRGen/GenValueWitness.cpp b/lib/IRGen/GenValueWitness.cpp index 4d5ea33ba1b6a..85dde1655f8e6 100644 --- a/lib/IRGen/GenValueWitness.cpp +++ b/lib/IRGen/GenValueWitness.cpp @@ -387,7 +387,7 @@ static Address getArgAsBuffer(IRGenFunction &IGF, static CanType getFormalTypeInPrimaryContext(CanType abstractType) { auto *nominal = abstractType.getAnyNominal(); if (nominal && abstractType->isEqual(nominal->getDeclaredType())) { - return nominal->mapTypeIntoContext(nominal->getDeclaredInterfaceType()) + return nominal->mapTypeIntoEnvironment(nominal->getDeclaredInterfaceType()) ->getCanonicalType(); } @@ -397,7 +397,7 @@ static CanType getFormalTypeInPrimaryContext(CanType abstractType) { SILType irgen::getLoweredTypeInPrimaryContext(IRGenModule &IGM, NominalTypeDecl *type) { - CanType concreteFormalType = type->mapTypeIntoContext( + CanType concreteFormalType = type->mapTypeIntoEnvironment( type->getDeclaredInterfaceType())->getCanonicalType(); return IGM.getLoweredType(concreteFormalType); } @@ -1371,7 +1371,7 @@ addValueWitnesses(IRGenModule &IGM, ConstantStructBuilder &B, /// Currently, this is true if the size and/or alignment of the type is /// dependent on its generic parameters. bool irgen::hasDependentValueWitnessTable(IRGenModule &IGM, NominalTypeDecl *decl) { - auto ty = decl->mapTypeIntoContext(decl->getDeclaredInterfaceType()); + auto ty = decl->mapTypeIntoEnvironment(decl->getDeclaredInterfaceType()); return !IGM.getTypeInfoForUnlowered(ty).isFixedSize(); } diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index 4fe84cf843b3d..7737d464569d1 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -1042,7 +1042,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { return false; }); - Ty = Ty->mapTypeOutOfContext(); + Ty = Ty->mapTypeOutOfEnvironment(); } else { Sig = IGM.getCurGenericContext(); } @@ -1285,11 +1285,11 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { return {false, {}}; // Go from Pair to Pair. Type InterfaceTy = Decl->getDeclaredInterfaceType(); - Type UnsubstitutedTy = Decl->mapTypeIntoContext(InterfaceTy); + Type UnsubstitutedTy = Decl->mapTypeIntoEnvironment(InterfaceTy); Mangle::ASTMangler Mangler(IGM.Context); std::string DeclTypeMangledName = Mangler.mangleTypeForDebugger( - UnsubstitutedTy->mapTypeOutOfContext(), {}); + UnsubstitutedTy->mapTypeOutOfEnvironment(), {}); bool IsUnsubstituted = (DeclTypeMangledName == MangledName); return {IsUnsubstituted, UnsubstitutedTy}; } @@ -1464,7 +1464,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { std::optional ElemDbgTy; if (auto PayloadTy = ElemDecl->getPayloadInterfaceType()) { // A variant case which carries a payload. - PayloadTy = ElemDecl->getParentEnum()->mapTypeIntoContext(PayloadTy); + PayloadTy = ElemDecl->getParentEnum()->mapTypeIntoEnvironment(PayloadTy); auto &TI = IGM.getTypeInfoForUnlowered(PayloadTy); ElemDbgTy = CompletedDebugTypeInfo::getFromTypeInfo(PayloadTy, TI, IGM); // FIXME: This is not correct, but seems to be the only way to emit @@ -1532,7 +1532,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { std::optional ElemDbgTy; if (auto PayloadTy = ElemDecl->getPayloadInterfaceType()) { // A variant case which carries a payload. - PayloadTy = ElemDecl->getParentEnum()->mapTypeIntoContext(PayloadTy); + PayloadTy = ElemDecl->getParentEnum()->mapTypeIntoEnvironment(PayloadTy); ElemDbgTy = DebugTypeInfo::getFromTypeInfo( PayloadTy, IGM.getTypeInfoForUnlowered(PayloadTy), IGM); MemberTypes.emplace_back(ElemDecl->getBaseIdentifier().str(), @@ -3341,9 +3341,9 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn, SILType SILTy = IGM.silConv.getSILType( *ErrorInfo, FnTy, IGM.getMaximalTypeExpansionContext()); - errorResultTy = SILFn->mapTypeIntoContext(errorResultTy) + errorResultTy = SILFn->mapTypeIntoEnvironment(errorResultTy) ->getCanonicalType(); - SILTy = SILFn->mapTypeIntoContext(SILTy); + SILTy = SILFn->mapTypeIntoEnvironment(SILTy); auto DTI = DebugTypeInfo::getFromTypeInfo( errorResultTy, diff --git a/lib/IRGen/IRGenFunction.h b/lib/IRGen/IRGenFunction.h index f10cb8cb88feb..e96f4fae589b7 100644 --- a/lib/IRGen/IRGenFunction.h +++ b/lib/IRGen/IRGenFunction.h @@ -769,7 +769,7 @@ class IRGenFunction { void bindLocalTypeDataFromSelfWitnessTable( const ProtocolConformance *conformance, llvm::Value *selfTable, - llvm::function_ref mapTypeIntoContext); + llvm::function_ref mapTypeIntoEnvironment); void setDominanceResolver(DominanceResolverFunction resolver) { assert(DominanceResolver == nullptr); diff --git a/lib/IRGen/IRGenMangler.cpp b/lib/IRGen/IRGenMangler.cpp index a8a68b585c229..d856bdfc9e3be 100644 --- a/lib/IRGen/IRGenMangler.cpp +++ b/lib/IRGen/IRGenMangler.cpp @@ -445,7 +445,7 @@ std::string IRGenMangler::mangleSymbolNameForMangledMetadataAccessorString( // Reflection metadata is conditionalized for noncopyable types. CanType contextType = type; if (genericSig) { - contextType = genericSig.getGenericEnvironment()->mapTypeIntoContext(contextType) + contextType = genericSig.getGenericEnvironment()->mapTypeIntoEnvironment(contextType) ->getReducedType(genericSig); } if (contextType->isNoncopyable()) { diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index 783aa4688b979..c1dabec314a35 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -2038,7 +2038,7 @@ static ArrayRef emitEntryPointIndirectReturn( // Map an indirect return for a type SIL considers loadable but still // requires an indirect return at the IR level. SILFunctionConventions fnConv(funcTy, IGF.getSILModule()); - SILType directResultType = IGF.CurSILFn->mapTypeIntoContext( + SILType directResultType = IGF.CurSILFn->mapTypeIntoEnvironment( fnConv.getSILResultType(IGF.IGM.getMaximalTypeExpansionContext())); if (fnConv.hasAddressResult()) { @@ -2066,7 +2066,7 @@ static ArrayRef emitEntryPointIndirectReturn( IGF.IGM.getMaximalTypeExpansionContext())) { SILArgument *ret = bbargs[idx]; auto inContextResultType = - IGF.CurSILFn->mapTypeIntoContext(indirectResultType); + IGF.CurSILFn->mapTypeIntoEnvironment(indirectResultType); auto &retTI = IGF.IGM.getTypeInfo(ret->getType()); auto ¶mTI = IGF.IGM.getTypeInfo(inContextResultType); @@ -2095,7 +2095,7 @@ static void bindParameter(IRGenSILFunction &IGF, unsigned index, SILArgument *param, SILType paramTy, ExplosionForArgument explosionForArgument) { // Pull out the parameter value and its formal type. - auto ¶mTI = IGF.getTypeInfo(IGF.CurSILFn->mapTypeIntoContext(paramTy)); + auto ¶mTI = IGF.getTypeInfo(IGF.CurSILFn->mapTypeIntoEnvironment(paramTy)); auto &argTI = IGF.getTypeInfo(param->getType()); // If the SIL parameter isn't passed indirectly, we need to map it @@ -2186,14 +2186,14 @@ static void emitEntryPointArgumentsNativeCC(IRGenSILFunction &IGF, auto errorType = fnConv.getSILErrorType(IGF.IGM.getMaximalTypeExpansionContext()); auto inContextErrorType = - IGF.CurSILFn->mapTypeIntoContext(errorType); + IGF.CurSILFn->mapTypeIntoEnvironment(errorType); bool isTypedError = fnConv.isTypedError(); bool isIndirectError = fnConv.hasIndirectSILErrorResults(); if (isTypedError && !isIndirectError) { auto resultType = fnConv.getSILResultType(IGF.IGM.getMaximalTypeExpansionContext()); - auto inContextResultType = IGF.CurSILFn->mapTypeIntoContext(resultType); + auto inContextResultType = IGF.CurSILFn->mapTypeIntoEnvironment(resultType); auto &resultTI = cast(IGF.getTypeInfo(inContextResultType)); auto &errorTI = cast(IGF.getTypeInfo(inContextErrorType)); @@ -4470,7 +4470,7 @@ static void emitReturnInst(IRGenSILFunction &IGF, auto getNullErrorValue = [&] () -> llvm::Value* { if (!conv.isTypedError()) { - auto errorResultType = IGF.CurSILFn->mapTypeIntoContext( + auto errorResultType = IGF.CurSILFn->mapTypeIntoEnvironment( conv.getSILErrorType(IGF.IGM.getMaximalTypeExpansionContext())); auto errorType = cast(IGF.IGM.getStorageType(errorResultType)); @@ -4484,7 +4484,7 @@ static void emitReturnInst(IRGenSILFunction &IGF, if (fnType->getCoroutineKind() == SILCoroutineKind::YieldOnce) { assert(IGF.CurSILFn->getLoweredFunctionType()->getLanguage() == SILFunctionLanguage::Swift); - auto funcResultType = IGF.CurSILFn->mapTypeIntoContext( + auto funcResultType = IGF.CurSILFn->mapTypeIntoEnvironment( conv.getSILResultType(IGF.IGM.getMaximalTypeExpansionContext())); emitYieldOnceCoroutineResult(IGF, result, funcResultType, resultTy); @@ -4500,7 +4500,7 @@ static void emitReturnInst(IRGenSILFunction &IGF, if (conv.hasAddressResult()) { assert(IGF.CurSILFn->getLoweredFunctionType()->getLanguage() == SILFunctionLanguage::Swift); - auto funcResultType = IGF.CurSILFn->mapTypeIntoContext( + auto funcResultType = IGF.CurSILFn->mapTypeIntoEnvironment( conv.getSILResultType(IGF.IGM.getMaximalTypeExpansionContext())); emitAddressResult(IGF, result, funcResultType, resultTy); @@ -4532,7 +4532,7 @@ static void emitReturnInst(IRGenSILFunction &IGF, } } - auto funcResultType = IGF.CurSILFn->mapTypeIntoContext( + auto funcResultType = IGF.CurSILFn->mapTypeIntoEnvironment( conv.getSILResultType(IGF.IGM.getMaximalTypeExpansionContext())); if (IGF.isAsync()) { @@ -4552,7 +4552,7 @@ static void emitReturnInst(IRGenSILFunction &IGF, SILType errorType; if (fnType->hasErrorResult() && conv.isTypedError() && !conv.hasIndirectSILResults() && !conv.hasIndirectSILErrorResults()) { - errorType = IGF.CurSILFn->mapTypeIntoContext( + errorType = IGF.CurSILFn->mapTypeIntoEnvironment( conv.getSILErrorType(IGF.IGM.getMaximalTypeExpansionContext())); } IGF.emitScalarReturn(resultTy, funcResultType, result, swiftCCReturn, false, @@ -4620,11 +4620,11 @@ void IRGenSILFunction::visitThrowInst(swift::ThrowInst *i) { llvm::Constant *flag = llvm::ConstantInt::get(IGM.IntPtrTy, 1); flag = llvm::ConstantExpr::getIntToPtr(flag, IGM.Int8PtrTy); Explosion errorResult = getLoweredExplosion(i->getOperand()); - auto silErrorTy = CurSILFn->mapTypeIntoContext( + auto silErrorTy = CurSILFn->mapTypeIntoEnvironment( conv.getSILErrorType(IGM.getMaximalTypeExpansionContext())); auto &errorTI = cast(IGM.getTypeInfo(silErrorTy)); - auto silResultTy = CurSILFn->mapTypeIntoContext( + auto silResultTy = CurSILFn->mapTypeIntoEnvironment( conv.getSILResultType(IGM.getMaximalTypeExpansionContext())); if (silErrorTy.getASTType()->isNever()) { @@ -4671,15 +4671,15 @@ void IRGenSILFunction::visitThrowInst(swift::ThrowInst *i) { auto exn = getLoweredExplosion(i->getOperand()); auto layout = getAsyncContextLayout(*this); - auto funcResultType = CurSILFn->mapTypeIntoContext( + auto funcResultType = CurSILFn->mapTypeIntoEnvironment( conv.getSILResultType(IGM.getMaximalTypeExpansionContext())); if (conv.isTypedError()) { - auto silErrorTy = CurSILFn->mapTypeIntoContext( + auto silErrorTy = CurSILFn->mapTypeIntoEnvironment( conv.getSILErrorType(IGM.getMaximalTypeExpansionContext())); auto &errorTI = cast(IGM.getTypeInfo(silErrorTy)); - auto silResultTy = CurSILFn->mapTypeIntoContext( + auto silResultTy = CurSILFn->mapTypeIntoEnvironment( conv.getSILResultType(IGM.getMaximalTypeExpansionContext())); auto &resultTI = cast(IGM.getTypeInfo(silResultTy)); auto &resultSchema = resultTI.nativeReturnValueSchema(IGM); @@ -4747,7 +4747,7 @@ void IRGenSILFunction::visitThrowAddrInst(swift::ThrowAddrInst *i) { // Async functions just return to the continuation. } else { auto layout = getAsyncContextLayout(*this); - auto funcResultType = CurSILFn->mapTypeIntoContext( + auto funcResultType = CurSILFn->mapTypeIntoEnvironment( conv.getSILResultType(IGM.getMaximalTypeExpansionContext())); llvm::Constant *flag = llvm::ConstantInt::get(IGM.IntPtrTy, 1); diff --git a/lib/IRGen/LoadableByAddress.cpp b/lib/IRGen/LoadableByAddress.cpp index 6dcdbd495bb8f..829912702b1ae 100644 --- a/lib/IRGen/LoadableByAddress.cpp +++ b/lib/IRGen/LoadableByAddress.cpp @@ -121,7 +121,7 @@ static bool isLargeLoadableType(GenericEnvironment *GenericEnv, SILType t, auto canType = t.getASTType(); if (canType->hasTypeParameter()) { assert(GenericEnv && "Expected a GenericEnv"); - canType = GenericEnv->mapTypeIntoContext(canType)->getCanonicalType(); + canType = GenericEnv->mapTypeIntoEnvironment(canType)->getCanonicalType(); } if (canType.getAnyGeneric() || t.is()) { @@ -1424,7 +1424,7 @@ void LoadableStorageAllocation::insertIndirectReturnArgs() { auto canType = resultStorageType.getASTType(); if (canType->hasTypeParameter()) { assert(genEnv && "Expected a GenericEnv"); - canType = genEnv->mapTypeIntoContext(canType)->getCanonicalType(); + canType = genEnv->mapTypeIntoEnvironment(canType)->getCanonicalType(); } resultStorageType = SILType::getPrimitiveObjectType(canType); auto newResultStorageType = @@ -3545,7 +3545,7 @@ class LargeLoadableHeuristic { auto canType = ty.getASTType(); if (canType->hasTypeParameter()) { assert(genEnv && "Expected a GenericEnv"); - canType = genEnv->mapTypeIntoContext(canType)->getCanonicalType(); + canType = genEnv->mapTypeIntoEnvironment(canType)->getCanonicalType(); } if (canType.getAnyGeneric() || isa(canType) || ty.is()) { @@ -3718,7 +3718,7 @@ bool LargeLoadableHeuristic::isPotentiallyCArray(SILType ty) { auto canType = ty.getASTType(); if (canType->hasTypeParameter()) { assert(genEnv && "Expected a GenericEnv"); - canType = genEnv->mapTypeIntoContext(canType)->getCanonicalType(); + canType = genEnv->mapTypeIntoEnvironment(canType)->getCanonicalType(); } if (canType.getAnyGeneric() || isa(canType)) { @@ -3742,7 +3742,7 @@ bool LargeLoadableHeuristic::isLargeLoadableTypeOld(SILType ty) { auto canType = ty.getASTType(); if (canType->hasTypeParameter()) { assert(genEnv && "Expected a GenericEnv"); - canType = genEnv->mapTypeIntoContext(canType)->getCanonicalType(); + canType = genEnv->mapTypeIntoEnvironment(canType)->getCanonicalType(); } if (canType.getAnyGeneric() || isa(canType)) { diff --git a/lib/IRGen/Outlining.cpp b/lib/IRGen/Outlining.cpp index 1b84a1256286a..c5c62805e0f48 100644 --- a/lib/IRGen/Outlining.cpp +++ b/lib/IRGen/Outlining.cpp @@ -276,7 +276,7 @@ irgen::getTypeAndGenericSignatureForManglingOutlineFunction(SILType type) { GenericEnvironment *env = digOutGenericEnvironment(loweredType); assert(env && "has archetype but no archetype?!"); - return {loweredType->mapTypeOutOfContext()->getCanonicalType(), + return {loweredType->mapTypeOutOfEnvironment()->getCanonicalType(), env->getGenericSignature().getCanonicalSignature()}; } diff --git a/lib/IRGen/TypeLayout.cpp b/lib/IRGen/TypeLayout.cpp index 61de9e4fb9251..1724e9314cd8a 100644 --- a/lib/IRGen/TypeLayout.cpp +++ b/lib/IRGen/TypeLayout.cpp @@ -472,7 +472,7 @@ llvm::Function *createMetatypeAccessorFunction(IRGenModule &IGM, SILType ty, std::string symbolName = mangler.mangleSymbolNameForMangledMetadataAccessorString( "get_type_metadata_for_layout_string", sig, - fieldType->mapTypeOutOfContext()->getCanonicalType(), + fieldType->mapTypeOutOfEnvironment()->getCanonicalType(), MangledTypeRefRole::Metadata); auto helperFn = IGM.getOrCreateHelperFunction( @@ -508,7 +508,7 @@ llvm::Function *createFixedEnumLoadTag(IRGenModule &IGM, IRGenMangler mangler(IGM.Context); auto symbol = mangler.mangleSymbolNameForMangledGetEnumTagForLayoutString( - entry.ty.getASTType()->mapTypeOutOfContext()->getCanonicalType()); + entry.ty.getASTType()->mapTypeOutOfEnvironment()->getCanonicalType()); auto helperFn = IGM.getOrCreateHelperFunction( symbol, IGM.Int32Ty /*retTy*/, IGM.Int8PtrTy /*argTys*/, @@ -1739,7 +1739,7 @@ AlignedGroupEntry::layoutString(IRGenModule &IGM, std::string symbolName = mangler.mangleSymbolNameForMangledMetadataAccessorString( "type_layout_string", genericSig.getCanonicalSignature(), - ty.getASTType()->mapTypeOutOfContext()->getCanonicalType(), + ty.getASTType()->mapTypeOutOfEnvironment()->getCanonicalType(), MangledTypeRefRole::Metadata); auto *global = SB.finishAndCreateGlobal(symbolName, IGM.getPointerAlignment(), @@ -2341,7 +2341,7 @@ EnumTypeLayoutEntry::layoutString(IRGenModule &IGM, std::string symbolName = mangler.mangleSymbolNameForMangledMetadataAccessorString( "type_layout_string", genericSig.getCanonicalSignature(), - ty.getASTType()->mapTypeOutOfContext()->getCanonicalType(), + ty.getASTType()->mapTypeOutOfEnvironment()->getCanonicalType(), MangledTypeRefRole::Metadata); auto *global = SB.finishAndCreateGlobal(symbolName, IGM.getPointerAlignment(), diff --git a/lib/SIL/IR/AbstractionPattern.cpp b/lib/SIL/IR/AbstractionPattern.cpp index 61b9309e2ce39..8c8b1de1181fa 100644 --- a/lib/SIL/IR/AbstractionPattern.cpp +++ b/lib/SIL/IR/AbstractionPattern.cpp @@ -97,7 +97,7 @@ TypeConverter::getAbstractionPattern(VarDecl *var, bool isNonObjC) { if (auto clangDecl = var->getClangDecl()) { auto clangType = getClangType(clangDecl); - auto contextType = var->getDeclContext()->mapTypeIntoContext(swiftType); + auto contextType = var->getDeclContext()->mapTypeIntoEnvironment(swiftType); swiftType = getLoweredBridgedType(AbstractionPattern(sig, swiftType, clangType), contextType, getClangDeclBridgeability(clangDecl), @@ -324,7 +324,7 @@ bool AbstractionPattern::conformsToKnownProtocol( // that ensures the type conforms. auto type = getType(); if (hasGenericSignature() && getType()->hasTypeParameter()) { - type = GenericEnvironment::mapTypeIntoContext( + type = GenericEnvironment::mapTypeIntoEnvironment( getGenericSignature().getGenericEnvironment(), getType()) ->getReducedType(getGenericSignature()); } diff --git a/lib/SIL/IR/SIL.cpp b/lib/SIL/IR/SIL.cpp index d03ee74f91f7d..6c92f75589263 100644 --- a/lib/SIL/IR/SIL.cpp +++ b/lib/SIL/IR/SIL.cpp @@ -330,9 +330,9 @@ getKeyPathSupportingGenericSignature(Type ty, GenericSignature contextSig) { // If the type is an archetype, then it just needs Copyable and Escapable // constraints imposed. if (ty->is()) { - copyable = ProtocolConformanceRef::forAbstract(ty->mapTypeOutOfContext(), + copyable = ProtocolConformanceRef::forAbstract(ty->mapTypeOutOfEnvironment(), copyableProtocol); - escapable = ProtocolConformanceRef::forAbstract(ty->mapTypeOutOfContext(), + escapable = ProtocolConformanceRef::forAbstract(ty->mapTypeOutOfEnvironment(), escapableProtocol); } else { // Look for any conditional conformances. @@ -355,9 +355,9 @@ getKeyPathSupportingGenericSignature(Type ty, GenericSignature contextSig) { // The only requirements are that the abstract type itself be copyable // and escapable. ceRequirements.push_back(Requirement(RequirementKind::Conformance, - ty->mapTypeOutOfContext(), copyableProtocol->getDeclaredType())); + ty->mapTypeOutOfEnvironment(), copyableProtocol->getDeclaredType())); ceRequirements.push_back(Requirement(RequirementKind::Conformance, - ty->mapTypeOutOfContext(), escapableProtocol->getDeclaredType())); + ty->mapTypeOutOfEnvironment(), escapableProtocol->getDeclaredType())); return; } @@ -518,7 +518,7 @@ AbstractStorageDecl::getPropertyDescriptorGenericSignature() const { llvm_unreachable("should be definition linkage?"); } - auto typeInContext = contextSig.getGenericEnvironment()->mapTypeIntoContext( + auto typeInContext = contextSig.getGenericEnvironment()->mapTypeIntoEnvironment( getValueInterfaceType()); auto valueTypeSig = getKeyPathSupportingGenericSignatureForValueType(typeInContext, contextSig); if (!valueTypeSig) { diff --git a/lib/SIL/IR/SILFunction.cpp b/lib/SIL/IR/SILFunction.cpp index 13deeee9bc7ef..f5b25418a6624 100644 --- a/lib/SIL/IR/SILFunction.cpp +++ b/lib/SIL/IR/SILFunction.cpp @@ -509,7 +509,7 @@ bool SILFunction::shouldOptimize() const { return getEffectiveOptimizationMode() != OptimizationMode::NoOptimization; } -Type SILFunction::mapTypeIntoContext(Type type) const { +Type SILFunction::mapTypeIntoEnvironment(Type type) const { assert(!type->hasPrimaryArchetype()); if (GenericEnv) { @@ -517,7 +517,7 @@ Type SILFunction::mapTypeIntoContext(Type type) const { // type, which might contain element archetypes, if it was the interface type // of a closure or local variable. if (type->hasElementArchetype()) - return GenericEnv->mapTypeIntoContext(type); + return GenericEnv->mapTypeIntoEnvironment(type); // Otherwise, assume we have an interface type for the "combined" captured // environment. @@ -530,7 +530,7 @@ Type SILFunction::mapTypeIntoContext(Type type) const { return type; } -SILType SILFunction::mapTypeIntoContext(SILType type) const { +SILType SILFunction::mapTypeIntoEnvironment(SILType type) const { assert(!type.hasPrimaryArchetype()); if (GenericEnv) { @@ -546,7 +546,7 @@ SILType SILFunction::mapTypeIntoContext(SILType type) const { return type; } -SILType GenericEnvironment::mapTypeIntoContext(SILModule &M, +SILType GenericEnvironment::mapTypeIntoEnvironment(SILModule &M, SILType type) const { assert(!type.hasPrimaryArchetype()); diff --git a/lib/SIL/IR/SILFunctionType.cpp b/lib/SIL/IR/SILFunctionType.cpp index d98e2c83003bf..463e4d40dc6cb 100644 --- a/lib/SIL/IR/SILFunctionType.cpp +++ b/lib/SIL/IR/SILFunctionType.cpp @@ -2204,7 +2204,7 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function, auto capturedEnvs = loweredCaptures.getGenericEnvironments(); auto *isolatedParam = loweredCaptures.getIsolatedParamCapture(); - auto mapTypeOutOfContext = [&](Type t) -> CanType { + auto mapTypeOutOfEnvironment = [&](Type t) -> CanType { LLVM_DEBUG(llvm::dbgs() << "-- capture with contextual type " << t << "\n"); auto result = mapLocalArchetypesOutOfContext(t, origGenericSig, capturedEnvs) @@ -2218,7 +2218,7 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function, if (capture.isDynamicSelfMetadata()) { ParameterConvention convention = ParameterConvention::Direct_Unowned; auto dynamicSelfInterfaceType = - mapTypeOutOfContext(loweredCaptures.getDynamicSelfType()); + mapTypeOutOfEnvironment(loweredCaptures.getDynamicSelfType()); auto selfMetatype = CanMetatypeType::get(dynamicSelfInterfaceType, MetatypeRepresentation::Thick); @@ -2231,7 +2231,7 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function, if (capture.isOpaqueValue()) { OpaqueValueExpr *opaqueValue = capture.getOpaqueValue(); - auto canType = mapTypeOutOfContext(opaqueValue->getType()); + auto canType = mapTypeOutOfEnvironment(opaqueValue->getType()); auto &loweredTL = TC.getTypeLowering(AbstractionPattern(genericSig, canType), canType, expansion); @@ -2279,7 +2279,7 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function, (genericSig && origGenericSig && !genericSig->isEqual(origGenericSig))); - auto interfaceType = mapTypeOutOfContext(type)->getReducedType( + auto interfaceType = mapTypeOutOfEnvironment(type)->getReducedType( genericSig ? genericSig : origGenericSig); auto &loweredTL = TC.getTypeLowering(AbstractionPattern(genericSig, interfaceType), @@ -3440,7 +3440,7 @@ CanSILFunctionType swift::buildSILFunctionThunkType( auto substFormalTypeIntoThunkContext = [&](CanType t) -> CanType { - return GenericEnvironment::mapTypeIntoContext( + return GenericEnvironment::mapTypeIntoEnvironment( genericEnv, mapLocalArchetypesOutOfContext(t, baseGenericSig, capturedEnvs)) ->getCanonicalType(); @@ -3448,7 +3448,7 @@ CanSILFunctionType swift::buildSILFunctionThunkType( auto substLoweredTypeIntoThunkContext = [&](CanSILFunctionType t) -> CanSILFunctionType { return cast( - GenericEnvironment::mapTypeIntoContext( + GenericEnvironment::mapTypeIntoEnvironment( genericEnv, mapLocalArchetypesOutOfContext(t, baseGenericSig, capturedEnvs)) ->getCanonicalType()); @@ -3517,8 +3517,8 @@ CanSILFunctionType swift::buildSILFunctionThunkType( params.push_back({dynamicSelfType, ParameterConvention::Direct_Unowned}); } - auto mapTypeOutOfContext = [&](CanType type) -> CanType { - return type->mapTypeOutOfContext()->getCanonicalType(); + auto mapTypeOutOfEnvironment = [&](CanType type) -> CanType { + return type->mapTypeOutOfEnvironment()->getCanonicalType(); }; // Map the parameter and expected types out of context to get the interface @@ -3526,26 +3526,26 @@ CanSILFunctionType swift::buildSILFunctionThunkType( SmallVector interfaceParams; interfaceParams.reserve(params.size()); for (auto ¶m : params) { - auto interfaceParam = param.map(mapTypeOutOfContext); + auto interfaceParam = param.map(mapTypeOutOfEnvironment); interfaceParams.push_back(interfaceParam); } SmallVector interfaceYields; for (auto &yield : expectedType->getYields()) { - auto interfaceYield = yield.map(mapTypeOutOfContext); + auto interfaceYield = yield.map(mapTypeOutOfEnvironment); interfaceYields.push_back(interfaceYield); } SmallVector interfaceResults; for (auto &result : expectedType->getResults()) { - auto interfaceResult = result.map(mapTypeOutOfContext); + auto interfaceResult = result.map(mapTypeOutOfEnvironment); interfaceResults.push_back(interfaceResult); } std::optional interfaceErrorResult; if (expectedType->hasErrorResult()) { auto errorResult = expectedType->getErrorResult(); - interfaceErrorResult = errorResult.map(mapTypeOutOfContext);; + interfaceErrorResult = errorResult.map(mapTypeOutOfEnvironment);; } // The type of the thunk function. diff --git a/lib/SIL/IR/SILPrinter.cpp b/lib/SIL/IR/SILPrinter.cpp index 0d6b1f985b7a3..6e2b4fa6a82bc 100644 --- a/lib/SIL/IR/SILPrinter.cpp +++ b/lib/SIL/IR/SILPrinter.cpp @@ -610,7 +610,7 @@ static void printSILFunctionNameAndType( // defined). sugaredTypeNames[paramTy->getCanonicalType()] = name; if (auto *archetypeTy = - genEnv->mapTypeIntoContext(paramTy)->getAs()) + genEnv->mapTypeIntoEnvironment(paramTy)->getAs()) sugaredTypeNames[archetypeTy->getCanonicalType()] = name; } } diff --git a/lib/SIL/IR/SILType.cpp b/lib/SIL/IR/SILType.cpp index 8f4e4219db037..6f44758b275ad 100644 --- a/lib/SIL/IR/SILType.cpp +++ b/lib/SIL/IR/SILType.cpp @@ -142,18 +142,18 @@ SILType SILType::getUnsafeRawPointer(const ASTContext &ctx) { } bool SILType::isTrivial(const SILFunction &F) const { - auto contextType = hasTypeParameter() ? F.mapTypeIntoContext(*this) : *this; + auto contextType = hasTypeParameter() ? F.mapTypeIntoEnvironment(*this) : *this; return F.getTypeProperties(contextType).isTrivial(); } bool SILType::isOrContainsRawPointer(const SILFunction &F) const { - auto contextType = hasTypeParameter() ? F.mapTypeIntoContext(*this) : *this; + auto contextType = hasTypeParameter() ? F.mapTypeIntoEnvironment(*this) : *this; return F.getTypeProperties(contextType).isOrContainsRawPointer(); } bool SILType::isNonTrivialOrContainsRawPointer(const SILFunction *f) const { - auto contextType = hasTypeParameter() ? f->mapTypeIntoContext(*this) : *this; + auto contextType = hasTypeParameter() ? f->mapTypeIntoEnvironment(*this) : *this; auto props = f->getTypeProperties(contextType); bool result = !props.isTrivial() || props.isOrContainsRawPointer(); assert((result || !isFunctionTypeWithContext()) && @@ -162,7 +162,7 @@ bool SILType::isNonTrivialOrContainsRawPointer(const SILFunction *f) const { } bool SILType::isOrContainsPack(const SILFunction &F) const { - auto contextType = hasTypeParameter() ? F.mapTypeIntoContext(*this) : *this; + auto contextType = hasTypeParameter() ? F.mapTypeIntoEnvironment(*this) : *this; return F.getTypeProperties(contextType).isOrContainsPack(); } @@ -232,7 +232,7 @@ bool SILType::isNoReturnFunction(SILModule &M, } Lifetime SILType::getLifetime(const SILFunction &F) const { - auto contextType = hasTypeParameter() ? F.mapTypeIntoContext(*this) : *this; + auto contextType = hasTypeParameter() ? F.mapTypeIntoEnvironment(*this) : *this; auto properties = F.getTypeProperties(contextType); if (properties.isTrivial()) return Lifetime::None; @@ -488,13 +488,13 @@ bool SILType::isLoadableOrOpaque(const SILFunction &F) const { } bool SILType::isAddressOnly(const SILFunction &F) const { - auto contextType = hasTypeParameter() ? F.mapTypeIntoContext(*this) : *this; + auto contextType = hasTypeParameter() ? F.mapTypeIntoEnvironment(*this) : *this; return F.getTypeLowering(contextType).isAddressOnly(); } bool SILType::isFixedABI(const SILFunction &F) const { - auto contextType = hasTypeParameter() ? F.mapTypeIntoContext(*this) : *this; + auto contextType = hasTypeParameter() ? F.mapTypeIntoEnvironment(*this) : *this; return F.getTypeProperties(contextType).isFixedABI(); } @@ -641,13 +641,13 @@ SILType::canUseExistentialRepresentation(ExistentialRepresentation repr, llvm_unreachable("Unhandled ExistentialRepresentation in switch."); } -SILType SILType::mapTypeOutOfContext() const { - return SILType::getPrimitiveType(mapTypeOutOfContext(getASTType()), +SILType SILType::mapTypeOutOfEnvironment() const { + return SILType::getPrimitiveType(mapTypeOutOfEnvironment(getASTType()), getCategory()); } -CanType SILType::mapTypeOutOfContext(CanType type) { - return type->mapTypeOutOfContext()->getCanonicalType(); +CanType SILType::mapTypeOutOfEnvironment(CanType type) { + return type->mapTypeOutOfEnvironment()->getCanonicalType(); } CanType swift::getSILBoxFieldLoweredType(TypeExpansionContext context, @@ -774,7 +774,7 @@ bool SILFunctionType::isAddressable(unsigned paramIdx, SILModule &module, if (condAddressableIndices && condAddressableIndices->contains(paramIdx)) { CanType argType = paramInfo.getArgumentType(module, this, expansion); CanType contextType = genericEnv - ? genericEnv->mapTypeIntoContext(argType)->getCanonicalType() + ? genericEnv->mapTypeIntoEnvironment(argType)->getCanonicalType() : argType; assert(!contextType->hasTypeParameter()); if (typeConverter.getTypeProperties(contextType, expansion) @@ -1229,7 +1229,7 @@ bool SILType::isMarkedAsImmortal() const { bool SILType::isAddressableForDeps(const SILFunction &function) const { auto contextType = - hasTypeParameter() ? function.mapTypeIntoContext(*this) : *this; + hasTypeParameter() ? function.mapTypeIntoEnvironment(*this) : *this; auto properties = function.getTypeProperties(contextType); return properties.isAddressableForDependencies(); } @@ -1375,7 +1375,7 @@ SILType::getConcurrencyDiagnosticBehavior(SILFunction *fn) const { bool SILType::mayHaveCustomDeinit(const SILFunction &function) const { auto contextType = - hasTypeParameter() ? function.mapTypeIntoContext(*this) : *this; + hasTypeParameter() ? function.mapTypeIntoEnvironment(*this) : *this; auto properties = function.getTypeProperties(contextType); return properties.mayHaveCustomDeinit(); } diff --git a/lib/SIL/IR/TypeLowering.cpp b/lib/SIL/IR/TypeLowering.cpp index ffeb8a2fb92cf..bd1db1863d7e4 100644 --- a/lib/SIL/IR/TypeLowering.cpp +++ b/lib/SIL/IR/TypeLowering.cpp @@ -3985,7 +3985,7 @@ static CanAnyFunctionType getDefaultArgGeneratorInterfaceType( Type resultTy; if (auto type = pd->getTypeOfDefaultExpr()) { - resultTy = type->mapTypeOutOfContext(); + resultTy = type->mapTypeOutOfEnvironment(); } else { resultTy = pd->getInterfaceType(); } @@ -4016,7 +4016,7 @@ static CanAnyFunctionType getStoredPropertyInitializerInterfaceType( VarDecl *VD) { auto *DC = VD->getDeclContext(); CanType resultTy = - VD->getParentPattern()->getType()->mapTypeOutOfContext() + VD->getParentPattern()->getType()->mapTypeOutOfEnvironment() ->getCanonicalType(); // If this is the backing storage for a property with an attached diff --git a/lib/SIL/Parser/ParseSIL.cpp b/lib/SIL/Parser/ParseSIL.cpp index b699b15a333f0..8a265528714f7 100644 --- a/lib/SIL/Parser/ParseSIL.cpp +++ b/lib/SIL/Parser/ParseSIL.cpp @@ -1095,7 +1095,7 @@ bool SILParser::parseASTType(CanType &result, parsedType.get(), /*isSILType=*/false, genericSig, genericParams); if (wantContextualType && genericSig) { resolvedType = genericSig.getGenericEnvironment() - ->mapTypeIntoContext(resolvedType); + ->mapTypeIntoEnvironment(resolvedType); } if (resolvedType->hasError()) @@ -1131,7 +1131,7 @@ bool SILParser::parseASTTypeOrValue(CanType &result, parsedType.get(), /*isSILType=*/false, genericSig, genericParams); if (wantContextualType && genericSig) { resolvedType = genericSig.getGenericEnvironment() - ->mapTypeIntoContext(resolvedType); + ->mapTypeIntoEnvironment(resolvedType); } if (resolvedType->hasError()) @@ -1241,7 +1241,7 @@ bool SILParser::parseSILType(SILType &Result, auto Ty = performTypeResolution(attrRepr, /*IsSILType=*/true, OuterGenericSig, OuterGenericParams); if (OuterGenericSig) { - Ty = OuterGenericSig.getGenericEnvironment()->mapTypeIntoContext(Ty); + Ty = OuterGenericSig.getGenericEnvironment()->mapTypeIntoEnvironment(Ty); } if (Ty->hasError()) @@ -1843,7 +1843,7 @@ bool SILParser::parseSubstitutions(SmallVectorImpl &parsed, auto Ty = performTypeResolution(TyR.get(), /*IsSILType=*/false, GenericSig, GenericParams); if (GenericSig) { - Ty = GenericSig.getGenericEnvironment()->mapTypeIntoContext(Ty); + Ty = GenericSig.getGenericEnvironment()->mapTypeIntoEnvironment(Ty); } if (Ty->hasError()) @@ -2366,7 +2366,7 @@ SILParser::parseKeyPathPatternComponent(KeyPathPatternComponent &component, if (patternSig) loweredTy = SILType::getPrimitiveType(loweredTy.getRawASTType() - ->mapTypeOutOfContext() + ->mapTypeOutOfEnvironment() ->getCanonicalType(), loweredTy.getCategory()); @@ -2375,7 +2375,7 @@ SILParser::parseKeyPathPatternComponent(KeyPathPatternComponent &component, Type contextFormalTy = formalTy; if (patternSig) { contextFormalTy = patternSig.getGenericEnvironment() - ->mapTypeIntoContext(formalTy); + ->mapTypeIntoEnvironment(formalTy); } auto lookup = lookupConformance(contextFormalTy, proto); if (lookup.isInvalid()) { @@ -2509,7 +2509,7 @@ SILParser::parseKeyPathPatternComponent(KeyPathPatternComponent &component, // Map the substitutions out of the pattern context so that they // use interface types. externalSubs = - externalSubs.mapReplacementTypesOutOfContext().getCanonical(); + externalSubs.mapReplacementTypesOutOfEnvironment().getCanonical(); } } else { @@ -3291,7 +3291,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B, return true; // Map it out of context. It should be a type pack parameter. - shapeClass = shapeClass->mapTypeOutOfContext()->getCanonicalType(); + shapeClass = shapeClass->mapTypeOutOfEnvironment()->getCanonicalType(); auto shapeParam = dyn_cast(shapeClass); if (!shapeParam || !shapeParam->isParameterPack()) { P.diagnose(shapeClassLoc, diag::opened_shape_class_not_pack_param); @@ -8157,7 +8157,7 @@ ProtocolConformanceRef SILParser::parseProtocolConformanceHelper( witnessSig, witnessParams); if (witnessSig) { ConformingTy = witnessSig.getGenericEnvironment() - ->mapTypeIntoContext(ConformingTy); + ->mapTypeIntoEnvironment(ConformingTy); } if (ConformingTy->hasError()) @@ -8282,7 +8282,7 @@ static bool parseSILWitnessTableEntry( witnessSig, &silContext, &P.SF); if (witnessSig) { - Ty = witnessSig.getGenericEnvironment()->mapTypeIntoContext(Ty); + Ty = witnessSig.getGenericEnvironment()->mapTypeIntoEnvironment(Ty); } if (Ty->hasError()) @@ -8325,7 +8325,7 @@ static bool parseSILWitnessTableEntry( witnessSig, &silContext, &P.SF); if (witnessSig) { - Ty = witnessSig.getGenericEnvironment()->mapTypeIntoContext(Ty); + Ty = witnessSig.getGenericEnvironment()->mapTypeIntoEnvironment(Ty); } if (Ty->hasError()) @@ -8366,7 +8366,7 @@ static bool parseSILWitnessTableEntry( witnessSig, &silContext, &P.SF); if (witnessSig) { - Ty = witnessSig.getGenericEnvironment()->mapTypeIntoContext(Ty); + Ty = witnessSig.getGenericEnvironment()->mapTypeIntoEnvironment(Ty); } if (Ty->hasError()) diff --git a/lib/SIL/Utils/GenericSpecializationMangler.cpp b/lib/SIL/Utils/GenericSpecializationMangler.cpp index 6b3da8eed20b6..6016725737e36 100644 --- a/lib/SIL/Utils/GenericSpecializationMangler.cpp +++ b/lib/SIL/Utils/GenericSpecializationMangler.cpp @@ -176,7 +176,7 @@ getSubstitutionMapForPrespecialization(GenericSignature genericSig, [&](SubstitutableType *type) -> Type { auto SpecializedInterfaceTy = Type(type).subst(CalleeInterfaceToSpecializedInterfaceMap); - return SpecializedGenericEnv->mapTypeIntoContext( + return SpecializedGenericEnv->mapTypeIntoEnvironment( SpecializedInterfaceTy); }, LookUpConformanceInModule()); diff --git a/lib/SIL/Verifier/SILVerifier.cpp b/lib/SIL/Verifier/SILVerifier.cpp index d8b007ffb81e2..f454cbcf64196 100644 --- a/lib/SIL/Verifier/SILVerifier.cpp +++ b/lib/SIL/Verifier/SILVerifier.cpp @@ -5382,7 +5382,7 @@ class SILVerifier : public SILVerifierBase { LLVM_DEBUG(RI->print(llvm::dbgs())); SILType functionResultType = - F.getLoweredType(F.mapTypeIntoContext(fnConv.getSILResultType( + F.getLoweredType(F.mapTypeIntoEnvironment(fnConv.getSILResultType( F.getTypeExpansionContext())) .getASTType()) .getCategoryType( @@ -5415,7 +5415,7 @@ class SILVerifier : public SILVerifierBase { "throw in function that doesn't have an error result"); SILType functionResultType = - F.getLoweredType(F.mapTypeIntoContext(fnConv.getSILErrorType( + F.getLoweredType(F.mapTypeIntoEnvironment(fnConv.getSILErrorType( F.getTypeExpansionContext())) .getASTType()) .getCategoryType(fnConv.getSILErrorType(F.getTypeExpansionContext()) @@ -5444,7 +5444,7 @@ class SILVerifier : public SILVerifierBase { require(yieldedValues.size() == yieldInfos.size(), "wrong number of yielded values for function"); for (auto i : indices(yieldedValues)) { - SILType yieldType = F.mapTypeIntoContext( + SILType yieldType = F.mapTypeIntoEnvironment( fnConv.getSILType(yieldInfos[i], F.getTypeExpansionContext())); requireSameType(yieldedValues[i]->getType(), yieldType, "yielded value does not match yield type of coroutine"); @@ -6446,7 +6446,7 @@ class SILVerifier : public SILVerifierBase { auto interfaceTy = archetype->getInterfaceType(); auto rootParamTy = interfaceTy->getRootGenericParam(); - auto root = genericEnv->mapTypeIntoContext( + auto root = genericEnv->mapTypeIntoEnvironment( rootParamTy)->castTo(); auto it = allOpened.find(root->getCanonicalType()); assert(it != allOpened.end()); @@ -6619,7 +6619,7 @@ class SILVerifier : public SILVerifierBase { auto argI = entry->args_begin(); auto check = [&](const char *what, SILType ty) { - auto mappedTy = F.mapTypeIntoContext(ty); + auto mappedTy = F.mapTypeIntoEnvironment(ty); SILArgument *bbarg = *argI; ++argI; if (bbarg->getType() != mappedTy && @@ -7813,7 +7813,7 @@ CanType SILProperty::getBaseType() const { if (sig) { auto env = dc->getGenericEnvironmentOfContext(); - baseTy = env->mapTypeIntoContext(baseTy)->getCanonicalType(); + baseTy = env->mapTypeIntoEnvironment(baseTy)->getCanonicalType(); } return baseTy; @@ -7832,7 +7832,7 @@ void SILProperty::verify(const SILModule &M) const { auto env = decl->getInnermostDeclContext()->getGenericEnvironmentOfContext(); subs = env->getForwardingSubstitutionMap(); - leafTy = env->mapTypeIntoContext(leafTy)->getCanonicalType(); + leafTy = env->mapTypeIntoEnvironment(leafTy)->getCanonicalType(); } bool hasIndices = false; if (auto subscript = dyn_cast(decl)) { diff --git a/lib/SILGen/ResultPlan.cpp b/lib/SILGen/ResultPlan.cpp index cb40b57b0588f..77bffc8957f91 100644 --- a/lib/SILGen/ResultPlan.cpp +++ b/lib/SILGen/ResultPlan.cpp @@ -835,9 +835,9 @@ class ForeignAsyncInitializationPlan final : public ResultPlan { SILFunction *impl = SGF.SGM.getOrCreateForeignAsyncCompletionHandlerImplFunction( cast( - impFnTy->mapTypeOutOfContext()->getReducedType(sig)), - blockStorageTy->mapTypeOutOfContext()->getReducedType(sig), - continuationTy->mapTypeOutOfContext()->getReducedType(sig), + impFnTy->mapTypeOutOfEnvironment()->getReducedType(sig)), + blockStorageTy->mapTypeOutOfEnvironment()->getReducedType(sig), + continuationTy->mapTypeOutOfEnvironment()->getReducedType(sig), origFormalType, sig, calleeTypeInfo); auto impRef = SGF.B.createFunctionRef(loc, impl); @@ -948,7 +948,7 @@ class ForeignAsyncInitializationPlan final : public ResultPlan { } auto mappedOutContinuationTy = - continuationTy->mapTypeOutOfContext()->getCanonicalType(); + continuationTy->mapTypeOutOfEnvironment()->getCanonicalType(); auto resumeType = cast(mappedOutContinuationTy).getGenericArgs()[0]; @@ -958,7 +958,7 @@ class ForeignAsyncInitializationPlan final : public ResultPlan { : SGF.SGM.getResumeUnsafeThrowingContinuationWithError(); Type replacementTypes[] = { - SGF.F.mapTypeIntoContext(resumeType)->getCanonicalType()}; + SGF.F.mapTypeIntoEnvironment(resumeType)->getCanonicalType()}; auto subs = SubstitutionMap::get(errorIntrinsic->getGenericSignature(), replacementTypes, LookUpConformanceInModule()); diff --git a/lib/SILGen/SILGen.cpp b/lib/SILGen/SILGen.cpp index 0d8a3abf48876..49dee62c8f47d 100644 --- a/lib/SILGen/SILGen.cpp +++ b/lib/SILGen/SILGen.cpp @@ -2092,7 +2092,7 @@ SILGenModule::canStorageUseStoredKeyPathComponent(AbstractStorageDecl *decl, auto componentObjTy = decl->getValueInterfaceType(); if (auto genericEnv = decl->getInnermostDeclContext()->getGenericEnvironmentOfContext()) - componentObjTy = genericEnv->mapTypeIntoContext(componentObjTy); + componentObjTy = genericEnv->mapTypeIntoEnvironment(componentObjTy); auto storageTy = M.Types.getSubstitutedStorageType( TypeExpansionContext::minimal(), decl, componentObjTy); auto opaqueTy = M.Types.getLoweredRValueType( diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp index 553a9a97d6af8..5dae91a02f9ba 100644 --- a/lib/SILGen/SILGenApply.cpp +++ b/lib/SILGen/SILGenApply.cpp @@ -6375,7 +6375,7 @@ SILValue SILGenFunction::emitApplyWithRethrow(SILLocation loc, SILValue fn, // Convert to the outer error, if we need to. SILValue outerError; SILType innerErrorType = innerError->getType().getObjectType(); - SILType outerErrorType = F.mapTypeIntoContext( + SILType outerErrorType = F.mapTypeIntoEnvironment( F.getConventions().getSILErrorType(getTypeExpansionContext())); if (IndirectErrorResult && IndirectErrorResult == innerError) { // Fast path: we aliased the indirect error result slot because both are @@ -6506,7 +6506,7 @@ void SILGenFunction::emitYield(SILLocation loc, SmallVector substYieldTys; for (auto origYield : fnType->getYields()) { substYieldTys.push_back( - {F.mapTypeIntoContext(origYield.getArgumentType( + {F.mapTypeIntoEnvironment(origYield.getArgumentType( SGM.M, fnType, getTypeExpansionContext())) ->getCanonicalType(), origYield.getConvention()}); diff --git a/lib/SILGen/SILGenAvailability.cpp b/lib/SILGen/SILGenAvailability.cpp index f289c3a44da5b..936b1ec0accc9 100644 --- a/lib/SILGen/SILGenAvailability.cpp +++ b/lib/SILGen/SILGenAvailability.cpp @@ -233,14 +233,14 @@ static void emitBackDeployForwardApplyAndReturnOrThrow( // Emit error block. SGF.B.emitBlock(errorBB); ManagedValue error = - SGF.B.createPhi(SGF.F.mapTypeIntoContext(fnConv.getSILErrorType(TEC)), + SGF.B.createPhi(SGF.F.mapTypeIntoEnvironment(fnConv.getSILErrorType(TEC)), OwnershipKind::Owned); SGF.B.createBranch(loc, SGF.ThrowDest.getBlock(), {error}); // Emit normal block. SGF.B.emitBlock(normalBB); SILValue result = normalBB->createPhiArgument( - SGF.F.mapTypeIntoContext(fnConv.getSILResultType(TEC)), + SGF.F.mapTypeIntoEnvironment(fnConv.getSILResultType(TEC)), OwnershipKind::Owned); SmallVector directResults; extractAllElements(result, loc, SGF.B, directResults); diff --git a/lib/SILGen/SILGenBridging.cpp b/lib/SILGen/SILGenBridging.cpp index 1ce8eb2562e7e..d169025ea8c47 100644 --- a/lib/SILGen/SILGenBridging.cpp +++ b/lib/SILGen/SILGenBridging.cpp @@ -561,9 +561,9 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc, // Build the invoke function signature. The block will capture the original // function value. auto fnInterfaceTy = cast( - loweredFuncUnsubstTy->mapTypeOutOfContext()->getCanonicalType()); + loweredFuncUnsubstTy->mapTypeOutOfEnvironment()->getCanonicalType()); auto blockInterfaceTy = cast( - loweredBlockTy->mapTypeOutOfContext()->getCanonicalType()); + loweredBlockTy->mapTypeOutOfEnvironment()->getCanonicalType()); assert(!blockInterfaceTy->isCoroutine()); @@ -1722,7 +1722,7 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) { SILFunctionConventions objcConv(CanSILFunctionType(objcFnTy), SGM.M); SILFunctionConventions nativeConv(CanSILFunctionType(nativeInfo.SILFnType), SGM.M); - auto swiftResultTy = F.mapTypeIntoContext( + auto swiftResultTy = F.mapTypeIntoEnvironment( nativeConv.getSILResultType(getTypeExpansionContext())); auto objcResultTy = objcConv.getSILResultType(getTypeExpansionContext()); @@ -2183,13 +2183,13 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) { // type rather than the declaration. auto selfArgTy = F.getLoweredFunctionType()->getSelfParameter() .getSILStorageType(getModule(), F.getLoweredFunctionType(), getTypeExpansionContext()); - auto selfArg = F.begin()->createFunctionArgument(F.mapTypeIntoContext(selfArgTy), selfDecl); + auto selfArg = F.begin()->createFunctionArgument(F.mapTypeIntoEnvironment(selfArgTy), selfDecl); params.push_back(selfArg); // For allocating constructors, 'self' is a metatype, not the 'self' value // formally present in the constructor body. if (thunk.kind == SILDeclRef::Kind::Allocator) { - allocatorSelfType = F.mapTypeIntoContext( + allocatorSelfType = F.mapTypeIntoEnvironment( fd->getDeclContext()->getSelfInterfaceType()); } } @@ -2293,10 +2293,10 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) { } CanType nativeFormalType = - F.mapTypeIntoContext(nativeFormalParams[nativeParamIndex]) + F.mapTypeIntoEnvironment(nativeFormalParams[nativeParamIndex]) ->getCanonicalType(); CanType foreignFormalType = - F.mapTypeIntoContext(foreignFormalParams[nativeParamIndex]) + F.mapTypeIntoEnvironment(foreignFormalParams[nativeParamIndex]) ->getCanonicalType(); if (isSelf) { @@ -2307,7 +2307,7 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) { auto foreignParam = foreignFnTy->getParameters()[foreignArgIndex++]; SILType foreignLoweredTy = - F.mapTypeIntoContext(foreignParam.getSILStorageType( + F.mapTypeIntoEnvironment(foreignParam.getSILStorageType( F.getModule(), foreignFnTy, F.getTypeExpansionContext())); auto bridged = emitNativeToBridgedValue(fd, param, nativeFormalType, @@ -2342,10 +2342,10 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) { fnType = fnType->substGenericArgs(SGM.M, subs, getTypeExpansionContext()); CanType nativeFormalResultType = - fd->mapTypeIntoContext(nativeCI.LoweredType.getResult()) + fd->mapTypeIntoEnvironment(nativeCI.LoweredType.getResult()) ->getCanonicalType(); CanType bridgedFormalResultType = - fd->mapTypeIntoContext(foreignCI.LoweredType.getResult()) + fd->mapTypeIntoEnvironment(foreignCI.LoweredType.getResult()) ->getCanonicalType(); CalleeTypeInfo calleeTypeInfo( fnType, AbstractionPattern(nativeFnTy->getInvocationGenericSignature(), diff --git a/lib/SILGen/SILGenConcurrency.cpp b/lib/SILGen/SILGenConcurrency.cpp index 2a4eef22fba13..b03fcd82fcad6 100644 --- a/lib/SILGen/SILGenConcurrency.cpp +++ b/lib/SILGen/SILGenConcurrency.cpp @@ -196,7 +196,7 @@ void SILGenFunction::emitExpectedExecutorProlog() { case ActorIsolation::GlobalActor: if (F.isAsync() || wantDataRaceChecks) { - auto globalActorType = F.mapTypeIntoContext(actorIsolation.getGlobalActor()); + auto globalActorType = F.mapTypeIntoEnvironment(actorIsolation.getGlobalActor()); setExpectedExecutorForGlobalActor(*this, globalActorType); } break; @@ -228,7 +228,7 @@ void SILGenFunction::emitExpectedExecutorProlog() { case ActorIsolation::GlobalActor: if (wantExecutor) { - auto globalActorType = F.mapTypeIntoContext(actorIsolation.getGlobalActor()); + auto globalActorType = F.mapTypeIntoEnvironment(actorIsolation.getGlobalActor()); setExpectedExecutorForGlobalActor(*this, globalActorType); break; } @@ -660,7 +660,7 @@ SILGenFunction::emitClosureIsolation(SILLocation loc, SILDeclRef constant, llvm_unreachable("closures cannot directly have erased isolation"); case ActorIsolation::GlobalActor: { - auto globalActorType = F.mapTypeIntoContext(isolation.getGlobalActor()) + auto globalActorType = F.mapTypeIntoEnvironment(isolation.getGlobalActor()) ->getCanonicalType(); return emitGlobalActorIsolation(loc, globalActorType); } @@ -748,7 +748,7 @@ SILGenFunction::emitExecutor(SILLocation loc, ActorIsolation isolation, } case ActorIsolation::GlobalActor: { - auto globalActorType = F.mapTypeIntoContext(isolation.getGlobalActor()); + auto globalActorType = F.mapTypeIntoEnvironment(isolation.getGlobalActor()); return emitLoadGlobalActorExecutor(globalActorType); } } diff --git a/lib/SILGen/SILGenConstructor.cpp b/lib/SILGen/SILGenConstructor.cpp index 52e745b56c5da..08f972be8c2c4 100644 --- a/lib/SILGen/SILGenConstructor.cpp +++ b/lib/SILGen/SILGenConstructor.cpp @@ -111,7 +111,7 @@ static SILValue emitConstructorMetatypeArg(SILGenFunction &SGF, VD->setInterfaceType(metatypeTy); return SGF.F.begin()->createFunctionArgument( - SGF.getLoweredTypeForFunctionArgument(DC->mapTypeIntoContext(metatypeTy)), + SGF.getLoweredTypeForFunctionArgument(DC->mapTypeIntoEnvironment(metatypeTy)), VD); } @@ -122,7 +122,7 @@ static RValue emitImplicitValueConstructorArg(SILGenFunction &SGF, DeclContext *DC, LoweredParamsInContextGenerator &loweredParamTypes, Initialization *argInit = nullptr) { - auto type = DC->mapTypeIntoContext(interfaceType)->getCanonicalType(); + auto type = DC->mapTypeIntoEnvironment(interfaceType)->getCanonicalType(); // Restructure tuple arguments. if (auto tupleIfaceTy = dyn_cast(interfaceType)) { @@ -300,7 +300,7 @@ emitApplyOfInitAccessor(SILGenFunction &SGF, SILLocation loc, } // The `self` metatype. - auto metatypeTy = MetatypeType::get(accessor->mapTypeIntoContext(selfIfaceTy)); + auto metatypeTy = MetatypeType::get(accessor->mapTypeIntoEnvironment(selfIfaceTy)); arguments.push_back(SGF.B.createMetatype(loc, SGF.getLoweredType(metatypeTy))); SubstitutionMap subs; @@ -692,7 +692,7 @@ void SILGenFunction::emitValueConstructor(ConstructorDecl *ctor) { // failure. SILBasicBlock *failureExitBB = nullptr; SILArgument *failureExitArg = nullptr; - auto resultType = ctor->mapTypeIntoContext(ctor->getResultInterfaceType()); + auto resultType = ctor->mapTypeIntoEnvironment(ctor->getResultInterfaceType()); auto &resultLowering = getTypeLowering(resultType); if (ctor->isFailable()) { @@ -852,7 +852,7 @@ void SILGenFunction::emitValueConstructor(ConstructorDecl *ctor) { void SILGenFunction::emitEnumConstructor(EnumElementDecl *element) { Type enumIfaceTy = element->getParentEnum()->getDeclaredInterfaceType(); - Type enumTy = F.mapTypeIntoContext(enumIfaceTy); + Type enumTy = F.mapTypeIntoEnvironment(enumIfaceTy); auto &enumTI = SGM.Types.getTypeLowering(enumTy, TypeExpansionContext::minimal()); @@ -946,7 +946,7 @@ void SILGenFunction::emitClassConstructorAllocator(ConstructorDecl *ctor) { // argument for it. if (F.getConventions().hasIndirectSILErrorResults()) { assert(F.getConventions().getNumIndirectSILErrorResults() == 1); - auto paramTy = F.mapTypeIntoContext( + auto paramTy = F.mapTypeIntoEnvironment( F.getConventions().getSILErrorType(getTypeExpansionContext())); auto inContextParamTy = F.getLoweredType(paramTy.getASTType()) .getCategoryType(paramTy.getCategory()); @@ -958,7 +958,7 @@ void SILGenFunction::emitClassConstructorAllocator(ConstructorDecl *ctor) { } if (F.isNonisolatedNonsending()) { - auto paramTy = F.mapTypeIntoContext( + auto paramTy = F.mapTypeIntoEnvironment( SILType::getBuiltinImplicitActorType(F.getASTContext())); auto inContextParamTy = F.getLoweredType(paramTy.getASTType()) .getCategoryType(paramTy.getCategory()); @@ -1216,7 +1216,7 @@ void SILGenFunction::emitClassConstructorInitializer(ConstructorDecl *ctor) { prepareEpilog(ctor, std::nullopt, ctor->getEffectiveThrownErrorType(), CleanupLocation(endOfInitLoc)); - auto resultType = ctor->mapTypeIntoContext(ctor->getResultInterfaceType()); + auto resultType = ctor->mapTypeIntoEnvironment(ctor->getResultInterfaceType()); // If the constructor can fail, set up an alternative epilog for constructor // failure. @@ -1456,7 +1456,7 @@ static std::pair getInitializationTypeInContext( DeclContext *fromDC, DeclContext *toDC, Pattern *pattern) { - auto interfaceType = pattern->getType()->mapTypeOutOfContext(); + auto interfaceType = pattern->getType()->mapTypeOutOfEnvironment(); // If this pattern is initializing the backing storage for a property // with an attached wrapper that is initialized with `=`, the @@ -1472,7 +1472,7 @@ getInitializationTypeInContext( fromDC->getGenericSignatureOfContext().getCanonicalSignature(), interfaceType->getCanonicalType()); - auto substType = toDC->mapTypeIntoContext(interfaceType)->getCanonicalType(); + auto substType = toDC->mapTypeIntoEnvironment(interfaceType)->getCanonicalType(); return std::make_pair(origType, substType); } diff --git a/lib/SILGen/SILGenDestructor.cpp b/lib/SILGen/SILGenDestructor.cpp index 3a807d2037e1a..fe5986b378658 100644 --- a/lib/SILGen/SILGenDestructor.cpp +++ b/lib/SILGen/SILGenDestructor.cpp @@ -48,7 +48,7 @@ void SILGenFunction::emitDistributedRemoteActorDeinit( auto finishBB = createBasicBlock("finishDeinitBB"); auto localBB = createBasicBlock("localActorDeinitBB"); - auto selfTy = F.mapTypeIntoContext(cd->getDeclaredInterfaceType()); + auto selfTy = F.mapTypeIntoEnvironment(cd->getDeclaredInterfaceType()); emitDistributedIfRemoteBranch(SILLocation(loc), selfValue, selfTy, /*if remote=*/remoteBB, /*if local=*/localBB); @@ -160,7 +160,7 @@ void SILGenFunction::emitDestroyingDestructor(DestructorDecl *dd) { SILType classTy = selfValue->getType(); if (cd->hasSuperclass() && !cd->isNativeNSObjectSubclass()) { Type superclassTy = - dd->mapTypeIntoContext(cd->getSuperclass()); + dd->mapTypeIntoEnvironment(cd->getSuperclass()); ClassDecl *superclass = superclassTy->getClassOrBoundGenericClass(); auto superclassDtorDecl = superclass->getDestructor(); SILDeclRef dtorConstant = @@ -527,7 +527,7 @@ void SILGenFunction::emitRecursiveChainDestruction(ManagedValue selfValue, ClassDecl *cd, VarDecl *recursiveLink, CleanupLocation cleanupLoc) { - auto selfTy = F.mapTypeIntoContext(cd->getDeclaredInterfaceType()); + auto selfTy = F.mapTypeIntoEnvironment(cd->getDeclaredInterfaceType()); auto selfTyLowered = getTypeLowering(selfTy).getLoweredType(); @@ -540,7 +540,7 @@ void SILGenFunction::emitRecursiveChainDestruction(ManagedValue selfValue, // var iter = self.link // self.link = nil - auto Ty = getTypeLowering(F.mapTypeIntoContext(recursiveLink->getInterfaceType())).getLoweredType(); + auto Ty = getTypeLowering(F.mapTypeIntoEnvironment(recursiveLink->getInterfaceType())).getLoweredType(); auto optionalNone = B.createOptionalNone(cleanupLoc, Ty); SILValue varAddr = B.createRefElementAddr(cleanupLoc, selfValue.getValue(), recursiveLink, @@ -766,7 +766,7 @@ void SILGenFunction::emitObjCDestructor(SILDeclRef dtor) { // instance variables before the object is actually deallocated. // Form a reference to the superclass -dealloc. - Type superclassTy = dd->mapTypeIntoContext(cd->getSuperclass()); + Type superclassTy = dd->mapTypeIntoEnvironment(cd->getSuperclass()); assert(superclassTy && "Emitting Objective-C -dealloc without superclass?"); ClassDecl *superclass = superclassTy->getClassOrBoundGenericClass(); auto superclassDtorDecl = superclass->getDestructor(); diff --git a/lib/SILGen/SILGenDistributed.cpp b/lib/SILGen/SILGenDistributed.cpp index d913b398fd527..ab4cfee42ac94 100644 --- a/lib/SILGen/SILGenDistributed.cpp +++ b/lib/SILGen/SILGenDistributed.cpp @@ -45,7 +45,7 @@ static SILValue emitActorPropertyReference( SILGenFunction &SGF, SILLocation loc, SILValue actorSelf, VarDecl *property) { assert(property); - Type formalType = SGF.F.mapTypeIntoContext(property->getInterfaceType()); + Type formalType = SGF.F.mapTypeIntoEnvironment(property->getInterfaceType()); SILType loweredType = SGF.getLoweredType(formalType).getAddressType(); return SGF.B.createRefElementAddr(loc, actorSelf, property, loweredType); } @@ -58,7 +58,7 @@ static void initializeProperty(SILGenFunction &SGF, SILLocation loc, SILValue actorSelf, VarDecl* prop, SILValue value, IsTake_t isTake) { - Type formalType = SGF.F.mapTypeIntoContext(prop->getInterfaceType()); + Type formalType = SGF.F.mapTypeIntoEnvironment(prop->getInterfaceType()); SILType loweredType = SGF.getLoweredType(formalType); auto fieldAddr = emitActorPropertyReference(SGF, loc, actorSelf, prop); @@ -200,14 +200,14 @@ void SILGenFunction::emitDistActorIdentityInit(ConstructorDecl *ctor, // --- prepare `Self.self` metatype auto *selfTyDecl = ctor->getParent()->getSelfNominalTypeDecl(); - auto selfTy = F.mapTypeIntoContext(selfTyDecl->getDeclaredInterfaceType()); + auto selfTy = F.mapTypeIntoEnvironment(selfTyDecl->getDeclaredInterfaceType()); auto selfMetatype = getLoweredType(MetatypeType::get(selfTy)); SILValue selfMetatypeValue = B.createMetatype(loc, selfMetatype); // --- create a temporary storage for the result of the call // it will be deallocated automatically as we exit this scope VarDecl *var = classDecl->getDistributedActorIDProperty(); - auto resultTy = getLoweredType(F.mapTypeIntoContext(var->getInterfaceType())); + auto resultTy = getLoweredType(F.mapTypeIntoEnvironment(var->getInterfaceType())); auto temp = emitTemporaryAllocation(loc, resultTy); // --- emit the call itself. @@ -249,7 +249,7 @@ void InitializeDistActorIdentity::emit(SILGenFunction &SGF, CleanupLocation loc, auto borrowedSelf = actorSelf.borrow(SGF, loc); // load the actorSystem value - Type formalType = SGF.F.mapTypeIntoContext(systemVar->getInterfaceType()); + Type formalType = SGF.F.mapTypeIntoEnvironment(systemVar->getInterfaceType()); SILType loweredType = SGF.getLoweredType(formalType).getAddressType(); auto ref = SGF.B.createRefElementAddr(loc, borrowedSelf, systemVar, loweredType); @@ -347,7 +347,7 @@ void SILGenFunction::emitDistributedActorReady( SGFContext sgfCxt; { VarDecl *property = classDecl->getDistributedActorSystemProperty(); - Type formalType = F.mapTypeIntoContext(property->getInterfaceType()); + Type formalType = F.mapTypeIntoEnvironment(property->getInterfaceType()); SILType loweredType = getLoweredType(formalType).getAddressType(); SILValue actorSystemRef = emitActorPropertyReference( *this, loc, borrowedSelf.getValue(), property); @@ -416,7 +416,7 @@ void SILGenFunction::emitDistributedActorFactory(FuncDecl *fd) { // TODO(distrib // type: SpecificDistributedActor auto *selfTyDecl = DC->getSelfClassDecl(); assert(selfTyDecl->isDistributedActor()); - auto selfTy = F.mapTypeIntoContext(selfTyDecl->getDeclaredInterfaceType()); + auto selfTy = F.mapTypeIntoEnvironment(selfTyDecl->getDeclaredInterfaceType()); auto returnTy = getLoweredType(selfTy); // ==== Prepare all the basic blocks diff --git a/lib/SILGen/SILGenEpilog.cpp b/lib/SILGen/SILGenEpilog.cpp index 57579e1cc1bc5..a2b69c6637288 100644 --- a/lib/SILGen/SILGenEpilog.cpp +++ b/lib/SILGen/SILGenEpilog.cpp @@ -36,13 +36,13 @@ void SILGenFunction::prepareEpilog( if (fnConv.hasAddressResult() || fnConv.hasGuaranteedResult()) { // Do not explode tuples for borrow/mutate accessors SILType resultType = - F.getLoweredType(F.mapTypeIntoContext(*directResultType)); + F.getLoweredType(F.mapTypeIntoEnvironment(*directResultType)); epilogBB->createPhiArgument(resultType, fnConv.hasGuaranteedResult() ? OwnershipKind::Guaranteed : OwnershipKind::None); } else { for (auto directResult : fnConv.getDirectSILResults()) { - SILType resultType = F.getLoweredType(F.mapTypeIntoContext( + SILType resultType = F.getLoweredType(F.mapTypeIntoEnvironment( fnConv.getSILType(directResult, getTypeExpansionContext()))); // @out tuples do not get flattened in the function's return type, but // the epilog block expects (recursively) flattened arguments. Flatten @@ -96,7 +96,7 @@ void SILGenFunction::prepareRethrowEpilog( SILBasicBlock *rethrowBB = createBasicBlock(FunctionSection::Postmatter); if (!IndirectErrorResult) { - auto errorTypeInContext = dc->mapTypeIntoContext(errorType); + auto errorTypeInContext = dc->mapTypeIntoEnvironment(errorType); SILType loweredErrorType = getLoweredType(origErrorType, errorTypeInContext); rethrowBB->createPhiArgument(loweredErrorType, OwnershipKind::Owned); } @@ -160,7 +160,7 @@ static SILValue buildReturnValue(SILGenFunction &SGF, SILLocation loc, if (!fnConv.useLoweredAddresses()) { // In opaque-values code, nested @out tuples are not flattened. Reconstruct // nested tuples. - auto resultType = SGF.F.getLoweredType(SGF.F.mapTypeIntoContext( + auto resultType = SGF.F.getLoweredType(SGF.F.mapTypeIntoEnvironment( fnConv.getSILResultType(SGF.getTypeExpansionContext()))); SmallVector, 4> mutableDirectResult; for (auto result : directResults) { diff --git a/lib/SILGen/SILGenExpr.cpp b/lib/SILGen/SILGenExpr.cpp index a90fcbe9eb4e6..34a497c56290e 100644 --- a/lib/SILGen/SILGenExpr.cpp +++ b/lib/SILGen/SILGenExpr.cpp @@ -3600,7 +3600,7 @@ static PreparedArguments loadIndexValuesForKeyPathComponent( SmallVector indexParams; for (auto &elt : indexes) { // FIXME: Varargs? - indexParams.emplace_back(SGF.F.mapTypeIntoContext(elt.first)); + indexParams.emplace_back(SGF.F.mapTypeIntoEnvironment(elt.first)); } PreparedArguments indexValues(indexParams); @@ -3614,12 +3614,12 @@ static PreparedArguments loadIndexValuesForKeyPathComponent( if (indexes.size() > 1) { eltAddr = SGF.B.createTupleElementAddr(loc, eltAddr, i); } - auto ty = SGF.F.mapTypeIntoContext(indexes[i].second); + auto ty = SGF.F.mapTypeIntoEnvironment(indexes[i].second); auto value = SGF.emitLoad(loc, eltAddr, SGF.getTypeLowering(ty), SGFContext(), IsNotTake); auto substType = - SGF.F.mapTypeIntoContext(indexes[i].first)->getCanonicalType(); + SGF.F.mapTypeIntoEnvironment(indexes[i].first)->getCanonicalType(); indexValues.add(loc, RValue(SGF, loc, substType, value)); } @@ -3777,8 +3777,8 @@ static void emitKeyPathThunk( SILValue &argPtr, SILParameterInfo paramInfo, bool lowerValueArg = false) { auto entry = thunk->begin(); if (genericEnv) { - resultArgTy = genericEnv->mapTypeIntoContext(SGM.M, resultArgTy); - baseArgTy = genericEnv->mapTypeIntoContext(SGM.M, baseArgTy); + resultArgTy = genericEnv->mapTypeIntoEnvironment(SGM.M, resultArgTy); + baseArgTy = genericEnv->mapTypeIntoEnvironment(SGM.M, baseArgTy); } if (!lowerValueArg) { if (SGM.M.useLoweredAddresses()) { @@ -3792,7 +3792,7 @@ static void emitKeyPathThunk( auto argTy = subSGF.silConv.getSILType(paramInfo, signature, subSGF.F.getTypeExpansionContext()); if (genericEnv) - argTy = genericEnv->mapTypeIntoContext(SGM.M, argTy); + argTy = genericEnv->mapTypeIntoEnvironment(SGM.M, argTy); argPtr = entry->createFunctionArgument(argTy); } } @@ -3830,9 +3830,9 @@ static SILFunction *getOrCreateKeyPathGetter( // Emit the thunk, which accesses the underlying property normally with // reabstraction where necessary. if (genericEnv) { - baseType = genericEnv->mapTypeIntoContext(baseType)->getCanonicalType(); + baseType = genericEnv->mapTypeIntoEnvironment(baseType)->getCanonicalType(); propertyType = - genericEnv->mapTypeIntoContext(propertyType)->getCanonicalType(); + genericEnv->mapTypeIntoEnvironment(propertyType)->getCanonicalType(); thunk->setGenericEnvironment(genericEnv); } SILGenFunction subSGF(SGM, *thunk, SGM.SwiftModule); @@ -3927,9 +3927,9 @@ static SILFunction *getOrCreateKeyPathSetter( // Emit the thunk, which accesses the underlying property normally with // reabstraction where necessary. if (genericEnv) { - baseType = genericEnv->mapTypeIntoContext(baseType)->getCanonicalType(); + baseType = genericEnv->mapTypeIntoEnvironment(baseType)->getCanonicalType(); propertyType = - genericEnv->mapTypeIntoContext(propertyType)->getCanonicalType(); + genericEnv->mapTypeIntoEnvironment(propertyType)->getCanonicalType(); thunk->setGenericEnvironment(genericEnv); } SILGenFunction subSGF(SGM, *thunk, SGM.SwiftModule); @@ -4063,8 +4063,8 @@ static SILFunction *getOrCreateKeyPathAppliedMethod( // Emit the thunk, which accesses the underlying property normally with // reabstraction where necessary. if (genericEnv) { - baseType = genericEnv->mapTypeIntoContext(baseType)->getCanonicalType(); - methodType = genericEnv->mapTypeIntoContext(methodType)->getCanonicalType(); + baseType = genericEnv->mapTypeIntoEnvironment(baseType)->getCanonicalType(); + methodType = genericEnv->mapTypeIntoEnvironment(methodType)->getCanonicalType(); thunk->setGenericEnvironment(genericEnv); } SILGenFunction subSGF(SGM, *thunk, SGM.SwiftModule); @@ -4152,8 +4152,8 @@ static SILFunction *getOrCreateUnappliedKeypathMethod( // Emit the thunk, which accesses the underlying property normally with // reabstraction where necessary. if (genericEnv) { - baseType = genericEnv->mapTypeIntoContext(baseType)->getCanonicalType(); - methodType = genericEnv->mapTypeIntoContext(methodType)->getCanonicalType(); + baseType = genericEnv->mapTypeIntoEnvironment(baseType)->getCanonicalType(); + methodType = genericEnv->mapTypeIntoEnvironment(methodType)->getCanonicalType(); thunk->setGenericEnvironment(genericEnv); } SILGenFunction subSGF(SGM, *thunk, SGM.SwiftModule); @@ -4230,12 +4230,12 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM, CanType indexTupleTy; if (indexes.size() == 1) { - indexTupleTy = GenericEnvironment::mapTypeIntoContext( + indexTupleTy = GenericEnvironment::mapTypeIntoEnvironment( genericEnv, indexes[0].FormalType)->getCanonicalType(); } else { SmallVector indexElts; for (auto &elt : indexes) { - indexElts.push_back(GenericEnvironment::mapTypeIntoContext( + indexElts.push_back(GenericEnvironment::mapTypeIntoEnvironment( genericEnv, elt.FormalType)); } @@ -4289,8 +4289,8 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM, auto rhsArgTy = subSGF.silConv.getSILType( params[1], signature, subSGF.getTypeExpansionContext()); if (genericEnv) { - lhsArgTy = genericEnv->mapTypeIntoContext(SGM.M, lhsArgTy); - rhsArgTy = genericEnv->mapTypeIntoContext(SGM.M, rhsArgTy); + lhsArgTy = genericEnv->mapTypeIntoEnvironment(SGM.M, lhsArgTy); + rhsArgTy = genericEnv->mapTypeIntoEnvironment(SGM.M, rhsArgTy); } auto lhsAddr = entry->createFunctionArgument(lhsArgTy); auto rhsAddr = entry->createFunctionArgument(rhsArgTy); @@ -4314,7 +4314,7 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM, Type formalTy = index.FormalType; ProtocolConformanceRef hashable = index.Hashable; if (genericEnv) { - formalTy = genericEnv->mapTypeIntoContext(formalTy); + formalTy = genericEnv->mapTypeIntoEnvironment(formalTy); hashable = hashable.subst(genericEnv->getForwardingSubstitutionMap()); } @@ -4463,7 +4463,7 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM, auto indexArgTy = subSGF.silConv.getSILType( params[0], signature, subSGF.getTypeExpansionContext()); if (genericEnv) - indexArgTy = genericEnv->mapTypeIntoContext(SGM.M, indexArgTy); + indexArgTy = genericEnv->mapTypeIntoEnvironment(SGM.M, indexArgTy); auto indexPtr = entry->createFunctionArgument(indexArgTy); SILValue hashCode; @@ -4487,7 +4487,7 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM, auto formalTy = index.FormalType; auto hashable = index.Hashable; if (genericEnv) { - formalTy = genericEnv->mapTypeIntoContext(formalTy)->getCanonicalType(); + formalTy = genericEnv->mapTypeIntoEnvironment(formalTy)->getCanonicalType(); hashable = hashable.subst( genericEnv->getForwardingSubstitutionMap()); } @@ -4596,10 +4596,10 @@ static void lowerKeyPathMemberIndexTypes( AbstractionPattern::getOpaque(), paramTy, TypeExpansionContext::noOpaqueTypeArchetypesSubstitution( ResilienceExpansion::Minimal)); - paramLoweredTy = paramLoweredTy.mapTypeOutOfContext(); + paramLoweredTy = paramLoweredTy.mapTypeOutOfEnvironment(); indexPatterns.push_back( - {paramTy->mapTypeOutOfContext()->getCanonicalType(), paramLoweredTy}); + {paramTy->mapTypeOutOfEnvironment()->getCanonicalType(), paramLoweredTy}); } }; @@ -4630,7 +4630,7 @@ static void lowerKeyPathMemberIndexPatterns( CanType formalTy; SILType loweredTy; std::tie(formalTy, loweredTy) = indexTypes[i]; - auto hashable = indexHashables[i].mapConformanceOutOfContext(); + auto hashable = indexHashables[i].mapConformanceOutOfEnvironment(); assert(hashable.isAbstract() || hashable.getConcrete()->getType()->isEqual(formalTy)); @@ -4663,13 +4663,13 @@ KeyPathPatternComponent SILGenModule::emitKeyPathComponentForDecl( methodTy->getResult()->castTo()->getResult(); if (auto genMethodTy = methodResultTy->getAs()) methodResultTy = genMethodTy->substGenericArgs(subs); - componentTy = methodResultTy->mapTypeOutOfContext()->getCanonicalType(); + componentTy = methodResultTy->mapTypeOutOfEnvironment()->getCanonicalType(); } else { // Otherwise, component type is method type without Self. if (auto genMethodTy = methodTy->getAs()) methodTy = genMethodTy->substGenericArgs(subs); auto methodInterfaceTy = cast( - methodTy->mapTypeOutOfContext()->getCanonicalType()); + methodTy->mapTypeOutOfEnvironment()->getCanonicalType()); componentTy = methodInterfaceTy.getResult(); } @@ -4814,7 +4814,7 @@ KeyPathPatternComponent SILGenModule::emitKeyPathComponentForDecl( if (externalSubs.getRecursiveProperties().hasArchetype()) { needsGenericContext = true; // FIXME: This doesn't do anything for local archetypes! - externalSubs = externalSubs.mapReplacementTypesOutOfContext(); + externalSubs = externalSubs.mapReplacementTypesOutOfEnvironment(); } } @@ -4847,15 +4847,15 @@ KeyPathPatternComponent SILGenModule::emitKeyPathComponentForDecl( componentTy = var->getValueInterfaceType()->getCanonicalType(); ASSERT(!componentTy->hasTypeParameter()); } else { - // The mapTypeIntoContext() / mapTypeOutOfContext() dance is there + // The mapTypeIntoEnvironment() / mapTypeOutOfEnvironment() dance is there // to handle the case where baseTy being a type parameter subject // to a superclass requirement. componentTy = var->getValueInterfaceType() - .subst(GenericEnvironment::mapTypeIntoContext( + .subst(GenericEnvironment::mapTypeIntoEnvironment( genericEnv, baseTy->getMetatypeInstanceType()) ->getContextSubstitutionMap(var->getDeclContext())) - ->mapTypeOutOfContext() + ->mapTypeOutOfEnvironment() ->getCanonicalType(); } @@ -4897,7 +4897,7 @@ KeyPathPatternComponent SILGenModule::emitKeyPathComponentForDecl( if (auto genSubscriptTy = baseSubscriptTy->getAs()) baseSubscriptTy = genSubscriptTy->substGenericArgs(subs); auto baseSubscriptInterfaceTy = cast( - baseSubscriptTy->mapTypeOutOfContext()->getCanonicalType()); + baseSubscriptTy->mapTypeOutOfEnvironment()->getCanonicalType()); auto componentTy = baseSubscriptInterfaceTy.getResult(); if (decl->getAttrs().hasAttribute()) { @@ -4962,7 +4962,7 @@ RValue RValueEmitter::visitKeyPathExpr(KeyPathExpr *E, SGFContext C) { bool needsGenericContext = false; if (rootTy->hasArchetype()) { needsGenericContext = true; - rootTy = rootTy->mapTypeOutOfContext()->getCanonicalType(); + rootTy = rootTy->mapTypeOutOfEnvironment()->getCanonicalType(); } auto baseTy = rootTy; @@ -5409,7 +5409,7 @@ RValue RValueEmitter::visitRebindSelfInConstructorExpr( auto selfDecl = E->getSelf(); auto ctorDecl = cast(selfDecl->getDeclContext()); auto selfIfaceTy = ctorDecl->getDeclContext()->getSelfInterfaceType(); - auto selfTy = ctorDecl->mapTypeIntoContext(selfIfaceTy); + auto selfTy = ctorDecl->mapTypeIntoEnvironment(selfIfaceTy); bool isChaining; // Ignored auto *otherCtor = E->getCalledConstructor(isChaining)->getDecl(); @@ -5423,7 +5423,7 @@ RValue RValueEmitter::visitRebindSelfInConstructorExpr( // The optionality depth of the result type of the enclosing initializer in // this context. const auto destOptionalityDepth = - ctorDecl->mapTypeIntoContext(ctorDecl->getResultInterfaceType()) + ctorDecl->mapTypeIntoEnvironment(ctorDecl->getResultInterfaceType()) ->getOptionalityDepth(); // The subexpression consumes the current 'self' binding. diff --git a/lib/SILGen/SILGenFunction.cpp b/lib/SILGen/SILGenFunction.cpp index d58bd97f34c46..facc22c7cdabc 100644 --- a/lib/SILGen/SILGenFunction.cpp +++ b/lib/SILGen/SILGenFunction.cpp @@ -626,8 +626,8 @@ void SILGenFunction::emitCaptures(SILLocation loc, isPack = true; } - auto type = FunctionDC->mapTypeIntoContext(interfaceType); - auto valueType = FunctionDC->mapTypeIntoContext( + auto type = FunctionDC->mapTypeIntoEnvironment(interfaceType); + auto valueType = FunctionDC->mapTypeIntoEnvironment( interfaceType->getReferenceStorageReferent()); // @@ -1158,10 +1158,10 @@ void SILGenFunction::emitClosure(AbstractClosureExpr *ace) { auto &closureInfo = SGM.M.Types.getClosureTypeInfo(ace); TypeContext = closureInfo; - auto resultIfaceTy = ace->getResultType()->mapTypeOutOfContext(); + auto resultIfaceTy = ace->getResultType()->mapTypeOutOfEnvironment(); std::optional errorIfaceTy; if (auto optErrorTy = ace->getEffectiveThrownType()) - errorIfaceTy = (*optErrorTy)->mapTypeOutOfContext(); + errorIfaceTy = (*optErrorTy)->mapTypeOutOfEnvironment(); auto captureInfo = SGM.M.Types.getLoweredLocalCaptures( SILDeclRef(ace)); emitProlog(ace, captureInfo, ace->getParameters(), /*selfParam=*/nullptr, @@ -1605,7 +1605,7 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, Expr *value, vd->getPropertyWrapperInitializerInfo().getProjectedValuePlaceholder(); auto interfaceType = placeholder->getType(); if (interfaceType->hasArchetype()) - interfaceType = interfaceType->mapTypeOutOfContext(); + interfaceType = interfaceType->mapTypeOutOfEnvironment(); param->setInterfaceType(interfaceType); } @@ -1614,7 +1614,7 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, Expr *value, } auto captureInfo = SGM.M.Types.getLoweredLocalCaptures(function); - auto interfaceType = value->getType()->mapTypeOutOfContext(); + auto interfaceType = value->getType()->mapTypeOutOfEnvironment(); emitProlog(dc, captureInfo, params, /*selfParam=*/nullptr, interfaceType, /*errorType=*/std::nullopt, SourceLoc()); if (EmitProfilerIncrement) { @@ -1695,7 +1695,7 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, VarDecl *var) { const auto i = pbd->getPatternEntryIndexForVarDecl(var); auto *anchorVar = pbd->getAnchoringVarDecl(i); auto subs = getForwardingSubstitutionMap(); - auto contextualType = dc->mapTypeIntoContext(interfaceType); + auto contextualType = dc->mapTypeIntoEnvironment(interfaceType); auto resultType = contextualType->getCanonicalType(); auto origResultType = AbstractionPattern(resultType); diff --git a/lib/SILGen/SILGenFunction.h b/lib/SILGen/SILGenFunction.h index c46a9d224a8ac..9d6c12c6994b7 100644 --- a/lib/SILGen/SILGenFunction.h +++ b/lib/SILGen/SILGenFunction.h @@ -889,12 +889,12 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction } SILType getSILTypeInContext(SILResultInfo result, CanSILFunctionType fnTy) { - auto t = F.mapTypeIntoContext(getSILType(result, fnTy)); + auto t = F.mapTypeIntoEnvironment(getSILType(result, fnTy)); return getTypeLowering(t).getLoweredType().getCategoryType(t.getCategory()); } SILType getSILTypeInContext(SILParameterInfo param, CanSILFunctionType fnTy) { - auto t = F.mapTypeIntoContext(getSILType(param, fnTy)); + auto t = F.mapTypeIntoEnvironment(getSILType(param, fnTy)); return getTypeLowering(t).getLoweredType().getCategoryType(t.getCategory()); } diff --git a/lib/SILGen/SILGenLocalArchetype.cpp b/lib/SILGen/SILGenLocalArchetype.cpp index e637676cb00a1..def99f7e77b18 100644 --- a/lib/SILGen/SILGenLocalArchetype.cpp +++ b/lib/SILGen/SILGenLocalArchetype.cpp @@ -60,7 +60,7 @@ class LocalArchetypeTransform : public SILCloner { for (auto &bb : F) bbs.push_back(&bb); - // Make F.mapTypeIntoContext() use the new environment. + // Make F.mapTypeIntoEnvironment() use the new environment. F.setGenericEnvironment(env); // Start by cloning the entry block. diff --git a/lib/SILGen/SILGenPoly.cpp b/lib/SILGen/SILGenPoly.cpp index 2afe87b63719f..8dfd02ce97aa6 100644 --- a/lib/SILGen/SILGenPoly.cpp +++ b/lib/SILGen/SILGenPoly.cpp @@ -990,7 +990,7 @@ void SILGenFunction::collectThunkParams( // Add the indirect results. for (auto resultTy : F.getConventions().getIndirectSILResultTypes( getTypeExpansionContext())) { - auto paramTy = F.mapTypeIntoContext(resultTy); + auto paramTy = F.mapTypeIntoEnvironment(resultTy); // Lower result parameters in the context of the function: opaque result // types will be lowered to their underlying type if allowed by resilience. auto inContextParamTy = F.getLoweredType(paramTy.getASTType()) @@ -1002,7 +1002,7 @@ void SILGenFunction::collectThunkParams( if (F.getConventions().hasIndirectSILErrorResults()) { assert(F.getConventions().getNumIndirectSILErrorResults() == 1); - auto paramTy = F.mapTypeIntoContext( + auto paramTy = F.mapTypeIntoEnvironment( F.getConventions().getSILErrorType(getTypeExpansionContext())); auto inContextParamTy = F.getLoweredType(paramTy.getASTType()) .getCategoryType(paramTy.getCategory()); @@ -1016,7 +1016,7 @@ void SILGenFunction::collectThunkParams( // Add the parameters. auto paramTypes = F.getLoweredFunctionType()->getParameters(); for (auto param : paramTypes) { - auto paramTy = F.mapTypeIntoContext( + auto paramTy = F.mapTypeIntoEnvironment( F.getConventions().getSILType(param, getTypeExpansionContext())); // Lower parameters in the context of the function: opaque result types will // be lowered to their underlying type if allowed by resilience. @@ -2909,9 +2909,9 @@ static ManagedValue applyTrivialConversions(SILGenFunction &SGF, auto innerASTTy = innerValue.getType().getASTType(); auto outerASTTy = outerType.getASTType(); if (innerASTTy->hasArchetype()) - innerASTTy = innerASTTy->mapTypeOutOfContext()->getCanonicalType(); + innerASTTy = innerASTTy->mapTypeOutOfEnvironment()->getCanonicalType(); if (outerASTTy->hasArchetype()) - outerASTTy = outerASTTy->mapTypeOutOfContext()->getCanonicalType(); + outerASTTy = outerASTTy->mapTypeOutOfEnvironment()->getCanonicalType(); if (innerASTTy == outerASTTy) { return innerValue; @@ -3074,7 +3074,7 @@ static void translateYields(SILGenFunction &SGF, SILLocation loc, // them into SILParameterInfos. SmallVector outerLoweredTypesAsParameters; for (auto unmappedInfo : outerInfos.getLoweredTypes()) { - auto mappedTy = SGF.F.mapTypeIntoContext( + auto mappedTy = SGF.F.mapTypeIntoEnvironment( unmappedInfo.getSILStorageInterfaceType()); outerLoweredTypesAsParameters.push_back({mappedTy.getASTType(), unmappedInfo.getConvention()}); @@ -5340,7 +5340,7 @@ void ResultPlanner::execute(SmallVectorImpl &innerDirectResultStack, outerResultCtxt = SGFContext(&*outerResultInit); } else { outerResultTy = - SGF.F.mapTypeIntoContext( + SGF.F.mapTypeIntoEnvironment( SGF.getSILType(op.OuterResult, CanSILFunctionType())); } @@ -5418,7 +5418,7 @@ void ResultPlanner::execute(SmallVectorImpl &innerDirectResultStack, case Operation::TupleDirect: { auto firstEltIndex = outerDirectResults.size() - op.NumElements; auto elts = llvm::ArrayRef(outerDirectResults).slice(firstEltIndex); - auto tupleType = SGF.F.mapTypeIntoContext( + auto tupleType = SGF.F.mapTypeIntoEnvironment( SGF.getSILType(op.OuterResult, CanSILFunctionType())); auto tuple = SGF.B.createTuple(Loc, tupleType, elts); outerDirectResults.resize(firstEltIndex); @@ -5436,7 +5436,7 @@ void ResultPlanner::execute(SmallVectorImpl &innerDirectResultStack, case Operation::InjectOptionalDirect: { SILValue value = outerDirectResults.pop_back_val(); - auto tupleType = SGF.F.mapTypeIntoContext( + auto tupleType = SGF.F.mapTypeIntoEnvironment( SGF.getSILType(op.OuterResult, CanSILFunctionType())); SILValue optValue = SGF.B.createEnum(Loc, value, op.SomeDecl, tupleType); outerDirectResults.push_back(optValue); @@ -6202,8 +6202,8 @@ ManagedValue SILGenFunction::getThunkedAutoDiffLinearMap( thunkType->getWithExtInfo(thunkType->getExtInfo().withNoEscape(false)); // Get the thunk name. - auto fromInterfaceType = fromType->mapTypeOutOfContext()->getCanonicalType(); - auto toInterfaceType = toType->mapTypeOutOfContext()->getCanonicalType(); + auto fromInterfaceType = fromType->mapTypeOutOfEnvironment()->getCanonicalType(); + auto toInterfaceType = toType->mapTypeOutOfEnvironment()->getCanonicalType(); Mangle::ASTMangler mangler(getASTContext()); std::string name; // If `self` is being reordered, it is an AD-specific self-reordering @@ -6461,7 +6461,7 @@ ManagedValue SILGenFunction::getThunkedAutoDiffLinearMap( auto paramTy = fromConv.getSILType(fromType->getParameters()[paramIdx], thunkSGF.getTypeExpansionContext()); if (!paramTy.hasArchetype()) - paramTy = thunk->mapTypeIntoContext(paramTy); + paramTy = thunk->mapTypeIntoEnvironment(paramTy); assert(paramTy.isAddress()); auto toArg = (*toArgIter++).getValue(); auto *buf = createAllocStack(toArg->getType()); @@ -6611,7 +6611,7 @@ SILFunction *SILGenModule::getOrCreateCustomDerivativeThunk( auto *fnRef = thunkSGF.B.createFunctionRef(loc, customDerivativeFn); auto fnRefType = - thunkSGF.F.mapTypeIntoContext(fnRef->getType().mapTypeOutOfContext()) + thunkSGF.F.mapTypeIntoEnvironment(fnRef->getType().mapTypeOutOfEnvironment()) .castTo() ->getUnsubstitutedType(M); @@ -6679,12 +6679,12 @@ SILFunction *SILGenModule::getOrCreateCustomDerivativeThunk( // return the `apply` instruction. auto linearMapFnType = cast( thunk - ->mapTypeIntoContext( + ->mapTypeIntoEnvironment( fnRefType->getResults().back().getInterfaceType()) ->getCanonicalType()); auto targetLinearMapFnType = thunk - ->mapTypeIntoContext( + ->mapTypeIntoEnvironment( thunkFnTy->getResults().back().getSILStorageInterfaceType()) .castTo(); SILFunctionConventions conv(thunkFnTy, thunkSGF.getModule()); @@ -6720,7 +6720,7 @@ SILFunction *SILGenModule::getOrCreateCustomDerivativeThunk( SILType linearMapResultType = thunk ->getLoweredType(thunk - ->mapTypeIntoContext( + ->mapTypeIntoEnvironment( conv.getSILResultType(typeExpansionContext)) .getASTType()) .getCategoryType( @@ -7467,7 +7467,7 @@ void SILGenFunction::emitProtocolWitness( genericFnType->substGenericArgs(forwardingSubs)->getCanonicalType()); } else { reqtSubstTy = cast( - F.mapTypeIntoContext(reqtSubstTy)->getCanonicalType()); + F.mapTypeIntoEnvironment(reqtSubstTy)->getCanonicalType()); } assert(!reqtSubstTy->hasError()); diff --git a/lib/SILGen/SILGenProlog.cpp b/lib/SILGen/SILGenProlog.cpp index ea4185fdfb1d7..72e905a90055c 100644 --- a/lib/SILGen/SILGenProlog.cpp +++ b/lib/SILGen/SILGenProlog.cpp @@ -45,7 +45,7 @@ SILValue SILGenFunction::emitSelfDeclForDestructor(VarDecl *selfDecl) { // Emit the implicit 'self' argument. SILType selfType = conventions.getSILArgumentType( conventions.getNumSILArguments() - 1, F.getTypeExpansionContext()); - selfType = F.mapTypeIntoContext(selfType); + selfType = F.mapTypeIntoEnvironment(selfType); SILValue selfValue = F.begin()->createFunctionArgument(selfType, selfDecl); uint16_t ArgNo = 1; // Hardcoded for destructors. @@ -127,7 +127,7 @@ struct LoweredParamGenerator { assert(!isFormalParameterPack || parameterInfo.isPack()); auto paramType = - SGF.F.mapTypeIntoContext(SGF.getSILType(parameterInfo, fnTy)); + SGF.F.mapTypeIntoEnvironment(SGF.getSILType(parameterInfo, fnTy)); ManagedValue mv = SGF.B.createInputFunctionArgument( paramType, paramDecl, isNoImplicitCopy, lifetimeAnnotation, /*isClosureCapture*/ false, isFormalParameterPack, isImplicitParameter); @@ -1155,9 +1155,9 @@ static void emitCaptureArguments(SILGenFunction &SGF, SILLocation Loc(expr); Loc.markAsPrologue(); - auto interfaceType = expr->getType()->mapTypeOutOfContext(); + auto interfaceType = expr->getType()->mapTypeOutOfEnvironment(); - auto type = SGF.F.mapTypeIntoContext(interfaceType); + auto type = SGF.F.mapTypeIntoEnvironment(interfaceType); auto &lowering = SGF.getTypeLowering(type); SILType ty = lowering.getLoweredType(); @@ -1215,7 +1215,7 @@ static void emitCaptureArguments(SILGenFunction &SGF, isPack = true; } - auto type = SGF.F.mapTypeIntoContext(interfaceType); + auto type = SGF.F.mapTypeIntoEnvironment(interfaceType); auto &lowering = SGF.getTypeLowering(type); SILType ty = lowering.getLoweredType(); @@ -1460,8 +1460,8 @@ void SILGenFunction::emitProlog( if (capture.isOpaqueValue()) { OpaqueValueExpr *opaqueValue = capture.getOpaqueValue(); - Type type = opaqueValue->getType()->mapTypeOutOfContext(); - type = F.mapTypeIntoContext(type); + Type type = opaqueValue->getType()->mapTypeOutOfEnvironment(); + type = F.mapTypeIntoEnvironment(type); auto &lowering = getTypeLowering(type); SILType ty = lowering.getLoweredType(); SILValue val = F.begin()->createFunctionArgument(ty); @@ -1550,7 +1550,7 @@ static void emitIndirectResultParameters(SILGenFunction &SGF, } CanType resultTypeInContext = - DC->mapTypeIntoContext(resultType)->getCanonicalType(); + DC->mapTypeIntoEnvironment(resultType)->getCanonicalType(); // Tuples in the original result type are expanded. if (origResultType.isTuple()) { @@ -1615,7 +1615,7 @@ static void emitIndirectErrorParameter(SILGenFunction &SGF, AbstractionPattern origErrorType, DeclContext *DC) { CanType errorTypeInContext = - DC->mapTypeIntoContext(errorType)->getCanonicalType(); + DC->mapTypeIntoEnvironment(errorType)->getCanonicalType(); // If the error type is address-only, emit the indirect error argument. @@ -1718,7 +1718,7 @@ uint16_t SILGenFunction::emitBasicProlog( // Record the ArgNo of the artificial $error inout argument. if (errorType && IndirectErrorResult == nullptr) { CanType errorTypeInContext = - DC->mapTypeIntoContext(*errorType)->getCanonicalType(); + DC->mapTypeIntoEnvironment(*errorType)->getCanonicalType(); auto loweredErrorTy = getLoweredType(*origErrorType, errorTypeInContext); ManagedValue undef = emitUndef(loweredErrorTy); SILDebugVariable dbgVar("$error", /*Constant*/ false, ++ArgNo); diff --git a/lib/SILGen/SILGenThunk.cpp b/lib/SILGen/SILGenThunk.cpp index a2ba63724f5c3..a1b9e4697a4de 100644 --- a/lib/SILGen/SILGenThunk.cpp +++ b/lib/SILGen/SILGenThunk.cpp @@ -284,7 +284,7 @@ SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction( CanGenericSignature sig, CalleeTypeInfo &calleeInfo) { auto convention = *calleeInfo.foreign.async; auto resumeType = - calleeInfo.substResultType->mapTypeOutOfContext()->getReducedType(sig); + calleeInfo.substResultType->mapTypeOutOfEnvironment()->getReducedType(sig); CanAnyFunctionType completionHandlerOrigTy = [&]() { auto completionHandlerOrigTy = @@ -392,7 +392,7 @@ SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction( continuation = SGF.B.createUncheckedAddrCast( loc, underlyingValueAddr, SILType::getPrimitiveAddressType( - F->mapTypeIntoContext(continuationType)->getCanonicalType())); + F->mapTypeIntoEnvironment(continuationType)->getCanonicalType())); // If we are not using checked bridging, we load the continuation from // memory since we are going to pass it in registers, not in memory to @@ -480,7 +480,7 @@ SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction( // native Swift error. auto nativeError = SGF.emitBridgedToNativeError(loc, matchedError); Type replacementTypes[] - = {F->mapTypeIntoContext(resumeType)->getCanonicalType()}; + = {F->mapTypeIntoEnvironment(resumeType)->getCanonicalType()}; auto subs = SubstitutionMap::get(errorIntrinsic->getGenericSignature(), replacementTypes, LookUpConformanceInModule()); @@ -500,7 +500,7 @@ SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction( } auto loweredResumeTy = SGF.getLoweredType(AbstractionPattern::getOpaque(), - F->mapTypeIntoContext(resumeType)); + F->mapTypeIntoEnvironment(resumeType)); // Prepare the argument for the resume intrinsic, using the non-error // arguments to the callback. @@ -558,7 +558,7 @@ SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction( prepareArgument( /*destBuf*/ resumeEltBuf, /*destFormalType*/ - F->mapTypeIntoContext(resumeTuple.getElementTypes()[i]) + F->mapTypeIntoEnvironment(resumeTuple.getElementTypes()[i]) ->getCanonicalType(), /*arg*/ params[paramIndices[i]], /*argFormalType*/ @@ -569,7 +569,7 @@ SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction( assert(params.size() == 2 + (bool)errorIndex + (bool)flagIndex); prepareArgument(/*destBuf*/ resumeArgBuf, /*destFormalType*/ - F->mapTypeIntoContext(resumeType)->getCanonicalType(), + F->mapTypeIntoEnvironment(resumeType)->getCanonicalType(), /*arg*/ params[paramIndices[0]], /*argFormalType*/ blockParams[blockParamIndex(0)].getParameterType()); @@ -578,7 +578,7 @@ SILFunction *SILGenModule::getOrCreateForeignAsyncCompletionHandlerImplFunction( // Resume the continuation with the composed bridged result. ManagedValue resumeArg = SGF.emitManagedBufferWithCleanup(resumeArgBuf); Type replacementTypes[] - = {F->mapTypeIntoContext(resumeType)->getCanonicalType()}; + = {F->mapTypeIntoEnvironment(resumeType)->getCanonicalType()}; auto subs = SubstitutionMap::get(resumeIntrinsic->getGenericSignature(), replacementTypes, LookUpConformanceInModule()); @@ -615,16 +615,16 @@ getOrCreateReabstractionThunk(CanSILFunctionType thunkType, // Mangle the reabstraction thunk. // Substitute context parameters out of the "from" and "to" types. - auto fromInterfaceType = fromType->mapTypeOutOfContext() + auto fromInterfaceType = fromType->mapTypeOutOfEnvironment() ->getCanonicalType(); - auto toInterfaceType = toType->mapTypeOutOfContext() + auto toInterfaceType = toType->mapTypeOutOfEnvironment() ->getCanonicalType(); CanType dynamicSelfInterfaceType; if (dynamicSelfType) - dynamicSelfInterfaceType = dynamicSelfType->mapTypeOutOfContext() + dynamicSelfInterfaceType = dynamicSelfType->mapTypeOutOfEnvironment() ->getCanonicalType(); if (fromGlobalActorBound) - fromGlobalActorBound = fromGlobalActorBound->mapTypeOutOfContext() + fromGlobalActorBound = fromGlobalActorBound->mapTypeOutOfEnvironment() ->getCanonicalType(); Mangle::ASTMangler NewMangler(thunkType->getASTContext()); diff --git a/lib/SILGen/SILGenType.cpp b/lib/SILGen/SILGenType.cpp index d81293b243779..e82f35ec54043 100644 --- a/lib/SILGen/SILGenType.cpp +++ b/lib/SILGen/SILGenType.cpp @@ -771,7 +771,7 @@ SILFunction *SILGenModule::emitProtocolWitness( // The type of the witness thunk. auto reqtSubstTy = cast( reqtOrigTy->substGenericArgs(reqtSubMap) - ->mapTypeOutOfContext() + ->mapTypeOutOfEnvironment() ->getCanonicalType()); // Rewrite the conformance in terms of the requirement environment's Self @@ -787,7 +787,7 @@ SILFunction *SILGenModule::emitProtocolWitness( if (conformance.isConcrete()) { conformance = reqtSubMap.lookupConformance(M.getASTContext().TheSelfType, origConformance.getProtocol()) - .mapConformanceOutOfContext(); + .mapConformanceOutOfEnvironment(); ASSERT(!conformance.isAbstract()); manglingConformance = conformance.getConcrete(); @@ -821,7 +821,7 @@ SILFunction *SILGenModule::emitProtocolWitness( if (auto accessor = dyn_cast(requirement.getDecl())) { if (accessor->isCoroutine()) { witnessSubsForTypeLowering = - witness.getSubstitutions().mapReplacementTypesOutOfContext(); + witness.getSubstitutions().mapReplacementTypesOutOfEnvironment(); if (accessor->isRequirementWithSynthesizedDefaultImplementation()) allowDuplicateThunk = true; } @@ -1122,7 +1122,7 @@ class SILGenDefaultWitnessTable if (!witness) return addMissingDefault(); - Type witnessInContext = Proto->mapTypeIntoContext(witness); + Type witnessInContext = Proto->mapTypeIntoEnvironment(witness); auto entry = SILWitnessTable::AssociatedTypeWitness{ assocType, witnessInContext->getCanonicalType()}; @@ -1354,7 +1354,7 @@ SILFunction *SILGenModule::emitDefaultOverride(SILDeclRef replacement, for (auto result : originalConvention.getDirectSILResults()) { auto ty = originalConvention.getSILType( result, function->getTypeExpansionContext()); - ty = function->mapTypeIntoContext(ty); + ty = function->mapTypeIntoEnvironment(ty); directResultTypes.push_back(ty.getASTType()); } SILType resultTy; diff --git a/lib/SILOptimizer/Differentiation/JVPCloner.cpp b/lib/SILOptimizer/Differentiation/JVPCloner.cpp index 588ec85227886..f5f7dac798235 100644 --- a/lib/SILOptimizer/Differentiation/JVPCloner.cpp +++ b/lib/SILOptimizer/Differentiation/JVPCloner.cpp @@ -333,15 +333,15 @@ class JVPCloner::Implementation final /// Remap any archetypes into the differential function's context. Type remapTypeInDifferential(Type ty) { if (ty->hasArchetype()) - return getDifferential().mapTypeIntoContext(ty->mapTypeOutOfContext()); - return getDifferential().mapTypeIntoContext(ty); + return getDifferential().mapTypeIntoEnvironment(ty->mapTypeOutOfEnvironment()); + return getDifferential().mapTypeIntoEnvironment(ty); } /// Remap any archetypes into the differential function's context. SILType remapSILTypeInDifferential(SILType ty) { if (ty.hasArchetype()) - return getDifferential().mapTypeIntoContext(ty.mapTypeOutOfContext()); - return getDifferential().mapTypeIntoContext(ty); + return getDifferential().mapTypeIntoEnvironment(ty.mapTypeOutOfEnvironment()); + return getDifferential().mapTypeIntoEnvironment(ty); } /// Find the tangent space of a given canonical type. @@ -702,7 +702,7 @@ class JVPCloner::Implementation final loc, differentialRef, jvpSubstMap, {diffStructVal}, ParameterConvention::Direct_Guaranteed); - auto differentialType = jvp->mapTypeIntoContext( + auto differentialType = jvp->mapTypeIntoEnvironment( jvp->getConventions().getSILType( jvp->getLoweredFunctionType()->getResults().back(), jvp->getTypeExpansionContext())); diff --git a/lib/SILOptimizer/Differentiation/LinearMapInfo.cpp b/lib/SILOptimizer/Differentiation/LinearMapInfo.cpp index 4586ccc53555e..ca3a96e7ff608 100644 --- a/lib/SILOptimizer/Differentiation/LinearMapInfo.cpp +++ b/lib/SILOptimizer/Differentiation/LinearMapInfo.cpp @@ -67,8 +67,8 @@ LinearMapInfo::LinearMapInfo(ADContext &context, AutoDiffLinearMapKind kind, SILType LinearMapInfo::remapTypeInDerivative(SILType ty) { if (ty.hasArchetype()) - return derivative->mapTypeIntoContext(ty.mapTypeOutOfContext()); - return derivative->mapTypeIntoContext(ty); + return derivative->mapTypeIntoEnvironment(ty.mapTypeOutOfEnvironment()); + return derivative->mapTypeIntoEnvironment(ty); } EnumDecl * @@ -153,7 +153,7 @@ void LinearMapInfo::populateBranchingTraceDecl(SILBasicBlock *originalBB, auto canLinearMapTupleTy = linearMapTupleTy->getCanonicalType(); decl->setInterfaceType(canLinearMapTupleTy->hasArchetype() - ? canLinearMapTupleTy->mapTypeOutOfContext() + ? canLinearMapTupleTy->mapTypeOutOfEnvironment() : canLinearMapTupleTy); } // Create enum element and enum case declarations. @@ -316,7 +316,7 @@ Type LinearMapInfo::getLinearMapType(ADContext &context, FullApplySite fai) { } Type resultType = - astFnTy->hasArchetype() ? astFnTy->mapTypeOutOfContext() : astFnTy; + astFnTy->hasArchetype() ? astFnTy->mapTypeOutOfEnvironment() : astFnTy; if (fai.getKind() == FullApplySiteKind::TryApplyInst) resultType = resultType->wrapInOptionalType(); diff --git a/lib/SILOptimizer/Differentiation/PullbackCloner.cpp b/lib/SILOptimizer/Differentiation/PullbackCloner.cpp index aa0ec54391027..3dc6056c455fe 100644 --- a/lib/SILOptimizer/Differentiation/PullbackCloner.cpp +++ b/lib/SILOptimizer/Differentiation/PullbackCloner.cpp @@ -240,7 +240,7 @@ class PullbackCloner::Implementation final /// Remap any archetypes into the current function's context. SILType remapType(SILType ty) { if (ty.hasArchetype()) - ty = ty.mapTypeOutOfContext(); + ty = ty.mapTypeOutOfEnvironment(); auto remappedType = ty.getASTType()->getReducedType( getPullback().getLoweredFunctionType()->getSubstGenericSignature()); auto remappedSILType = @@ -248,7 +248,7 @@ class PullbackCloner::Implementation final // FIXME: Sometimes getPullback() doesn't have a generic environment, in which // case callers are apparently happy to receive an interface type. if (getPullback().getGenericEnvironment()) - return getPullback().mapTypeIntoContext(remappedSILType); + return getPullback().mapTypeIntoEnvironment(remappedSILType); return remappedSILType; } @@ -2914,7 +2914,7 @@ void PullbackCloner::Implementation::emitZeroDerivativesForNonvariedResult( auto indirectResultIt = pullback.getIndirectResults().begin(); for (auto resultInfo : pullback.getLoweredFunctionType()->getResults()) { auto resultType = - pullback.mapTypeIntoContext(resultInfo.getInterfaceType()) + pullback.mapTypeIntoEnvironment(resultInfo.getInterfaceType()) ->getCanonicalType(); if (resultInfo.isFormalDirect()) directResults.push_back(builder.emitZero(pbLoc, resultType)); diff --git a/lib/SILOptimizer/Differentiation/Thunk.cpp b/lib/SILOptimizer/Differentiation/Thunk.cpp index 8081616571d9b..22e88645fa1c1 100644 --- a/lib/SILOptimizer/Differentiation/Thunk.cpp +++ b/lib/SILOptimizer/Differentiation/Thunk.cpp @@ -121,8 +121,8 @@ SILFunction *getOrCreateReabstractionThunk(SILOptFunctionBuilder &fb, auto thunkDeclType = thunkType->getWithExtInfo(thunkType->getExtInfo().withNoEscape(false)); - auto fromInterfaceType = fromType->mapTypeOutOfContext()->getCanonicalType(); - auto toInterfaceType = toType->mapTypeOutOfContext()->getCanonicalType(); + auto fromInterfaceType = fromType->mapTypeOutOfEnvironment()->getCanonicalType(); + auto toInterfaceType = toType->mapTypeOutOfEnvironment()->getCanonicalType(); Mangle::ASTMangler mangler(module.getASTContext()); std::string name = mangler.mangleReabstractionThunkHelper( @@ -207,7 +207,7 @@ SILFunction *getOrCreateReabstractionThunk(SILOptFunctionBuilder &fb, auto paramTy = fromConv.getSILType(fromType->getParameters()[paramIdx], builder.getTypeExpansionContext()); if (!paramTy.hasArchetype()) - paramTy = thunk->mapTypeIntoContext(paramTy); + paramTy = thunk->mapTypeIntoEnvironment(paramTy); assert(paramTy.isAddress()); auto toArg = *toArgIter++; auto *buf = createAllocStack(toArg->getType()); @@ -417,7 +417,7 @@ getOrCreateSubsetParametersThunkForLinearMap( Mangle::DifferentiationMangler mangler(parentThunk->getASTContext()); auto fromInterfaceType = - linearMapType->mapTypeOutOfContext()->getCanonicalType(); + linearMapType->mapTypeOutOfEnvironment()->getCanonicalType(); auto thunkName = mangler.mangleLinearMapSubsetParametersThunk( fromInterfaceType, kind.getLinearMapKind(), @@ -736,7 +736,7 @@ getOrCreateSubsetParametersThunkForDerivativeFunction( auto *caller = derivativeFn->getFunction(); if (targetType->hasArchetype()) { auto substTargetType = - caller->mapTypeIntoContext(targetType->mapTypeOutOfContext()) + caller->mapTypeIntoEnvironment(targetType->mapTypeOutOfEnvironment()) ->getCanonicalType(); targetType = SILType::getPrimitiveObjectType(substTargetType) .castTo(); @@ -770,7 +770,7 @@ getOrCreateSubsetParametersThunkForDerivativeFunction( assert(!origName.empty() && "Original function name could not be resolved"); Mangle::DifferentiationMangler mangler(adContext.getASTContext()); auto thunkName = mangler.mangleDerivativeFunctionSubsetParametersThunk( - origName, targetType->mapTypeOutOfContext()->getCanonicalType(), + origName, targetType->mapTypeOutOfEnvironment()->getCanonicalType(), kind, actualConfig.parameterIndices, actualConfig.resultIndices, desiredConfig.parameterIndices); @@ -806,7 +806,7 @@ getOrCreateSubsetParametersThunkForDerivativeFunction( assocRef = builder.createWitnessMethod( loc, assocMethodInst->getLookupType(), assocMethodInst->getConformance(), assocMethodInst->getMember(), - thunk->mapTypeIntoContext(assocMethodInst->getType())); + thunk->mapTypeIntoEnvironment(assocMethodInst->getType())); } else if (auto *assocMethodInst = peerThroughFunctionConversions( derivativeFn)) { @@ -817,7 +817,7 @@ getOrCreateSubsetParametersThunkForDerivativeFunction( #endif assocRef = builder.createClassMethod( loc, classOperand, assocMethodInst->getMember(), - thunk->mapTypeIntoContext(assocMethodInst->getType())); + thunk->mapTypeIntoEnvironment(assocMethodInst->getType())); } else if (auto *diffWitFn = peerThroughFunctionConversions< DifferentiabilityWitnessFunctionInst>(derivativeFn)) { assocRef = builder.createDifferentiabilityWitnessFunction( diff --git a/lib/SILOptimizer/Differentiation/VJPCloner.cpp b/lib/SILOptimizer/Differentiation/VJPCloner.cpp index 9749b5f819cb9..3e48268a3f733 100644 --- a/lib/SILOptimizer/Differentiation/VJPCloner.cpp +++ b/lib/SILOptimizer/Differentiation/VJPCloner.cpp @@ -277,7 +277,7 @@ class VJPCloner::Implementation final ParameterConvention::Direct_Guaranteed); } - auto pullbackType = vjp->mapTypeIntoContext(getPullbackType()); + auto pullbackType = vjp->mapTypeIntoEnvironment(getPullbackType()); auto pullbackFnType = pullbackType.castTo(); auto pullbackSubstType = pullbackPartialApply->getType().castTo(); diff --git a/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialTransform.cpp b/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialTransform.cpp index 6701c2412243c..76e13cc0bf4de 100644 --- a/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialTransform.cpp +++ b/lib/SILOptimizer/FunctionSignatureTransforms/ExistentialTransform.cpp @@ -141,7 +141,7 @@ void ExistentialSpecializerCloner::cloneArguments( // Clone arguments that are not rewritten. auto Ty = params[ArgDesc.Index].getArgumentType( M, NewFTy, NewF.getTypeExpansionContext()); - auto LoweredTy = NewF.getLoweredType(NewF.mapTypeIntoContext(Ty)); + auto LoweredTy = NewF.getLoweredType(NewF.mapTypeIntoEnvironment(Ty)); auto MappedTy = LoweredTy.getCategoryType(ArgDesc.Arg->getType().getCategory()); auto *NewArg = @@ -153,7 +153,7 @@ void ExistentialSpecializerCloner::cloneArguments( // Create the generic argument. GenericTypeParamType *GenericParam = iter->second; SILType GenericSILType = - NewF.getLoweredType(NewF.mapTypeIntoContext(GenericParam)); + NewF.getLoweredType(NewF.mapTypeIntoEnvironment(GenericParam)); GenericSILType = GenericSILType.getCategoryType( ArgDesc.Arg->getType().getCategory()); auto *NewArg = ClonedEntryBB->createFunctionArgument( @@ -637,7 +637,7 @@ void ExistentialTransform::createExistentialSpecializedFunction() { SubstitutionMap Subs = SubstitutionMap::get( NewFGenericSig, [&](SubstitutableType *type) -> Type { - return NewFGenericEnv->mapTypeIntoContext(type); + return NewFGenericEnv->mapTypeIntoEnvironment(type); }, LookUpConformanceInModule()); ExistentialSpecializerCloner cloner(F, NewF, Subs, ArgumentDescList, diff --git a/lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp b/lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp index 6f6ed836d5654..dedba48c73402 100644 --- a/lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp +++ b/lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp @@ -320,7 +320,7 @@ mapInterfaceTypes(SILFunction *F, if (!Param.getInterfaceType()->hasArchetype()) continue; Param = SILParameterInfo( - Param.getInterfaceType()->mapTypeOutOfContext()->getCanonicalType(), + Param.getInterfaceType()->mapTypeOutOfEnvironment()->getCanonicalType(), Param.getConvention()); } @@ -328,7 +328,7 @@ mapInterfaceTypes(SILFunction *F, if (!Result.getInterfaceType()->hasArchetype()) continue; auto InterfaceResult = Result.getWithInterfaceType( - Result.getInterfaceType()->mapTypeOutOfContext()->getCanonicalType()); + Result.getInterfaceType()->mapTypeOutOfEnvironment()->getCanonicalType()); Result = InterfaceResult; } @@ -337,7 +337,7 @@ mapInterfaceTypes(SILFunction *F, InterfaceErrorResult = SILResultInfo(InterfaceErrorResult.value() .getInterfaceType() - ->mapTypeOutOfContext() + ->mapTypeOutOfEnvironment() ->getCanonicalType(), InterfaceErrorResult.value().getConvention()); } diff --git a/lib/SILOptimizer/Mandatory/AddressLowering.cpp b/lib/SILOptimizer/Mandatory/AddressLowering.cpp index 90cec4ba14663..3eb718b0c50da 100644 --- a/lib/SILOptimizer/Mandatory/AddressLowering.cpp +++ b/lib/SILOptimizer/Mandatory/AddressLowering.cpp @@ -706,7 +706,7 @@ static unsigned insertIndirectReturnOrErrorArgs(AddressLoweringState &pass) { auto createIndirectResult = [&](SILType resultTy, StringRef internalName, unsigned argIdx) { - auto resultTyInContext = pass.function->mapTypeIntoContext(resultTy); + auto resultTyInContext = pass.function->mapTypeIntoEnvironment(resultTy); auto bodyResultTy = pass.function->getModule().Types.getLoweredType( resultTyInContext.getASTType(), *pass.function); auto var = new (astCtx) @@ -3334,7 +3334,7 @@ void YieldRewriter::rewriteYield(YieldInst *yieldInst) { void YieldRewriter::rewriteOperand(YieldInst *yieldInst, unsigned index) { auto info = opaqueFnConv.getYieldInfoForOperandIndex(index); auto convention = info.getConvention(); - auto ty = pass.function->mapTypeIntoContext( + auto ty = pass.function->mapTypeIntoEnvironment( opaqueFnConv.getSILType(info, pass.function->getTypeExpansionContext())); if (ty.isAddressOnly(*pass.function)) { assert(yieldInst->getOperand(index)->getType().isAddress() && diff --git a/lib/SILOptimizer/Mandatory/ThunkLowering.cpp b/lib/SILOptimizer/Mandatory/ThunkLowering.cpp index c471724662371..c96507be1b8a7 100644 --- a/lib/SILOptimizer/Mandatory/ThunkLowering.cpp +++ b/lib/SILOptimizer/Mandatory/ThunkLowering.cpp @@ -115,7 +115,7 @@ void ThunkBodyBuilder::createEntryBlockArguments() { for (auto indirectResult : conventions.getIndirectSILResults()) { SILType ty = conventions.getSILType(indirectResult, thunk->getTypeExpansionContext()); - ty = thunk->mapTypeIntoContext(ty); + ty = thunk->mapTypeIntoEnvironment(ty); thunkArguments.push_back(block->createFunctionArgument(ty)); } @@ -123,7 +123,7 @@ void ThunkBodyBuilder::createEntryBlockArguments() { for (auto paramInfo : conventions.getParameters()) { SILType ty = conventions.getSILType(paramInfo, thunk->getTypeExpansionContext()); - ty = thunk->mapTypeIntoContext(ty); + ty = thunk->mapTypeIntoEnvironment(ty); thunkArguments.push_back(block->createFunctionArgument(ty)); } } @@ -152,7 +152,7 @@ void ThunkBodyBuilder::callBeginApplyThunkedFunction( for (auto result : conventions.getDirectSILResults()) { auto ty = conventions.getSILType(result, thunk->getTypeExpansionContext()); - ty = thunk->mapTypeIntoContext(ty); + ty = thunk->mapTypeIntoEnvironment(ty); directResultTypes.push_back(ty.getASTType()); } @@ -199,7 +199,7 @@ void ThunkBodyBuilder::callTryApplyThunkedFunction( for (auto result : conventions.getDirectSILResults()) { auto ty = conventions.getSILType(result, thunk->getTypeExpansionContext()); - ty = thunk->mapTypeIntoContext(ty); + ty = thunk->mapTypeIntoEnvironment(ty); normalBlockArgs.push_back(ty.getASTType()); } diff --git a/lib/SILOptimizer/Transforms/EagerSpecializer.cpp b/lib/SILOptimizer/Transforms/EagerSpecializer.cpp index 13556037605b5..6c12a9398902f 100644 --- a/lib/SILOptimizer/Transforms/EagerSpecializer.cpp +++ b/lib/SILOptimizer/Transforms/EagerSpecializer.cpp @@ -440,7 +440,7 @@ void EagerDispatch::emitDispatchTo(SILFunction *NewFunc) { else { auto resultTy = GenericFunc->getConventions().getSILResultType( Builder.getTypeExpansionContext()); - auto GenResultTy = GenericFunc->mapTypeIntoContext(resultTy); + auto GenResultTy = GenericFunc->mapTypeIntoEnvironment(resultTy); SILValue CastResult = Builder.createUncheckedForwardingCast(Loc, Result, GenResultTy); @@ -469,7 +469,7 @@ void EagerDispatch:: emitTypeCheck(SILBasicBlock *FailedTypeCheckBB, SubstitutableType *ParamTy, Type SubTy) { // Instantiate a thick metatype for T.Type - auto ContextTy = GenericFunc->mapTypeIntoContext(ParamTy); + auto ContextTy = GenericFunc->mapTypeIntoEnvironment(ParamTy); auto GenericMT = Builder.createMetatype( Loc, getThickMetatypeType(ContextTy->getCanonicalType())); @@ -506,7 +506,7 @@ void EagerDispatch::emitIsTrivialCheck(SILBasicBlock *FailedTypeCheckBB, LayoutConstraint Layout) { auto &Ctx = Builder.getASTContext(); // Instantiate a thick metatype for T.Type - auto ContextTy = GenericFunc->mapTypeIntoContext(ParamTy); + auto ContextTy = GenericFunc->mapTypeIntoEnvironment(ParamTy); auto GenericMT = Builder.createMetatype( Loc, getThickMetatypeType(ContextTy->getCanonicalType())); auto BoolTy = SILType::getBuiltinIntegerType(1, Ctx); @@ -531,7 +531,7 @@ void EagerDispatch::emitTrivialAndSizeCheck(SILBasicBlock *FailedTypeCheckBB, } auto &Ctx = Builder.getASTContext(); // Instantiate a thick metatype for T.Type - auto ContextTy = GenericFunc->mapTypeIntoContext(ParamTy); + auto ContextTy = GenericFunc->mapTypeIntoEnvironment(ParamTy); auto GenericMT = Builder.createMetatype( Loc, getThickMetatypeType(ContextTy->getCanonicalType())); @@ -568,7 +568,7 @@ void EagerDispatch::emitRefCountedObjectCheck(SILBasicBlock *FailedTypeCheckBB, LayoutConstraint Layout) { auto &Ctx = Builder.getASTContext(); // Instantiate a thick metatype for T.Type - auto ContextTy = GenericFunc->mapTypeIntoContext(ParamTy); + auto ContextTy = GenericFunc->mapTypeIntoEnvironment(ParamTy); auto GenericMT = Builder.createMetatype( Loc, getThickMetatypeType(ContextTy->getCanonicalType())); diff --git a/lib/SILOptimizer/Transforms/PartialApplySimplification.cpp b/lib/SILOptimizer/Transforms/PartialApplySimplification.cpp index 3d582aba647c1..6da4ef02e046e 100644 --- a/lib/SILOptimizer/Transforms/PartialApplySimplification.cpp +++ b/lib/SILOptimizer/Transforms/PartialApplySimplification.cpp @@ -559,7 +559,7 @@ rewriteKnownCalleeWithExplicitContext(SILFunction *callee, auto &entry = *callee->begin(); // Insert an argument for the context before the originally applied args. - auto contextArgTy = callee->mapTypeIntoContext( + auto contextArgTy = callee->mapTypeIntoEnvironment( SILType::getPrimitiveObjectType(contextTy)); if (isIndirectFormalParameter(contextParam.getConvention())) { contextArgTy = contextArgTy.getAddressType(); diff --git a/lib/SILOptimizer/Utils/ConstExpr.cpp b/lib/SILOptimizer/Utils/ConstExpr.cpp index a0e33668acbb7..80572f60a2bf0 100644 --- a/lib/SILOptimizer/Utils/ConstExpr.cpp +++ b/lib/SILOptimizer/Utils/ConstExpr.cpp @@ -328,7 +328,7 @@ SymbolicValue ConstExprFunctionState::computeConstantValue(SILValue value) { // Try to resolve a witness method against our known conformances. if (auto *wmi = dyn_cast(value)) { auto conf = substitutionMap.lookupConformance( - wmi->getLookupType()->mapTypeOutOfContext()->getCanonicalType(), + wmi->getLookupType()->mapTypeOutOfEnvironment()->getCanonicalType(), wmi->getConformance().getProtocol()); if (conf.isInvalid()) return getUnknown(evaluator, value, diff --git a/lib/SILOptimizer/Utils/Generics.cpp b/lib/SILOptimizer/Utils/Generics.cpp index 9fbf130a2969d..9ef5e942708cf 100644 --- a/lib/SILOptimizer/Utils/Generics.cpp +++ b/lib/SILOptimizer/Utils/Generics.cpp @@ -614,7 +614,7 @@ bool ReabstractionInfo::prepareAndCheck(ApplySite Apply, SILFunction *Callee, if (CalleeGenericEnv) { if (auto Archetype = Replacement->getAs()) { auto OrigArchetype = - CalleeGenericEnv->mapTypeIntoContext(GP)->castTo(); + CalleeGenericEnv->mapTypeIntoEnvironment(GP)->castTo(); if (Archetype->requiresClass() && !OrigArchetype->requiresClass()) HasNonArchetypeGenericParams = true; if (Archetype->getLayoutConstraint() && @@ -910,7 +910,7 @@ getReturnTypeCategory(const SILResultInfo &RI, const SILFunctionConventions &substConv, TypeExpansionContext typeExpansion) { auto ResultTy = substConv.getSILType(RI, typeExpansion); - ResultTy = mapTypeIntoContext(ResultTy); + ResultTy = mapTypeIntoEnvironment(ResultTy); auto &TL = getModule().Types.getTypeLowering(ResultTy, typeExpansion); if (!TL.isLoadable()) @@ -931,7 +931,7 @@ getParamTypeCategory(const SILParameterInfo &PI, const SILFunctionConventions &substConv, TypeExpansionContext typeExpansion) { auto ParamTy = substConv.getSILType(PI, typeExpansion); - ParamTy = mapTypeIntoContext(ParamTy); + ParamTy = mapTypeIntoEnvironment(ParamTy); auto &TL = getModule().Types.getTypeLowering(ParamTy, typeExpansion); if (!TL.isLoadable()) @@ -1008,13 +1008,13 @@ CanSILFunctionType ReabstractionInfo::createThunkType(PartialApplyInst *forPAI) return newFnTy; } -SILType ReabstractionInfo::mapTypeIntoContext(SILType type) const { +SILType ReabstractionInfo::mapTypeIntoEnvironment(SILType type) const { if (Callee) { - return Callee->mapTypeIntoContext(type); + return Callee->mapTypeIntoEnvironment(type); } assert(!methodDecl.isNull()); if (auto *genericEnv = M->Types.getConstantGenericEnvironment(methodDecl)) - return genericEnv->mapTypeIntoContext(getModule(), type); + return genericEnv->mapTypeIntoEnvironment(getModule(), type); return type; } @@ -1494,7 +1494,7 @@ class FunctionSignaturePartialSpecializer { SubstitutionMap::get( SpecializedGenericSig, [&](SubstitutableType *type) -> Type { - return GenericEnvironment::mapTypeIntoContext( + return GenericEnvironment::mapTypeIntoEnvironment( CalleeGenericEnv, SpecializedGenericSig.getReducedType(type)); }, @@ -1711,7 +1711,7 @@ void FunctionSignaturePartialSpecializer:: // Add a same type requirement based on the provided generic parameter // substitutions. - auto ReplacementCallerInterfaceTy = Replacement->mapTypeOutOfContext(); + auto ReplacementCallerInterfaceTy = Replacement->mapTypeOutOfEnvironment(); auto SpecializedReplacementCallerInterfaceTy = ReplacementCallerInterfaceTy.subst( @@ -1818,7 +1818,7 @@ SubstitutionMap FunctionSignaturePartialSpecializer::computeClonerParamSubs() { CalleeGenericSig->print(llvm::dbgs())); auto SpecializedInterfaceTy = Type(type).subst(CalleeInterfaceToSpecializedInterfaceMap); - return SpecializedGenericEnv->mapTypeIntoContext( + return SpecializedGenericEnv->mapTypeIntoEnvironment( SpecializedInterfaceTy); }, LookUpConformanceInModule()); @@ -1836,8 +1836,8 @@ void FunctionSignaturePartialSpecializer::computeCallerInterfaceSubs( // First, map callee's interface type to specialized interface type. auto Ty = Type(type).subst(CalleeInterfaceToSpecializedInterfaceMap); Type SpecializedInterfaceTy = - SpecializedGenericEnv->mapTypeIntoContext(Ty) - ->mapTypeOutOfContext(); + SpecializedGenericEnv->mapTypeIntoEnvironment(Ty) + ->mapTypeOutOfEnvironment(); assert(!SpecializedInterfaceTy->hasError()); return SpecializedInterfaceTy; }, @@ -2814,7 +2814,7 @@ FullApplySite ReabstractionThunkGenerator::createApplyAndReturn( Builder.createThrowAddr(Loc); } else { SILValue errorValue = ErrorBB->createPhiArgument( - SpecializedFunc->mapTypeIntoContext( + SpecializedFunc->mapTypeIntoEnvironment( specConv.getSILErrorType(Builder.getTypeExpansionContext())), OwnershipKind::Owned); if (resultAddr.errorAddress) { @@ -2827,7 +2827,7 @@ FullApplySite ReabstractionThunkGenerator::createApplyAndReturn( } } returnValue = NormalBB->createPhiArgument( - SpecializedFunc->mapTypeIntoContext( + SpecializedFunc->mapTypeIntoEnvironment( specConv.getSILResultType(Builder.getTypeExpansionContext())), OwnershipKind::Owned); Builder.setInsertionPoint(NormalBB); @@ -2896,7 +2896,7 @@ ReabstractionThunkGenerator::convertReabstractionThunkArguments( // Store the result later. // FIXME: This only handles a single result! Partial specialization could // induce some combination of direct and indirect results. - SILType ResultTy = SpecializedFunc->mapTypeIntoContext( + SILType ResultTy = SpecializedFunc->mapTypeIntoEnvironment( substConv.getSILType(substRI, Builder.getTypeExpansionContext())); assert(ResultTy.isAddress()); assert(!resultAddr.returnAddress); @@ -2913,7 +2913,7 @@ ReabstractionThunkGenerator::convertReabstractionThunkArguments( if (thunkType->hasIndirectErrorResult()) { if (ReInfo.isErrorResultConverted()) { SILResultInfo substRI = thunkType->getErrorResult(); - SILType errorTy = SpecializedFunc->mapTypeIntoContext( + SILType errorTy = SpecializedFunc->mapTypeIntoEnvironment( substConv.getSILType(substRI, Builder.getTypeExpansionContext())); assert(errorTy.isAddress()); assert(!resultAddr.errorAddress); @@ -2940,7 +2940,7 @@ ReabstractionThunkGenerator::convertReabstractionThunkArguments( // Convert an originally indirect to direct specialized parameter. assert(!specConv.isSILIndirect(SpecType->getParameters()[specArgIdx])); // Instead of passing the address, pass the loaded value. - SILType ParamTy = SpecializedFunc->mapTypeIntoContext( + SILType ParamTy = SpecializedFunc->mapTypeIntoEnvironment( substConv.getSILType(thunkType->getParameters()[specArgIdx], Builder.getTypeExpansionContext())); assert(ParamTy.isAddress()); diff --git a/lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp b/lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp index ad677b85b9895..07b6e0fadc06d 100644 --- a/lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp +++ b/lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp @@ -716,7 +716,7 @@ static bool isCallerAndCalleeLayoutConstraintsCompatible(FullApplySite AI) { for (auto Param : SubstParams) { // Map the parameter into context - auto ContextTy = Callee->mapTypeIntoContext(Param->getCanonicalType()); + auto ContextTy = Callee->mapTypeIntoEnvironment(Param->getCanonicalType()); auto Archetype = ContextTy->getAs(); if (!Archetype) continue; diff --git a/lib/Sema/AssociatedTypeInference.cpp b/lib/Sema/AssociatedTypeInference.cpp index 2a8068f1b4b48..2802f42b929f2 100644 --- a/lib/Sema/AssociatedTypeInference.cpp +++ b/lib/Sema/AssociatedTypeInference.cpp @@ -590,7 +590,7 @@ static ResolveWitnessResult resolveTypeWitnessViaLookup( if (!viableTypes.insert(memberType->getCanonicalType()).second) continue; - auto memberTypeInContext = dc->mapTypeIntoContext(memberType); + auto memberTypeInContext = dc->mapTypeIntoEnvironment(memberType); // Check this type against the protocol requirements. if (auto checkResult = @@ -1441,7 +1441,7 @@ static bool isExtensionUsableForInference(const ExtensionDecl *extension, // because those have to be explicitly declared on the type somewhere // so won't be affected by whatever answer inference comes up with. auto checkConformance = [&](ProtocolDecl *proto) { - auto typeInContext = conformanceDC->mapTypeIntoContext(conformance->getType()); + auto typeInContext = conformanceDC->mapTypeIntoEnvironment(conformance->getType()); auto otherConf = swift::checkConformance(typeInContext, proto); return !otherConf.isInvalid(); }; @@ -1790,7 +1790,7 @@ AssociatedTypeInference::getPotentialTypeWitnessesFromRequirement( if (!allUnresolved.count(result.first)) { auto existingWitness = conformance->getTypeWitness(result.first); - existingWitness = dc->mapTypeIntoContext(existingWitness); + existingWitness = dc->mapTypeIntoEnvironment(existingWitness); // For now, only a fully-concrete binding can contradict an existing // type witness. @@ -1969,7 +1969,7 @@ static Type getWitnessTypeForMatching(NormalProtocolConformance *conformance, // Retrieve the set of substitutions to be applied to the witness. Type model = - conformance->getDeclContext()->mapTypeIntoContext(conformance->getType()); + conformance->getDeclContext()->mapTypeIntoEnvironment(conformance->getType()); TypeSubstitutionMap substitutions = model->getMemberSubstitutions(witness); type = getWithoutProtocolTypeAliases(type); @@ -2566,7 +2566,7 @@ AssociatedTypeInference::computeFailureTypeWitness( // If it isn't 'rethrows', use the thrown error type;. if (!witnessFunc->getAttrs().hasAttribute()) { return AbstractTypeWitness(assocType, - dc->mapTypeIntoContext(*thrownError)); + dc->mapTypeIntoEnvironment(*thrownError)); } for (auto req : witnessFunc->getGenericSignature().getRequirements()) { @@ -2576,7 +2576,7 @@ AssociatedTypeInference::computeFailureTypeWitness( proto->isSpecificProtocol(KnownProtocolKind::AsyncSequence)) { auto failureAssocType = proto->getAssociatedType(ctx.Id_Failure); auto failureType = DependentMemberType::get(req.getFirstType(), failureAssocType); - return AbstractTypeWitness(assocType, dc->mapTypeIntoContext(failureType)); + return AbstractTypeWitness(assocType, dc->mapTypeIntoEnvironment(failureType)); } } } @@ -2679,7 +2679,7 @@ Type AssociatedTypeInference::computeGenericParamWitness( continue; if (gp->getName() == assocType->getName()) - return dc->mapTypeIntoContext(gp); + return dc->mapTypeIntoEnvironment(gp); } } } @@ -2781,7 +2781,7 @@ bool AssociatedTypeInference::simplifyCurrentTypeWitnesses() { } auto selfTy = proto->getSelfInterfaceType()->getCanonicalType(); - auto substSelfTy = dc->mapTypeIntoContext(conformance->getType()); + auto substSelfTy = dc->mapTypeIntoEnvironment(conformance->getType()); for (auto assocType : proto->getAssociatedTypeMembers()) { if (conformance->hasTypeWitness(assocType)) @@ -2940,7 +2940,7 @@ AssociatedTypeInference::getSubstOptionsWithCurrentTypeWitnesses() { return ErrorType::get(thisProto->getASTContext()).getPointer(); } - return type->mapTypeOutOfContext().getPointer(); + return type->mapTypeOutOfEnvironment().getPointer(); }; return options; } @@ -3009,7 +3009,7 @@ bool AssociatedTypeInference::checkCurrentTypeWitnesses( } bool AssociatedTypeInference::checkConstrainedExtension(ExtensionDecl *ext) { - auto typeInContext = dc->mapTypeIntoContext(adoptee); + auto typeInContext = dc->mapTypeIntoEnvironment(adoptee); auto subs = typeInContext->getContextSubstitutionMap(ext->getExtendedNominal()); SubstOptions options = getSubstOptionsWithCurrentTypeWitnesses(); @@ -4024,7 +4024,7 @@ auto AssociatedTypeInference::solve() -> std::optional { auto derivedType = computeDerivedTypeWitness(assocType); if (derivedType.first) { recordTypeWitness(conformance, assocType, - derivedType.first->mapTypeOutOfContext(), + derivedType.first->mapTypeOutOfEnvironment(), derivedType.second); continue; } @@ -4092,7 +4092,7 @@ auto AssociatedTypeInference::solve() -> std::optional { assert(!replacement->hasTypeParameter()); if (replacement->hasArchetype()) { - replacement = replacement->mapTypeOutOfContext(); + replacement = replacement->mapTypeOutOfEnvironment(); } LLVM_DEBUG(llvm::dbgs() << "Best witness for " << assocType->getName() @@ -4585,10 +4585,10 @@ AssociatedConformanceRequest::evaluate(Evaluator &eval, // FIXME: Eliminate this, perhaps by adding a variant of // lookupConformance() taking a generic signature. if (substTy->hasTypeParameter()) - substTy = conformance->getDeclContext()->mapTypeIntoContext(substTy); + substTy = conformance->getDeclContext()->mapTypeIntoEnvironment(substTy); return lookupConformance(substTy, reqProto, /*allowMissing=*/true) - .mapConformanceOutOfContext(); + .mapConformanceOutOfEnvironment(); } TinyPtrVector diff --git a/lib/Sema/BuilderTransform.cpp b/lib/Sema/BuilderTransform.cpp index 326fb242476f9..38bb7678b336b 100644 --- a/lib/Sema/BuilderTransform.cpp +++ b/lib/Sema/BuilderTransform.cpp @@ -956,7 +956,7 @@ TypeChecker::applyResultBuilderBodyTransform(FuncDecl *func, Type builderType) { options |= ConstraintSystemFlags::DebugConstraints; auto resultInterfaceTy = func->getResultInterfaceType(); - auto resultContextType = func->mapTypeIntoContext(resultInterfaceTy); + auto resultContextType = func->mapTypeIntoEnvironment(resultInterfaceTy); // Determine whether we're inferring the underlying type for the opaque // result type of this function. @@ -982,7 +982,7 @@ TypeChecker::applyResultBuilderBodyTransform(FuncDecl *func, Type builderType) { // parameters to appear in the result builder type, because // the result builder type will only be used inside the body // of this decl; it's not part of the interface type. - builderType = func->mapTypeIntoContext(builderType); + builderType = func->mapTypeIntoEnvironment(builderType); { auto result = cs.matchResultBuilder( diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index b0cd62eefe1f0..095bf58abd1b5 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -1246,7 +1246,7 @@ namespace { auto *param = thunkParamList->get(idx); auto arg = thunkTy->getParams()[idx]; - param->setInterfaceType(arg.getParameterType()->mapTypeOutOfContext()); + param->setInterfaceType(arg.getParameterType()->mapTypeOutOfEnvironment()); param->setSpecifier(ParamDecl::getParameterSpecifierForValueOwnership( arg.getValueOwnership())); } @@ -1382,7 +1382,7 @@ namespace { new (ctx) ParamDecl(SourceLoc(), /*argument label*/ SourceLoc(), Identifier(), /*parameter name*/ SourceLoc(), ctx.Id_self, dc); - selfParamDecl->setInterfaceType(selfThunkParamTy->mapTypeOutOfContext()); + selfParamDecl->setInterfaceType(selfThunkParamTy->mapTypeOutOfEnvironment()); selfParamDecl->setSpecifier( ParamDecl::getParameterSpecifierForValueOwnership( selfThunkParam.getValueOwnership())); @@ -1557,7 +1557,7 @@ namespace { ctx.getIdentifier("$base$"), dc); capture->setImplicit(); - capture->setInterfaceType(base->getType()->mapTypeOutOfContext()); + capture->setInterfaceType(base->getType()->mapTypeOutOfEnvironment()); auto *capturePat = NamedPattern::createImplicit(ctx, capture, base->getType()); @@ -5276,7 +5276,7 @@ namespace { SourceLoc(), /*argument label*/ SourceLoc(), Identifier(), /*parameter name*/ SourceLoc(), ctx.getIdentifier("$0"), closure); - param->setInterfaceType(baseTy->mapTypeOutOfContext()); + param->setInterfaceType(baseTy->mapTypeOutOfEnvironment()); param->setSpecifier(ParamSpecifier::Default); param->setImplicit(); @@ -5292,7 +5292,7 @@ namespace { ctx.getIdentifier("$kp$"), dc); outerParam->setImplicit(); - outerParam->setInterfaceType(keyPathTy->mapTypeOutOfContext()); + outerParam->setInterfaceType(keyPathTy->mapTypeOutOfEnvironment()); auto *outerParamPat = NamedPattern::createImplicit(ctx, outerParam, keyPathTy); @@ -5529,7 +5529,7 @@ namespace { Expr *visitTapExpr(TapExpr *E) { auto type = simplifyType(cs.getType(E)); - E->getVar()->setInterfaceType(type->mapTypeOutOfContext()); + E->getVar()->setInterfaceType(type->mapTypeOutOfEnvironment()); cs.setType(E, type); E->setType(type); @@ -9192,7 +9192,7 @@ static Pattern *rewriteExprPattern(const SyntacticElementTarget &matchTarget, return nullptr; EP->setMatchExpr(resultTarget->getAsExpr()); - EP->getMatchVar()->setInterfaceType(patternTy->mapTypeOutOfContext()); + EP->getMatchVar()->setInterfaceType(patternTy->mapTypeOutOfEnvironment()); EP->setType(patternTy); return EP; } @@ -9270,7 +9270,7 @@ applySolutionToInitialization(SyntacticElementTarget target, Expr *initializer, // been subsumed by the backing property. if (wrappedVar) { ctx.setSideCachedPropertyWrapperBackingPropertyType( - wrappedVar, initType->mapTypeOutOfContext()); + wrappedVar, initType->mapTypeOutOfEnvironment()); // Record the semantic initializer on the outermost property wrapper. wrappedVar->getOutermostAttachedPropertyWrapper()->setSemanticInit( @@ -9334,7 +9334,7 @@ applySolutionToInitialization(SyntacticElementTarget target, Expr *initializer, resultTarget.getAsExpr()->forEachChildExpr([&](Expr *expr) -> Expr * { if (auto coercionExpr = dyn_cast(expr)) { auto newSubstitutions = - coercionExpr->substitutions.mapReplacementTypesOutOfContext(); + coercionExpr->substitutions.mapReplacementTypesOutOfEnvironment(); if (substitutions.empty()) { substitutions = newSubstitutions; } else { @@ -9730,7 +9730,7 @@ ExprWalker::rewriteTarget(SyntacticElementTarget target) { auto &ctx = solution.getConstraintSystem().getASTContext(); ctx.setSideCachedPropertyWrapperBackingPropertyType( - wrappedVar, backingType->mapTypeOutOfContext()); + wrappedVar, backingType->mapTypeOutOfEnvironment()); return target; } else if (target.getAsUninitializedVar()) { diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index 70bea706011e1..a99a2eb0c7f0d 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -4678,7 +4678,7 @@ bool UnintendedExtraGenericParamMemberFailure::diagnoseAsError() { auto baseType = resolveType(getBaseType())->getWithoutSpecifierType(); auto archetype = baseType->getMetatypeInstanceType()->castTo(); auto genericTy = - archetype->mapTypeOutOfContext()->castTo(); + archetype->mapTypeOutOfEnvironment()->castTo(); SourceLoc loc = genericTy->getDecl()->getSourceRange().End; StringRef replacement; diff --git a/lib/Sema/CSGen.cpp b/lib/Sema/CSGen.cpp index 247c342804694..4653856e441ed 100644 --- a/lib/Sema/CSGen.cpp +++ b/lib/Sema/CSGen.cpp @@ -1692,7 +1692,7 @@ namespace { assert(typeContext); auto selfTy = - CS.DC->mapTypeIntoContext(typeContext->getDeclaredInterfaceType()); + CS.DC->mapTypeIntoEnvironment(typeContext->getDeclaredInterfaceType()); auto superclassTy = selfTy->getSuperclass(); if (!superclassTy) diff --git a/lib/Sema/CSRanking.cpp b/lib/Sema/CSRanking.cpp index 0ee10d340d5ad..3e506750bd296 100644 --- a/lib/Sema/CSRanking.cpp +++ b/lib/Sema/CSRanking.cpp @@ -436,7 +436,7 @@ static bool isProtocolExtensionAsSpecializedAs(DeclContext *dc1, cs.addConstraint(ConstraintKind::Bind, replacements[0].second, - dc1->mapTypeIntoContext(selfType1), + dc1->mapTypeIntoEnvironment(selfType1), nullptr); // Solve the system. If the first extension is at least as specialized as the @@ -610,7 +610,7 @@ bool CompareDeclSpecializationRequest::evaluate( auto openedType1 = openType(cs, innerDC1, outerDC1, type1, replacements, locator); for (auto replacement : replacements) { - if (auto mapped = innerDC1->mapTypeIntoContext(replacement.first)) { + if (auto mapped = innerDC1->mapTypeIntoEnvironment(replacement.first)) { cs.addConstraint(ConstraintKind::Bind, replacement.second, mapped, locator); } @@ -1208,9 +1208,9 @@ SolutionCompareResult ConstraintSystem::compareSolutions( // If both are convenience initializers, and the instance type of // one is a subtype of the other's, favor the subtype constructor. - auto resType1 = ctor1->mapTypeIntoContext( + auto resType1 = ctor1->mapTypeIntoEnvironment( ctor1->getResultInterfaceType()); - auto resType2 = ctor2->mapTypeIntoContext( + auto resType2 = ctor2->mapTypeIntoEnvironment( ctor2->getResultInterfaceType()); if (!resType1->isEqual(resType2)) { diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index f1f9ec638bf0b..21797bc5454b7 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -9969,13 +9969,13 @@ ConstraintSystem::matchPackElementType(Type elementType, Type patternType, } auto shapeParam = CanGenericTypeParamType(cast( - shapeClass->mapTypeOutOfContext()->getCanonicalType())); + shapeClass->mapTypeOutOfEnvironment()->getCanonicalType())); auto *genericEnv = getPackExpansionEnvironment(packExpansion); if (genericEnv) { if (shapeParam != genericEnv->getOpenedElementShapeClass()) { return tryFix([&]() { - auto envShape = genericEnv->mapTypeIntoContext( + auto envShape = genericEnv->mapTypeIntoEnvironment( genericEnv->getOpenedElementShapeClass()); if (auto *pack = dyn_cast(envShape)) envShape = pack->unwrapSingletonPackExpansion()->getPatternType(); @@ -11771,7 +11771,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint( if (auto archetype = baseTy->getMetatypeInstanceType()->getAs()) { if (auto genericTy = - archetype->mapTypeOutOfContext()->getAs()) { + archetype->mapTypeOutOfEnvironment()->getAs()) { for (auto param : DC->getGenericSignatureOfContext() .getGenericParams()) { // Find a param at the same depth and one index past the type we're diff --git a/lib/Sema/CSSyntacticElement.cpp b/lib/Sema/CSSyntacticElement.cpp index 9fb95156411d9..355d843c7ad6d 100644 --- a/lib/Sema/CSSyntacticElement.cpp +++ b/lib/Sema/CSSyntacticElement.cpp @@ -2046,7 +2046,7 @@ class SyntacticElementSolutionApplication for (auto *expected : caseStmt->getCaseBodyVariables()) { assert(expected->hasName()); auto prev = expected->getParentVarDecl(); - auto type = solution.getResolvedType(prev)->mapTypeOutOfContext(); + auto type = solution.getResolvedType(prev)->mapTypeOutOfEnvironment(); expected->setInterfaceType(type); } } @@ -2567,19 +2567,19 @@ static void applySolutionToClosurePropertyWrappers(ClosureExpr *closure, // Set the interface type of each property wrapper synthesized var auto *backingVar = param->getPropertyWrapperBackingProperty(); auto backingType = solution.simplifyType(solution.getType(backingVar)) - ->mapTypeOutOfContext(); + ->mapTypeOutOfEnvironment(); backingVar->setInterfaceType(backingType); if (auto *projectionVar = param->getPropertyWrapperProjectionVar()) { projectionVar->setInterfaceType( solution.simplifyType(solution.getType(projectionVar)) - ->mapTypeOutOfContext()); + ->mapTypeOutOfEnvironment()); } auto *wrappedValueVar = param->getPropertyWrapperWrappedValueVar(); auto wrappedValueType = solution.simplifyType(solution.getType(wrappedValueVar)) - ->mapTypeOutOfContext(); + ->mapTypeOutOfEnvironment(); wrappedValueVar->setInterfaceType( wrappedValueType->getWithoutSpecifierType()); diff --git a/lib/Sema/CodeSynthesis.cpp b/lib/Sema/CodeSynthesis.cpp index 8adecd324e952..26d5595dea0aa 100644 --- a/lib/Sema/CodeSynthesis.cpp +++ b/lib/Sema/CodeSynthesis.cpp @@ -692,7 +692,7 @@ synthesizeDesignatedInitOverride(AbstractFunctionDecl *fn, void *context) { type = funcTy->getResult(); superclassCallExpr->setType(type); if (auto thrownInterfaceType = ctor->getEffectiveThrownErrorType()) { - Type superThrownType = ctor->mapTypeIntoContext(*thrownInterfaceType); + Type superThrownType = ctor->mapTypeIntoEnvironment(*thrownInterfaceType); superclassCallExpr->setThrows( ThrownErrorDestination::forMatchingContextType(superThrownType)); } else { @@ -786,7 +786,7 @@ createDesignatedInitOverride(ClassDecl *classDecl, superclassCtorSig.getRequirements(), [&](Type type) -> Type { auto substType = type.subst(subMap); - return GenericEnvironment::mapTypeIntoContext(genericEnv, substType); + return GenericEnvironment::mapTypeIntoEnvironment(genericEnv, substType); }); if (checkResult != CheckRequirementsResult::Success) return nullptr; diff --git a/lib/Sema/CodeSynthesisDistributedActor.cpp b/lib/Sema/CodeSynthesisDistributedActor.cpp index 6ce5bbd149350..80fe5a65f4aa1 100644 --- a/lib/Sema/CodeSynthesisDistributedActor.cpp +++ b/lib/Sema/CodeSynthesisDistributedActor.cpp @@ -46,7 +46,7 @@ static void forwardParameters(AbstractFunctionDecl *afd, forwardingParams.push_back(new (C) DeclRefExpr( ConcreteDeclRef(param), DeclNameLoc(), /*implicit=*/true, swift::AccessSemantics::Ordinary, - afd->mapTypeIntoContext(param->getInterfaceType()))); + afd->mapTypeIntoEnvironment(param->getInterfaceType()))); } } @@ -201,7 +201,7 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) { UnresolvedDeclRefExpr::createImplicit(C, recordGenericSubstitutionName); for (auto genParamType : genEnv->getGenericParams()) { - auto tyExpr = TypeExpr::createImplicit(genEnv->mapTypeIntoContext(genParamType), C); + auto tyExpr = TypeExpr::createImplicit(genEnv->mapTypeIntoEnvironment(genParamType), C); auto subTypeExpr = new (C) DotSelfExpr( tyExpr, sloc, sloc, tyExpr->getType()); @@ -258,7 +258,7 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) { auto remoteCallArgumentInitDecl = RCA->getDistributedRemoteCallArgumentInitFunction(); auto boundRCAType = BoundGenericType::get( - RCA, Type(), {thunk->mapTypeIntoContext(param->getInterfaceType())}); + RCA, Type(), {thunk->mapTypeIntoEnvironment(param->getInterfaceType())}); auto remoteCallArgumentInitDeclRef = TypeExpr::createImplicit(boundRCAType, C); @@ -273,7 +273,7 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) { new (C) DeclRefExpr( ConcreteDeclRef(param), dloc, implicit, AccessSemantics::Ordinary, - thunk->mapTypeIntoContext(param->getInterfaceType())) + thunk->mapTypeIntoEnvironment(param->getInterfaceType())) }, C); @@ -342,7 +342,7 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) { // Result.self // Watch out and always map into thunk context - auto resultType = thunk->mapTypeIntoContext(func->getResultInterfaceType()); + auto resultType = thunk->mapTypeIntoEnvironment(func->getResultInterfaceType()); auto *metaTypeRef = TypeExpr::createImplicit(resultType, C); auto *resultTypeExpr = new (C) DotSelfExpr(metaTypeRef, sloc, sloc, resultType); @@ -479,7 +479,7 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) { if (!isVoidReturn) { // Result.self auto resultType = - func->mapTypeIntoContext(func->getResultInterfaceType()); + func->mapTypeIntoEnvironment(func->getResultInterfaceType()); auto *metaTypeRef = TypeExpr::createImplicit(resultType, C); auto *resultTypeExpr = new (C) DotSelfExpr(metaTypeRef, sloc, sloc, resultType); diff --git a/lib/Sema/ConstraintSystem.cpp b/lib/Sema/ConstraintSystem.cpp index ec430186921a3..9701c4005add6 100644 --- a/lib/Sema/ConstraintSystem.cpp +++ b/lib/Sema/ConstraintSystem.cpp @@ -549,7 +549,7 @@ Type ConstraintSystem::getExplicitCaughtErrorType(CatchNode catchNode) { // If there is an explicit caught type for this node, use it. if (Type explicitCaughtType = catchNode.getExplicitCaughtType(ctx)) { if (explicitCaughtType->hasTypeParameter()) - explicitCaughtType = DC->mapTypeIntoContext(explicitCaughtType); + explicitCaughtType = DC->mapTypeIntoEnvironment(explicitCaughtType); return explicitCaughtType; } @@ -1277,7 +1277,7 @@ static Type getPropertyWrapperTypeFromOverload( if (auto baseType = resolvedOverload.choice.getBaseType()) { ty = baseType->getRValueType()->getTypeOfMember(wrapperVar, ty); } else { - ty = cs.DC->mapTypeIntoContext(ty); + ty = cs.DC->mapTypeIntoEnvironment(ty); } return ty; } @@ -1913,7 +1913,7 @@ static Type replacePlaceholderType(PlaceholderType *placeholder, // logic work with ErrorTypes instead. if (forCompletion) { if (auto *GP = replacement->getAs()) - return GP->getDecl()->getInnermostDeclContext()->mapTypeIntoContext(GP); + return GP->getDecl()->getInnermostDeclContext()->mapTypeIntoEnvironment(GP); } // Return an ErrorType with the replacement as the original type. Note that // if we failed to replace a type variable with a generic parameter, @@ -1926,7 +1926,7 @@ Type Solution::simplifyType(Type type, bool wantInterfaceType, // If we've been asked for an interface type, start by mapping any archetypes // out of context. if (wantInterfaceType) - type = type->mapTypeOutOfContext(); + type = type->mapTypeOutOfEnvironment(); if (!type->hasTypeVariableOrPlaceholder()) return type; @@ -1940,7 +1940,7 @@ Type Solution::simplifyType(Type type, bool wantInterfaceType, if (wantInterfaceType) { if (auto *gp = tvt->getImpl().getGenericParameter()) return gp; - return getFixedType(tvt)->mapTypeOutOfContext(); + return getFixedType(tvt)->mapTypeOutOfEnvironment(); } return getFixedType(tvt); }); diff --git a/lib/Sema/DerivedConformance/DerivedConformance.cpp b/lib/Sema/DerivedConformance/DerivedConformance.cpp index 2b8df914ddcf6..966c7c4206525 100644 --- a/lib/Sema/DerivedConformance/DerivedConformance.cpp +++ b/lib/Sema/DerivedConformance/DerivedConformance.cpp @@ -191,7 +191,7 @@ DerivedConformance::storedPropertiesNotConformingToProtocol( if (!type) nonconformingProperties.push_back(propertyDecl); - if (!checkConformance(DC->mapTypeIntoContext(type), protocol)) { + if (!checkConformance(DC->mapTypeIntoEnvironment(type), protocol)) { nonconformingProperties.push_back(propertyDecl); } } @@ -563,7 +563,7 @@ DerivedConformance::declareDerivedProperty(SynthesizedIntroducer intro, propDecl->setInterfaceType(propertyInterfaceType); auto propertyContextType = - getConformanceContext()->mapTypeIntoContext(propertyInterfaceType); + getConformanceContext()->mapTypeIntoEnvironment(propertyInterfaceType); Pattern *propPat = NamedPattern::createImplicit(Context, propDecl, propertyContextType); @@ -830,7 +830,7 @@ DerivedConformance::associatedValuesNotConformingToProtocol( for (auto param : *PL) { auto type = param->getInterfaceType(); - if (checkConformance(DC->mapTypeIntoContext(type), protocol).isInvalid()) { + if (checkConformance(DC->mapTypeIntoEnvironment(type), protocol).isInvalid()) { nonconformingAssociatedValues.push_back(param); } } diff --git a/lib/Sema/DerivedConformance/DerivedConformanceAdditiveArithmetic.cpp b/lib/Sema/DerivedConformance/DerivedConformanceAdditiveArithmetic.cpp index 8536399325c01..80f85e72ab96a 100644 --- a/lib/Sema/DerivedConformance/DerivedConformanceAdditiveArithmetic.cpp +++ b/lib/Sema/DerivedConformance/DerivedConformanceAdditiveArithmetic.cpp @@ -77,7 +77,7 @@ bool DerivedConformance::canDeriveAdditiveArithmetic(NominalTypeDecl *nominal, return llvm::all_of(structDecl->getStoredProperties(), [&](VarDecl *v) { if (v->getInterfaceType()->hasError()) return false; - auto varType = DC->mapTypeIntoContext(v->getValueInterfaceType()); + auto varType = DC->mapTypeIntoEnvironment(v->getValueInterfaceType()); return (bool) checkConformance(varType, proto); }); } @@ -97,7 +97,7 @@ deriveBodyMathOperator(AbstractFunctionDecl *funcDecl, MathOperator op) { initDRE->setFunctionRefInfo(FunctionRefInfo::singleBaseNameApply()); auto *nominalTypeExpr = TypeExpr::createImplicitForDecl( DeclNameLoc(), nominal, funcDecl, - funcDecl->mapTypeIntoContext(nominal->getInterfaceType())); + funcDecl->mapTypeIntoEnvironment(nominal->getInterfaceType())); auto *initExpr = ConstructorRefCallExpr::create(C, initDRE, nominalTypeExpr); // Get operator protocol requirement. @@ -111,7 +111,7 @@ deriveBodyMathOperator(AbstractFunctionDecl *funcDecl, MathOperator op) { // Create expression combining lhs and rhs members using member operator. auto createMemberOpExpr = [&](VarDecl *member) -> Expr * { auto memberType = - parentDC->mapTypeIntoContext(member->getValueInterfaceType()); + parentDC->mapTypeIntoEnvironment(member->getValueInterfaceType()); auto confRef = lookupConformance(memberType, proto); assert(confRef && "Member does not conform to math protocol"); @@ -227,12 +227,12 @@ deriveBodyPropertyGetter(AbstractFunctionDecl *funcDecl, ProtocolDecl *proto, auto *nominalTypeExpr = TypeExpr::createImplicitForDecl( DeclNameLoc(), nominal, funcDecl, - funcDecl->mapTypeIntoContext(nominal->getInterfaceType())); + funcDecl->mapTypeIntoEnvironment(nominal->getInterfaceType())); auto *initExpr = ConstructorRefCallExpr::create(C, initDRE, nominalTypeExpr); auto createMemberPropertyExpr = [&](VarDecl *member) -> Expr * { auto memberType = - parentDC->mapTypeIntoContext(member->getValueInterfaceType()); + parentDC->mapTypeIntoEnvironment(member->getValueInterfaceType()); Expr *memberExpr = nullptr; // If the property is static, create a type expression: `Member`. if (reqDecl->isStatic()) { diff --git a/lib/Sema/DerivedConformance/DerivedConformanceCaseIterable.cpp b/lib/Sema/DerivedConformance/DerivedConformanceCaseIterable.cpp index 784f069e3bb53..8bc2aef680eae 100644 --- a/lib/Sema/DerivedConformance/DerivedConformanceCaseIterable.cpp +++ b/lib/Sema/DerivedConformance/DerivedConformanceCaseIterable.cpp @@ -76,7 +76,7 @@ static Type deriveCaseIterable_AllCases(DerivedConformance &derived) { // typealias AllCases = [SomeEnum] // } auto *rawInterfaceType = computeAllCasesType(cast(derived.Nominal)); - return derived.getConformanceContext()->mapTypeIntoContext(rawInterfaceType); + return derived.getConformanceContext()->mapTypeIntoEnvironment(rawInterfaceType); } ValueDecl *DerivedConformance::deriveCaseIterable(ValueDecl *requirement) { diff --git a/lib/Sema/DerivedConformance/DerivedConformanceCodable.cpp b/lib/Sema/DerivedConformance/DerivedConformanceCodable.cpp index 0ad1eb60d40c2..cc5b510e74e4d 100644 --- a/lib/Sema/DerivedConformance/DerivedConformanceCodable.cpp +++ b/lib/Sema/DerivedConformance/DerivedConformanceCodable.cpp @@ -335,7 +335,7 @@ static bool validateCodingKeysEnum(const DerivedConformance &derived, } // We have a property to map to. Ensure it's {En,De}codable. - auto target = derived.getConformanceContext()->mapTypeIntoContext( + auto target = derived.getConformanceContext()->mapTypeIntoEnvironment( it->second->getValueInterfaceType()); if (checkConformance(target, derived.Protocol).isInvalid()) { TypeLoc typeLoc = { @@ -632,7 +632,7 @@ static CallExpr *createContainerKeyedByCall(ASTContext &C, DeclContext *DC, // CodingKeys.self expr auto *codingKeysExpr = TypeExpr::createImplicitForDecl( DeclNameLoc(), param, param->getDeclContext(), - DC->mapTypeIntoContext(param->getInterfaceType())); + DC->mapTypeIntoEnvironment(param->getInterfaceType())); auto *codingKeysMetaTypeExpr = new (C) DotSelfExpr(codingKeysExpr, SourceLoc(), SourceLoc()); @@ -652,13 +652,13 @@ static CallExpr *createNestedContainerKeyedByForKeyCall( // CodingKeys.self expr auto *codingKeysExpr = TypeExpr::createImplicitForDecl( DeclNameLoc(), codingKeysType, codingKeysType->getDeclContext(), - DC->mapTypeIntoContext(codingKeysType->getInterfaceType())); + DC->mapTypeIntoEnvironment(codingKeysType->getInterfaceType())); auto *codingKeysMetaTypeExpr = new (C) DotSelfExpr(codingKeysExpr, SourceLoc(), SourceLoc()); // key expr auto *metaTyRef = TypeExpr::createImplicit( - DC->mapTypeIntoContext(key->getParentEnum()->getDeclaredInterfaceType()), + DC->mapTypeIntoEnvironment(key->getParentEnum()->getDeclaredInterfaceType()), C); auto *keyExpr = new (C) MemberRefExpr(metaTyRef, SourceLoc(), key, DeclNameLoc(), /*Implicit=*/true); @@ -743,7 +743,7 @@ lookupVarDeclForCodingKeysCase(DeclContext *conformanceDC, // This is the VarDecl we're looking for. auto varType = - conformanceDC->mapTypeIntoContext(vd->getValueInterfaceType()); + conformanceDC->mapTypeIntoEnvironment(vd->getValueInterfaceType()); bool useIfPresentVariant = false; @@ -962,7 +962,7 @@ createEnumSwitch(ASTContext &C, DeclContext *DC, Expr *expr, EnumDecl *enumDecl, if (caseBody) { // generate: case .: - auto parentTy = DC->mapTypeIntoContext( + auto parentTy = DC->mapTypeIntoEnvironment( targetElt->getParentEnum()->getDeclaredInterfaceType()); auto *pat = EnumElementPattern::createImplicit(parentTy, targetElt, subpattern, DC); @@ -1162,7 +1162,7 @@ deriveBodyEncodable_enum_encode(AbstractFunctionDecl *encodeDecl, void *) { if (!caseCodingKey) continue; - auto varType = conformanceDC->mapTypeIntoContext( + auto varType = conformanceDC->mapTypeIntoEnvironment( payloadVar->getValueInterfaceType()); bool useIfPresentVariant = false; @@ -1674,7 +1674,7 @@ deriveBodyDecodable_enum_init(AbstractFunctionDecl *initDecl, void *) { } auto *targetType = TypeExpr::createImplicit( - funcDC->mapTypeIntoContext(targetEnum->getDeclaredInterfaceType()), C); + funcDC->mapTypeIntoEnvironment(targetEnum->getDeclaredInterfaceType()), C); auto *targetTypeExpr = new (C) DotSelfExpr(targetType, SourceLoc(), SourceLoc()); @@ -1769,7 +1769,7 @@ deriveBodyDecodable_enum_init(AbstractFunctionDecl *initDecl, void *) { continue; } - auto varType = conformanceDC->mapTypeIntoContext( + auto varType = conformanceDC->mapTypeIntoEnvironment( paramDecl->getValueInterfaceType()); bool useIfPresentVariant = false; diff --git a/lib/Sema/DerivedConformance/DerivedConformanceCodingKey.cpp b/lib/Sema/DerivedConformance/DerivedConformanceCodingKey.cpp index ecbce38ca3032..0ae2967520aab 100644 --- a/lib/Sema/DerivedConformance/DerivedConformanceCodingKey.cpp +++ b/lib/Sema/DerivedConformance/DerivedConformanceCodingKey.cpp @@ -322,7 +322,7 @@ static bool canSynthesizeCodingKey(DerivedConformance &derived) { Type rawType = enumDecl->getRawType(); if (rawType) { auto *parentDC = derived.getConformanceContext(); - rawType = parentDC->mapTypeIntoContext(rawType); + rawType = parentDC->mapTypeIntoEnvironment(rawType); if (!rawType->isString() && !rawType->isInt()) { return false; diff --git a/lib/Sema/DerivedConformance/DerivedConformanceDifferentiable.cpp b/lib/Sema/DerivedConformance/DerivedConformanceDifferentiable.cpp index e05ee5cf024db..a550e429f37e7 100644 --- a/lib/Sema/DerivedConformance/DerivedConformanceDifferentiable.cpp +++ b/lib/Sema/DerivedConformance/DerivedConformanceDifferentiable.cpp @@ -83,7 +83,7 @@ getStoredPropertiesForDifferentiation( continue; if (vd->getInterfaceType()->hasError()) continue; - auto varType = DC->mapTypeIntoContext(vd->getValueInterfaceType()); + auto varType = DC->mapTypeIntoEnvironment(vd->getValueInterfaceType()); auto conformance = checkConformance(varType, diffableProto); if (!conformance) continue; @@ -121,7 +121,7 @@ static Type getTangentVectorInterfaceType(Type contextualType, if (!conf) return nullptr; auto tanType = conf.getTypeWitnessByName(C.Id_TangentVector); - return tanType->hasArchetype() ? tanType->mapTypeOutOfContext() : tanType; + return tanType->hasArchetype() ? tanType->mapTypeOutOfEnvironment() : tanType; } /// Returns true iff the given nominal type declaration can derive @@ -133,7 +133,7 @@ static bool canDeriveTangentVectorAsSelf(NominalTypeDecl *nominal, return false; auto nominalTypeInContext = - DC->mapTypeIntoContext(nominal->getDeclaredInterfaceType()); + DC->mapTypeIntoEnvironment(nominal->getDeclaredInterfaceType()); auto &C = nominal->getASTContext(); auto *diffableProto = C.getProtocol(KnownProtocolKind::Differentiable); auto *addArithProto = C.getProtocol(KnownProtocolKind::AdditiveArithmetic); @@ -145,7 +145,7 @@ static bool canDeriveTangentVectorAsSelf(NominalTypeDecl *nominal, if (field->getAttrs().hasAttribute()) return false; // `Self` must have all stored properties satisfy `Self == TangentVector`. - auto fieldType = DC->mapTypeIntoContext(field->getValueInterfaceType()); + auto fieldType = DC->mapTypeIntoEnvironment(field->getValueInterfaceType()); auto conf = checkConformance(fieldType, diffableProto); if (!conf) return false; @@ -208,7 +208,7 @@ bool DerivedConformance::canDeriveDifferentiable(NominalTypeDecl *nominal, return llvm::all_of(diffProperties, [&](VarDecl *v) { if (v->getInterfaceType()->hasError()) return false; - auto varType = DC->mapTypeIntoContext(v->getValueInterfaceType()); + auto varType = DC->mapTypeIntoEnvironment(v->getValueInterfaceType()); return (bool) checkConformance(varType, diffableProto); }); } @@ -239,7 +239,7 @@ deriveBodyDifferentiable_move(AbstractFunctionDecl *funcDecl, void *) { // parameter member: `self..move(by: offset.)`. auto createMemberMethodCallExpr = [&](VarDecl *member) -> Expr * { auto memberType = - parentDC->mapTypeIntoContext(member->getValueInterfaceType()); + parentDC->mapTypeIntoEnvironment(member->getValueInterfaceType()); auto confRef = lookupConformance(memberType, diffProto); assert(confRef && "Member does not conform to `Differentiable`"); @@ -410,12 +410,12 @@ getOrSynthesizeTangentVectorStruct(DerivedConformance &derived, Identifier id) { // because that incorrectly affects memberwise initializer synthesis and // causes the type checker to not guarantee the order of these members. auto memberContextualType = - parentDC->mapTypeIntoContext(member->getValueInterfaceType()); + parentDC->mapTypeIntoEnvironment(member->getValueInterfaceType()); auto memberTanInterfaceType = getTangentVectorInterfaceType(memberContextualType, parentDC); tangentProperty->setInterfaceType(memberTanInterfaceType); auto memberTanContextType = - parentDC->mapTypeIntoContext(memberTanInterfaceType); + parentDC->mapTypeIntoEnvironment(memberTanInterfaceType); Pattern *memberPattern = NamedPattern::createImplicit(C, tangentProperty, memberTanContextType); memberPattern = @@ -550,7 +550,7 @@ static void checkAndDiagnoseImplicitNoDerivative(ASTContext &Context, if (vd->getAttrs().hasAttribute()) continue; // Check whether to diagnose stored property. - auto varType = DC->mapTypeIntoContext(vd->getValueInterfaceType()); + auto varType = DC->mapTypeIntoEnvironment(vd->getValueInterfaceType()); auto diffableConformance = checkConformance(varType, diffableProto); // If stored property should not be diagnosed, continue. if (diffableConformance && @@ -598,7 +598,7 @@ getOrSynthesizeTangentVectorStructType(DerivedConformance &derived) { // Return the `TangentVector` struct type. return std::make_pair( - parentDC->mapTypeIntoContext( + parentDC->mapTypeIntoEnvironment( tangentStruct->getDeclaredInterfaceType()), tangentStruct); } diff --git a/lib/Sema/DerivedConformance/DerivedConformanceDistributedActor.cpp b/lib/Sema/DerivedConformance/DerivedConformanceDistributedActor.cpp index 45682a0864894..84408995cc523 100644 --- a/lib/Sema/DerivedConformance/DerivedConformanceDistributedActor.cpp +++ b/lib/Sema/DerivedConformance/DerivedConformanceDistributedActor.cpp @@ -405,7 +405,7 @@ static FuncDecl *deriveDistributedActorSystem_invokeHandlerOnReturn( { ParamDecl::createImplicit( C, C.Id_handler, C.Id_handler, - system->mapTypeIntoContext(resultHandlerType), system), + system->mapTypeIntoEnvironment(resultHandlerType), system), ParamDecl::createImplicit( C, C.Id_resultBuffer, C.Id_resultBuffer, unsafeRawPointerType, system), diff --git a/lib/Sema/DerivedConformance/DerivedConformanceRawRepresentable.cpp b/lib/Sema/DerivedConformance/DerivedConformanceRawRepresentable.cpp index 7ed34ff7f5b8c..402eeb1f1c042 100644 --- a/lib/Sema/DerivedConformance/DerivedConformanceRawRepresentable.cpp +++ b/lib/Sema/DerivedConformance/DerivedConformanceRawRepresentable.cpp @@ -65,7 +65,7 @@ static Type deriveRawRepresentable_Raw(DerivedConformance &derived) { // typealias Raw = SomeType // } auto rawInterfaceType = cast(derived.Nominal)->getRawType(); - return derived.getConformanceContext()->mapTypeIntoContext(rawInterfaceType); + return derived.getConformanceContext()->mapTypeIntoEnvironment(rawInterfaceType); } static std::pair @@ -90,7 +90,7 @@ deriveBodyRawRepresentable_raw(AbstractFunctionDecl *toRawDecl, void *) { Type rawTy = enumDecl->getRawType(); assert(rawTy); - rawTy = toRawDecl->mapTypeIntoContext(rawTy); + rawTy = toRawDecl->mapTypeIntoEnvironment(rawTy); if (enumDecl->isObjC()) { // Special case: ObjC enums are represented by their raw value, so just use @@ -303,7 +303,7 @@ deriveBodyRawRepresentable_init(AbstractFunctionDecl *initDecl, void *) { Type rawTy = enumDecl->getRawType(); assert(rawTy); - rawTy = initDecl->mapTypeIntoContext(rawTy); + rawTy = initDecl->mapTypeIntoEnvironment(rawTy); bool isStringEnum = rawTy->isString(); llvm::SmallVector stringExprs; @@ -407,7 +407,7 @@ deriveRawRepresentable_init(DerivedConformance &derived) { auto enumDecl = cast(derived.Nominal); auto parentDC = derived.getConformanceContext(); auto rawInterfaceType = enumDecl->getRawType(); - auto rawType = parentDC->mapTypeIntoContext(rawInterfaceType); + auto rawType = parentDC->mapTypeIntoEnvironment(rawInterfaceType); assert([&]() -> bool { @@ -459,7 +459,7 @@ bool DerivedConformance::canDeriveRawRepresentable(DeclContext *DC, if (!computeAutomaticEnumValueKind(enumDecl)) return false; - rawType = DC->mapTypeIntoContext(rawType); + rawType = DC->mapTypeIntoEnvironment(rawType); auto inherited = enumDecl->getInherited().getEntries(); if (!inherited.empty() && inherited.front().wasValidated() && @@ -480,7 +480,7 @@ bool DerivedConformance::canDeriveRawRepresentable(DeclContext *DC, if (!rawValueDecls.empty()) { if (auto alias = dyn_cast(rawValueDecls.front())) { auto ty = alias->getDeclaredInterfaceType(); - if (!DC->mapTypeIntoContext(ty)->isEqual(rawType)) { + if (!DC->mapTypeIntoEnvironment(ty)->isEqual(rawType)) { return false; } } diff --git a/lib/Sema/LookupVisibleDecls.cpp b/lib/Sema/LookupVisibleDecls.cpp index 019505669720a..2bc2200d51e46 100644 --- a/lib/Sema/LookupVisibleDecls.cpp +++ b/lib/Sema/LookupVisibleDecls.cpp @@ -1316,7 +1316,7 @@ void swift::lookupVisibleMemberDecls(VisibleDeclConsumer &Consumer, Type BaseTy, // doing anything else. if (BaseTy->hasTypeParameter()) { assert(Sig); - BaseTy = Sig.getGenericEnvironment()->mapTypeIntoContext(BaseTy); + BaseTy = Sig.getGenericEnvironment()->mapTypeIntoEnvironment(BaseTy); } assert(CurrDC); diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp index ee90b74ddd7e8..c30820d752363 100644 --- a/lib/Sema/MiscDiagnostics.cpp +++ b/lib/Sema/MiscDiagnostics.cpp @@ -3167,11 +3167,11 @@ static bool fixItOverrideDeclarationTypesImpl( }); } if (auto *method = dyn_cast(decl)) { - auto resultType = method->mapTypeIntoContext( + auto resultType = method->mapTypeIntoEnvironment( method->getResultInterfaceType()); auto *baseMethod = cast(base); - auto baseResultType = baseMethod->mapTypeIntoContext( + auto baseResultType = baseMethod->mapTypeIntoEnvironment( baseMethod->getResultInterfaceType()); fixedAny |= checkType(resultType, ParamDecl::Specifier::Default, @@ -3194,8 +3194,8 @@ static bool fixItOverrideDeclarationTypesImpl( } auto resultType = - subscript->mapTypeIntoContext(subscript->getElementInterfaceType()); - auto baseResultType = baseSubscript->mapTypeIntoContext( + subscript->mapTypeIntoEnvironment(subscript->getElementInterfaceType()); + auto baseResultType = baseSubscript->mapTypeIntoEnvironment( baseSubscript->getElementInterfaceType()); fixedAny |= checkType(resultType, ParamDecl::Specifier::Default, baseResultType, ParamDecl::Specifier::Default, @@ -3693,7 +3693,7 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker { // If we have one successful candidate, then save it as the underlying // substitutions of the opaque decl. OpaqueDecl->setUniqueUnderlyingTypeSubstitutions( - std::get<1>(candidate).mapReplacementTypesOutOfContext()); + std::get<1>(candidate).mapReplacementTypesOutOfEnvironment()); } // There is no clear winner here since there are candidates within @@ -3759,14 +3759,14 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker { conditionalSubstitutions.push_back( OpaqueTypeDecl::ConditionallyAvailableSubstitutions::get( Ctx, queries, - std::get<1>(candidate).mapReplacementTypesOutOfContext())); + std::get<1>(candidate).mapReplacementTypesOutOfEnvironment())); } // Add universally available choice as the last one. conditionalSubstitutions.push_back( OpaqueTypeDecl::ConditionallyAvailableSubstitutions::get( Ctx, {AvailabilityQuery::universallyConstant(true)}, - universalSubstMap.mapReplacementTypesOutOfContext())); + universalSubstMap.mapReplacementTypesOutOfEnvironment())); OpaqueDecl->setConditionallyAvailableSubstitutions( conditionalSubstitutions); @@ -6749,7 +6749,7 @@ TypeChecker::omitNeedlessWords(AbstractFunctionDecl *afd) { if (auto func = dyn_cast(afd)) { resultType = func->getResultInterfaceType(); - resultType = func->mapTypeIntoContext(resultType); + resultType = func->mapTypeIntoEnvironment(resultType); returnsSelf = func->getResultInterfaceType()->hasDynamicSelfType(); } else if (isa(afd)) { resultType = contextType; diff --git a/lib/Sema/PCMacro.cpp b/lib/Sema/PCMacro.cpp index c5a1f4a7295f8..76e45e80b6804 100644 --- a/lib/Sema/PCMacro.cpp +++ b/lib/Sema/PCMacro.cpp @@ -520,7 +520,7 @@ class Instrumenter : InstrumenterBase { new (Context) VarDecl(/*IsStatic*/false, VarDecl::Introducer::Let, SourceLoc(), Context.getIdentifier(NameBuf), TypeCheckDC); - VD->setInterfaceType(MaybeLoadInitExpr->getType()->mapTypeOutOfContext()); + VD->setInterfaceType(MaybeLoadInitExpr->getType()->mapTypeOutOfEnvironment()); VD->setImplicit(); NamedPattern *NP = NamedPattern::createImplicit(Context, VD, VD->getTypeInContext()); diff --git a/lib/Sema/PlaygroundTransform.cpp b/lib/Sema/PlaygroundTransform.cpp index 44ac0531c2526..2cde51c0a8b73 100644 --- a/lib/Sema/PlaygroundTransform.cpp +++ b/lib/Sema/PlaygroundTransform.cpp @@ -806,7 +806,7 @@ class Instrumenter : InstrumenterBase { new (Context) VarDecl(/*IsStatic*/false, VarDecl::Introducer::Let, SourceLoc(), Context.getIdentifier(NameBuf), TypeCheckDC); - VD->setInterfaceType(MaybeLoadInitExpr->getType()->mapTypeOutOfContext()); + VD->setInterfaceType(MaybeLoadInitExpr->getType()->mapTypeOutOfEnvironment()); VD->setImplicit(); NamedPattern *NP = NamedPattern::createImplicit(Context, VD, VD->getTypeInContext()); @@ -820,7 +820,7 @@ class Instrumenter : InstrumenterBase { // Don't try to log ~Copyable types, as we can't pass them to the generic logging functions yet. if (auto *VD = dyn_cast_or_null(node.dyn_cast())) { auto interfaceTy = VD->getInterfaceType(); - auto contextualTy = VD->getInnermostDeclContext()->mapTypeIntoContext(interfaceTy); + auto contextualTy = VD->getInnermostDeclContext()->mapTypeIntoEnvironment(interfaceTy); return contextualTy->isCopyable(); } else if (auto *E = node.dyn_cast()) { return E->getType()->isCopyable(); diff --git a/lib/Sema/PreCheckTarget.cpp b/lib/Sema/PreCheckTarget.cpp index 637ecfff9536b..4ee4290dd81b4 100644 --- a/lib/Sema/PreCheckTarget.cpp +++ b/lib/Sema/PreCheckTarget.cpp @@ -694,7 +694,7 @@ static Expr *resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE, DeclContext *DC, // synthesized code, in that case, don't map the type into context, // but return as is -- the synthesis should ensure the type is // correct. - LookupDC ? LookupDC->mapTypeIntoContext(D->getInterfaceType()) + LookupDC ? LookupDC->mapTypeIntoEnvironment(D->getInterfaceType()) : D->getInterfaceType()); } else { if (makeTypeValue) { @@ -815,11 +815,11 @@ static Expr *resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE, DeclContext *DC, BaseExpr = TypeExpr::createImplicitForDecl( UDRE->getNameLoc(), selfParam, /*DC*/ nullptr, - DC->mapTypeIntoContext(selfParam->getInterfaceType())); + DC->mapTypeIntoEnvironment(selfParam->getInterfaceType())); } else if (auto NTD = dyn_cast(Base)) { BaseExpr = TypeExpr::createImplicitForDecl( UDRE->getNameLoc(), NTD, BaseDC, - DC->mapTypeIntoContext(NTD->getInterfaceType())); + DC->mapTypeIntoEnvironment(NTD->getInterfaceType())); } else { BaseExpr = new (Context) DeclRefExpr(Base, UDRE->getNameLoc(), /*Implicit=*/true); diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index acf377600d707..c16e0bb558eb7 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -5957,9 +5957,9 @@ IndexSubset *TypeChecker::inferDifferentiabilityParameters( return false; auto paramType = allParamTypes[i]; if (derivativeGenEnv) - paramType = derivativeGenEnv->mapTypeIntoContext(paramType); + paramType = derivativeGenEnv->mapTypeIntoEnvironment(paramType); else - paramType = AFD->mapTypeIntoContext(paramType); + paramType = AFD->mapTypeIntoEnvironment(paramType); // Return false for existential types. if (paramType->isExistentialType()) return false; @@ -6021,9 +6021,9 @@ static IndexSubset *computeDifferentiabilityParameters( else { auto selfType = function->getImplicitSelfDecl()->getInterfaceType(); if (derivativeGenEnv) - selfType = derivativeGenEnv->mapTypeIntoContext(selfType); + selfType = derivativeGenEnv->mapTypeIntoEnvironment(selfType); else - selfType = function->mapTypeIntoContext(selfType); + selfType = function->mapTypeIntoEnvironment(selfType); if (!conformsToDifferentiable(selfType)) { diags .diagnose(attrLoc, diag::diff_function_no_parameters, function) @@ -6765,7 +6765,7 @@ resolveDiffParamIndices(AbstractFunctionDecl *original, auto originalFnRemappedTy = original->getInterfaceType()->castTo(); if (derivativeGenEnv) originalFnRemappedTy = - derivativeGenEnv->mapTypeIntoContext(originalFnRemappedTy) + derivativeGenEnv->mapTypeIntoEnvironment(originalFnRemappedTy) ->castTo(); // Resolve and validate the differentiability parameters. @@ -6861,7 +6861,7 @@ typecheckDifferentiableAttrforDecl(AbstractFunctionDecl *original, auto originalFnRemappedTy = original->getInterfaceType()->castTo(); if (auto *derivativeGenEnv = derivativeGenSig.getGenericEnvironment()) originalFnRemappedTy = - derivativeGenEnv->mapTypeIntoContext(originalFnRemappedTy) + derivativeGenEnv->mapTypeIntoEnvironment(originalFnRemappedTy) ->castTo(); auto *resultIndices = @@ -7370,9 +7370,9 @@ static bool typeCheckDerivativeAttr(DerivativeAttr *attr) { Type expectedLinearMapType = expectedLinearMapTypeOrError.get(); if (expectedLinearMapType->hasTypeParameter()) expectedLinearMapType = - derivative->mapTypeIntoContext(expectedLinearMapType); + derivative->mapTypeIntoEnvironment(expectedLinearMapType); if (expectedLinearMapType->hasArchetype()) - expectedLinearMapType = expectedLinearMapType->mapTypeOutOfContext(); + expectedLinearMapType = expectedLinearMapType->mapTypeOutOfEnvironment(); // Compute the actual differential/pullback type for comparison with the // expected type. We must canonicalize the derivative interface type before @@ -7573,11 +7573,11 @@ static bool checkLinearityParameters( for (unsigned i : range(linearParams.size())) { auto linearParamType = linearParams[i].getPlainType(); if (!linearParamType->hasTypeParameter()) - linearParamType = linearParamType->mapTypeOutOfContext(); + linearParamType = linearParamType->mapTypeOutOfEnvironment(); if (derivativeGenEnv) - linearParamType = derivativeGenEnv->mapTypeIntoContext(linearParamType); + linearParamType = derivativeGenEnv->mapTypeIntoEnvironment(linearParamType); else - linearParamType = originalAFD->mapTypeIntoContext(linearParamType); + linearParamType = originalAFD->mapTypeIntoEnvironment(linearParamType); SourceLoc loc = parsedLinearParams.empty() ? attrLoc : parsedLinearParams[i].getLoc(); // Parameter must conform to `Differentiable` and satisfy @@ -7692,7 +7692,7 @@ void AttributeChecker::visitTransposeAttr(TransposeAttr *attr) { expectedOriginalResultType = expectedOriginalResultType->castTo()->getResult(); if (expectedOriginalResultType->hasTypeParameter()) - expectedOriginalResultType = transpose->mapTypeIntoContext( + expectedOriginalResultType = transpose->mapTypeIntoEnvironment( expectedOriginalResultType); if (!conformsToDifferentiable(expectedOriginalResultType, /*tangentVectorEqualsSelf*/ true)) { diff --git a/lib/Sema/TypeCheckBitwise.cpp b/lib/Sema/TypeCheckBitwise.cpp index 7d66c312cf24b..c127bb659a843 100644 --- a/lib/Sema/TypeCheckBitwise.cpp +++ b/lib/Sema/TypeCheckBitwise.cpp @@ -247,7 +247,7 @@ static bool checkBitwiseCopyableInstanceStorage(NominalTypeDecl *nominal, return true; } - if (dc->mapTypeIntoContext(nominal->getDeclaredInterfaceType()) + if (dc->mapTypeIntoEnvironment(nominal->getDeclaredInterfaceType()) ->isNoncopyable()) { // Already separately diagnosed when explicit. return true; diff --git a/lib/Sema/TypeCheckConcurrency.cpp b/lib/Sema/TypeCheckConcurrency.cpp index 27685d80a55c5..2f89d2d19daf2 100644 --- a/lib/Sema/TypeCheckConcurrency.cpp +++ b/lib/Sema/TypeCheckConcurrency.cpp @@ -1357,7 +1357,7 @@ inferSendableFromInstanceStorage(NominalTypeDecl *nominal, if (missing->getType()->is()) { requirements.push_back( Requirement(RequirementKind::Conformance, - missing->getType()->mapTypeOutOfContext(), + missing->getType()->mapTypeOutOfEnvironment(), sendableProto->getDeclaredType())); return false; } @@ -2078,7 +2078,7 @@ static ActorIsolation getInnermostIsolatedContext( case ActorIsolation::GlobalActor: return ActorIsolation::forGlobalActor( - dc->mapTypeIntoContext(isolation.getGlobalActor())) + dc->mapTypeIntoEnvironment(isolation.getGlobalActor())) .withPreconcurrency(isolation.preconcurrency()); } } @@ -3075,7 +3075,7 @@ namespace { continue; Type type = getDeclContext() - ->mapTypeIntoContext(decl->getInterfaceType()) + ->mapTypeIntoEnvironment(decl->getInterfaceType()) ->getReferenceStorageReferent(); if (type->hasError()) @@ -4416,7 +4416,7 @@ namespace { } case ActorIsolation::GlobalActor: { // Form a .shared reference. - Type globalActorType = getDeclContext()->mapTypeIntoContext( + Type globalActorType = getDeclContext()->mapTypeIntoEnvironment( isolation.getGlobalActor()); auto typeExpr = TypeExpr::createImplicit(globalActorType, ctx); actorExpr = new (ctx) UnresolvedDotExpr( @@ -5319,7 +5319,7 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true, } return ActorIsolation::forGlobalActor( - globalActorType->mapTypeOutOfContext()) + globalActorType->mapTypeOutOfEnvironment()) .withPreconcurrency(decl->preconcurrency() || isUnsafe); } @@ -5836,7 +5836,7 @@ getActorIsolationForMainFuncDecl(FuncDecl *fnDecl) { return isMainFunction && hasMainActor ? ActorIsolation::forGlobalActor( - ctx.getMainActorType()->mapTypeOutOfContext()) + ctx.getMainActorType()->mapTypeOutOfEnvironment()) : std::optional(); } @@ -6265,7 +6265,7 @@ computeDefaultInferredActorIsolation(ValueDecl *value) { // If we are required to use main actor... just use that. if (defaultIsolation == DefaultIsolation::MainActor) if (auto result = - globalActorHelper(ctx.getMainActorType()->mapTypeOutOfContext())) + globalActorHelper(ctx.getMainActorType()->mapTypeOutOfEnvironment())) return *result; } @@ -6390,7 +6390,7 @@ static InferredActorIsolation computeActorIsolation(Evaluator &evaluator, checkDeclWithIsolatedParameter(value); ParamDecl *param = value->getParameterList()->get(*paramIdx); - Type paramType = param->getDeclContext()->mapTypeIntoContext( + Type paramType = param->getDeclContext()->mapTypeIntoEnvironment( param->getInterfaceType()); Type actorType; if (auto wrapped = paramType->getOptionalObjectType()) { @@ -7634,11 +7634,11 @@ ProtocolConformance *swift::deriveImplicitSendableConformance( if (classDecl) { if (Type superclass = classDecl->getSuperclass()) { auto inheritedConformance = checkConformance( - classDecl->mapTypeIntoContext(superclass), + classDecl->mapTypeIntoEnvironment(superclass), proto, /*allowMissing=*/false); if (inheritedConformance) { inheritedConformance = inheritedConformance - .mapConformanceOutOfContext(); + .mapConformanceOutOfEnvironment(); if (inheritedConformance.isConcrete()) { return ctx.getInheritedConformance( nominal->getDeclaredInterfaceType(), @@ -8366,7 +8366,7 @@ ActorReferenceResult ActorReferenceResult::forReference( auto *init = dyn_cast(fromDC); if (init && init->isDesignatedInit() && isStoredProperty(decl) && (!actorInstance || actorInstance->isSelf())) { - auto type = fromDC->mapTypeIntoContext(decl->getInterfaceType()); + auto type = fromDC->mapTypeIntoEnvironment(decl->getInterfaceType()); if (!type->isSendableType()) { // Treat the decl isolation as 'preconcurrency' to downgrade violations // to warnings, because violating Sendable here is accepted by the diff --git a/lib/Sema/TypeCheckConstraints.cpp b/lib/Sema/TypeCheckConstraints.cpp index 6f7d1d711bf88..06d7147259494 100644 --- a/lib/Sema/TypeCheckConstraints.cpp +++ b/lib/Sema/TypeCheckConstraints.cpp @@ -535,7 +535,7 @@ Type TypeChecker::typeCheckParameterDefault(Expr *&defaultValue, isAutoClosure ? CTP_AutoclosureDefaultParameter : CTP_DefaultParameter, paramType, /*isDiscarded=*/false); - auto paramInterfaceTy = paramType->mapTypeOutOfContext(); + auto paramInterfaceTy = paramType->mapTypeOutOfEnvironment(); // Attempt to pre-check expression first, if that fails - skip type-checking. // This would make sure that diagnostics about invalid AST are never dropped. @@ -949,7 +949,7 @@ bool TypeChecker::typeCheckExprPattern(ExprPattern *EP, DeclContext *DC, "typecheck-expr-pattern", EP); PrettyStackTracePattern stackTrace(Context, "type-checking", EP); - EP->getMatchVar()->setInterfaceType(rhsType->mapTypeOutOfContext()); + EP->getMatchVar()->setInterfaceType(rhsType->mapTypeOutOfEnvironment()); // Check the expression as a condition. auto target = SyntacticElementTarget::forExprPattern(EP); @@ -975,7 +975,7 @@ static Type openTypeParameter(ConstraintSystem &cs, } auto *paramTy = interfaceTy->castTo(); - auto archetypeTy = env->mapTypeIntoContext(paramTy)->castTo(); + auto archetypeTy = env->mapTypeIntoEnvironment(paramTy)->castTo(); auto found = types.find(archetypeTy); if (found != types.end()) diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp index 1ce640845e5f6..989eef8c270b5 100644 --- a/lib/Sema/TypeCheckDecl.cpp +++ b/lib/Sema/TypeCheckDecl.cpp @@ -1171,7 +1171,7 @@ swift::computeAutomaticEnumValueKind(EnumDecl *ED) { assert(rawTy && "Cannot compute value kind without raw type!"); if (ED->getGenericEnvironmentOfContext() != nullptr) - rawTy = ED->mapTypeIntoContext(rawTy); + rawTy = ED->mapTypeIntoEnvironment(rawTy); // Swift enums require that the raw type is convertible from one of the // primitive literal protocols. @@ -1218,7 +1218,7 @@ EnumRawValuesRequest::evaluate(Evaluator &eval, EnumDecl *ED, } if (ED->getGenericEnvironmentOfContext() != nullptr) - rawTy = ED->mapTypeIntoContext(rawTy); + rawTy = ED->mapTypeIntoEnvironment(rawTy); if (rawTy->hasError()) return std::make_tuple<>(); @@ -2480,7 +2480,7 @@ InterfaceTypeRequest::evaluate(Evaluator &eval, ValueDecl *D) const { Type interfaceType = namingPattern->getType(); if (interfaceType->hasArchetype()) - interfaceType = interfaceType->mapTypeOutOfContext(); + interfaceType = interfaceType->mapTypeOutOfEnvironment(); // In SIL mode, VarDecls are written as having reference storage types. if (!interfaceType->is()) { @@ -2516,7 +2516,7 @@ InterfaceTypeRequest::evaluate(Evaluator &eval, ValueDecl *D) const { thrownTy = AFD->getThrownInterfaceType(); ProtocolDecl *errorProto = Context.getErrorDecl(); if (thrownTy && !thrownTy->hasError() && errorProto) { - Type thrownTyInContext = AFD->mapTypeIntoContext(thrownTy); + Type thrownTyInContext = AFD->mapTypeIntoEnvironment(thrownTy); if (!checkConformance(thrownTyInContext, errorProto)) { SourceLoc loc; if (auto thrownTypeRepr = AFD->getThrownTypeRepr()) diff --git a/lib/Sema/TypeCheckDeclObjC.cpp b/lib/Sema/TypeCheckDeclObjC.cpp index 605b5e49efa1d..940f44c736d5b 100644 --- a/lib/Sema/TypeCheckDeclObjC.cpp +++ b/lib/Sema/TypeCheckDeclObjC.cpp @@ -820,7 +820,7 @@ bool swift::isRepresentableInLanguage( } if (auto FD = dyn_cast(AFD)) { - Type ResultType = FD->mapTypeIntoContext(FD->getResultInterfaceType()); + Type ResultType = FD->mapTypeIntoEnvironment(FD->getResultInterfaceType()); if (!FD->hasAsync() && !ResultType->hasError() && !ResultType->isVoid() && @@ -919,7 +919,7 @@ bool swift::isRepresentableInLanguage( // Translate the result type of the function into parameters for the // completion handler parameter, exploding one level of tuple if needed. - Type resultType = FD->mapTypeIntoContext(FD->getResultInterfaceType()); + Type resultType = FD->mapTypeIntoEnvironment(FD->getResultInterfaceType()); if (auto tupleType = resultType->getAs()) { for (const auto &tupleElt : tupleType->getElements()) { if (addCompletionHandlerParam(tupleElt.getType())) @@ -1169,7 +1169,7 @@ bool swift::isRepresentableInObjC(const VarDecl *VD, ObjCReason Reason) { if (!abiRole.providesAPI() && abiRole.getCounterpart()) return isRepresentableInObjC(abiRole.getCounterpart(), Reason); - Type T = VD->getDeclContext()->mapTypeIntoContext(VD->getInterfaceType()); + Type T = VD->getDeclContext()->mapTypeIntoEnvironment(VD->getInterfaceType()); if (auto *RST = T->getAs()) { // In-memory layout of @weak and @unowned does not correspond to anything // in Objective-C, but this does not really matter here, since Objective-C diff --git a/lib/Sema/TypeCheckDeclOverride.cpp b/lib/Sema/TypeCheckDeclOverride.cpp index 146590fc2449e..51dc6ab463851 100644 --- a/lib/Sema/TypeCheckDeclOverride.cpp +++ b/lib/Sema/TypeCheckDeclOverride.cpp @@ -2086,11 +2086,11 @@ static bool checkSingleOverride(ValueDecl *override, ValueDecl *base) { if (baseThrownError && baseThrownError->hasTypeParameter()) { auto subs = SubstitutionMap::getOverrideSubstitutions(base, override); baseThrownError = baseThrownError.subst(subs); - baseThrownError = overrideFn->mapTypeIntoContext(baseThrownError); + baseThrownError = overrideFn->mapTypeIntoEnvironment(baseThrownError); } if (overrideThrownError) - overrideThrownError = overrideFn->mapTypeIntoContext(overrideThrownError); + overrideThrownError = overrideFn->mapTypeIntoEnvironment(overrideThrownError); // Check for a subtyping relationship. switch (compareThrownErrorsForSubtyping( diff --git a/lib/Sema/TypeCheckDeclPrimary.cpp b/lib/Sema/TypeCheckDeclPrimary.cpp index df444e9ded490..80ea6d5b1f8ab 100644 --- a/lib/Sema/TypeCheckDeclPrimary.cpp +++ b/lib/Sema/TypeCheckDeclPrimary.cpp @@ -1967,7 +1967,7 @@ static void diagnoseWrittenPlaceholderTypes(ASTContext &Ctx, diag::placeholder_type_not_allowed_in_pattern) .highlight(P->getSourceRange()); if (init && !init->getType()->hasError()) { - auto initTy = init->getType()->mapTypeOutOfContext(); + auto initTy = init->getType()->mapTypeOutOfEnvironment(); Ctx.Diags .diagnose(PTR->getLoc(), diag::replace_placeholder_with_inferred_type, initTy) @@ -2830,7 +2830,7 @@ class DeclChecker : public DeclVisitor { // Reject noncopyable typed subscripts with read/set accessors since we // cannot define modify operations upon them without copying the read. - if (SD->mapTypeIntoContext(SD->getElementInterfaceType())->isNoncopyable()) { + if (SD->mapTypeIntoEnvironment(SD->getElementInterfaceType())->isNoncopyable()) { if (auto *read = SD->getAccessor(AccessorKind::Read)) { if (!read->isImplicit()) { if (auto *set = SD->getAccessor(AccessorKind::Set)) { diff --git a/lib/Sema/TypeCheckDistributed.cpp b/lib/Sema/TypeCheckDistributed.cpp index cae44908d1b78..db3b3b93b3dca 100644 --- a/lib/Sema/TypeCheckDistributed.cpp +++ b/lib/Sema/TypeCheckDistributed.cpp @@ -415,12 +415,12 @@ static bool checkDistributedTargetResultType( Type resultType; if (auto func = dyn_cast(valueDecl)) { - resultType = func->mapTypeIntoContext(func->getResultInterfaceType()); + resultType = func->mapTypeIntoEnvironment(func->getResultInterfaceType()); } else if (auto var = dyn_cast(valueDecl)) { // Distributed computed properties are always getters, // so get the get accessor for mapping the type into context: auto getter = var->getAccessor(swift::AccessorKind::Get); - resultType = getter->mapTypeIntoContext(var->getInterfaceType()); + resultType = getter->mapTypeIntoEnvironment(var->getInterfaceType()); } else { llvm_unreachable("Unsupported distributed target"); } @@ -551,7 +551,7 @@ bool CheckDistributedFunctionRequest::evaluate( C, serializationReqType); // --- Check parameters for 'SerializationRequirement' conformance - auto paramTy = func->mapTypeIntoContext(param->getInterfaceType()); + auto paramTy = func->mapTypeIntoEnvironment(param->getInterfaceType()); auto srl = serializationReqType->getExistentialLayout(); for (auto req: srl.getProtocols()) { diff --git a/lib/Sema/TypeCheckEffects.cpp b/lib/Sema/TypeCheckEffects.cpp index 1cf491b90686f..a95c108565411 100644 --- a/lib/Sema/TypeCheckEffects.cpp +++ b/lib/Sema/TypeCheckEffects.cpp @@ -397,7 +397,7 @@ class AbstractFunction { case Kind::Parameter: auto *param = getParameter(); auto *dc = param->getDeclContext(); - return dc->mapTypeIntoContext(param->getInterfaceType()) + return dc->mapTypeIntoEnvironment(param->getInterfaceType()) ->lookThroughAllOptionalTypes(); } llvm_unreachable("bad kind"); diff --git a/lib/Sema/TypeCheckInvertible.cpp b/lib/Sema/TypeCheckInvertible.cpp index ec931dc286ad1..17f1aa46748a4 100644 --- a/lib/Sema/TypeCheckInvertible.cpp +++ b/lib/Sema/TypeCheckInvertible.cpp @@ -310,7 +310,7 @@ bool StorageVisitor::visit(NominalTypeDecl *nominal, DeclContext *dc) { // Walk the stored properties of classes and structs. if (isa(nominal) || isa(nominal)) { for (auto property : nominal->getStoredProperties()) { - auto propertyType = dc->mapTypeIntoContext( + auto propertyType = dc->mapTypeIntoEnvironment( property->getValueInterfaceType()); if ((*this)(property, propertyType)) return true; @@ -347,7 +347,7 @@ bool StorageVisitor::visit(NominalTypeDecl *nominal, DeclContext *dc) { continue; // Check that the associated value type is Sendable. - auto elementType = dc->mapTypeIntoContext( + auto elementType = dc->mapTypeIntoEnvironment( element->getPayloadInterfaceType()); if ((*this)(element, elementType)) return true; diff --git a/lib/Sema/TypeCheckMacros.cpp b/lib/Sema/TypeCheckMacros.cpp index 16a91928898b5..1973c3f1d0961 100644 --- a/lib/Sema/TypeCheckMacros.cpp +++ b/lib/Sema/TypeCheckMacros.cpp @@ -188,7 +188,7 @@ MacroDefinition MacroDefinitionRequest::evaluate( } // Type-check the macro expansion. - Type resultType = macro->mapTypeIntoContext(macro->getResultInterfaceType()); + Type resultType = macro->mapTypeIntoEnvironment(macro->getResultInterfaceType()); constraints::ContextualTypeInfo contextualType { TypeLoc::withoutLoc(resultType), diff --git a/lib/Sema/TypeCheckNameLookup.cpp b/lib/Sema/TypeCheckNameLookup.cpp index b9a2c93db6b0e..cc2897e47fb8d 100644 --- a/lib/Sema/TypeCheckNameLookup.cpp +++ b/lib/Sema/TypeCheckNameLookup.cpp @@ -317,7 +317,7 @@ LookupResult TypeChecker::lookupUnqualified(DeclContext *dc, DeclNameRef name, } assert(typeDC->isTypeContext()); } - foundInType = dc->mapTypeIntoContext( + foundInType = dc->mapTypeIntoEnvironment( typeDC->getDeclaredInterfaceType()); assert(foundInType && "bogus base declaration?"); } diff --git a/lib/Sema/TypeCheckPattern.cpp b/lib/Sema/TypeCheckPattern.cpp index c13bd31ac8f73..b62968ee0944b 100644 --- a/lib/Sema/TypeCheckPattern.cpp +++ b/lib/Sema/TypeCheckPattern.cpp @@ -714,7 +714,7 @@ validateTypedPattern(TypedPattern *TP, DeclContext *dc, return ErrorType::get(Context); } - return named->getDecl()->getDeclContext()->mapTypeIntoContext(opaqueTy); + return named->getDecl()->getDeclContext()->mapTypeIntoEnvironment(opaqueTy); } const auto ty = TypeResolution::resolveContextualType( @@ -1743,6 +1743,6 @@ void TypeChecker::coerceParameterListToType(ParameterList *P, param->setSpecifier(ParamDecl::Specifier::InOut); param->setInterfaceType( - params[i].getParameterType()->mapTypeOutOfContext()); + params[i].getParameterType()->mapTypeOutOfEnvironment()); } } diff --git a/lib/Sema/TypeCheckProtocol.cpp b/lib/Sema/TypeCheckProtocol.cpp index dd780cfff24ef..ff50a3e111d41 100644 --- a/lib/Sema/TypeCheckProtocol.cpp +++ b/lib/Sema/TypeCheckProtocol.cpp @@ -1008,7 +1008,7 @@ findMissingGenericRequirementForSolutionFix( auto selfTy = conformance->getProtocol()->getSelfInterfaceType() .subst(reqEnvironment.getRequirementToWitnessThunkSubs()) - ->mapTypeOutOfContext(); + ->mapTypeOutOfEnvironment(); auto sig = conformance->getGenericSignature(); auto *env = conformance->getGenericEnvironment(); @@ -1016,7 +1016,7 @@ findMissingGenericRequirementForSolutionFix( auto &ctx = conformance->getDeclContext()->getASTContext(); if (type->is() && - type->mapTypeOutOfContext()->isEqual(selfTy) && + type->mapTypeOutOfEnvironment()->isEqual(selfTy) && missingType->isEqual(conformance->getType())) { // e.g. `extension P where Self == C { func foo() { ... } }` // and `C` doesn't actually conform to `P`. @@ -1045,7 +1045,7 @@ findMissingGenericRequirementForSolutionFix( if (ordinal == params.size()) return ErrorType::get(ctx); - return env->mapTypeIntoContext(gp); + return env->mapTypeIntoEnvironment(gp); }, LookUpConformanceInModule(), SubstFlags::PreservePackExpansionLevel); @@ -5324,7 +5324,7 @@ static void ensureRequirementsAreSatisfied(ASTContext &ctx, auto typeInContext = conformance->getType(); ProtocolConformanceRef conformanceInContext(conformance); if (auto *genericEnv = conformance->getGenericEnvironment()) { - typeInContext = genericEnv->mapTypeIntoContext(typeInContext); + typeInContext = genericEnv->mapTypeIntoEnvironment(typeInContext); conformanceInContext = conformanceInContext.subst(genericEnv->getForwardingSubstitutionMap()); } @@ -5463,7 +5463,7 @@ static void ensureRequirementsAreSatisfied(ASTContext &ctx, auto assocConf = conformance->getAssociatedConformance(depTy, proto); if (assocConf.isConcrete()) { auto *concrete = assocConf.getConcrete(); - auto replacementTy = dc->mapTypeIntoContext(concrete->getType()); + auto replacementTy = dc->mapTypeIntoEnvironment(concrete->getType()); // If this requirement has a dependent member type, only require the // associated conformance to be as available as the requirement's @@ -5530,7 +5530,7 @@ hasInvalidTypeInConformanceContext(const ValueDecl *requirement, conformance->getProtocol()); // FIXME: getInterfaceType() on properties returns contextual types that have - // been mapped out of context, but mapTypeOutOfContext() does not reconstitute + // been mapped out of context, but mapTypeOutOfEnvironment() does not reconstitute // type parameters that were substituted with concrete types. Instead, // patterns should be refactored to use interface types, at least if they // appear in type contexts. @@ -5873,7 +5873,7 @@ void swift::diagnoseConformanceFailure(Type T, // Equatable, say so. // // Map it into context since we want to check conditional requirements. - rawType = enumDecl->mapTypeIntoContext(rawType); + rawType = enumDecl->mapTypeIntoEnvironment(rawType); if (!TypeChecker::conformsToKnownProtocol( rawType, KnownProtocolKind::Equatable)) { SourceLoc loc = enumDecl->getInherited().getStartLoc(); @@ -7345,7 +7345,7 @@ void TypeChecker::inferDefaultWitnesses(ProtocolDecl *proto) { auto match = RequirementMatch(asd, MatchKind::ExactMatch, asdTy, reqEnv); match.WitnessSubstitutions = reqEnv.getRequirementToWitnessThunkSubs() - .mapReplacementTypesOutOfContext(); + .mapReplacementTypesOutOfEnvironment(); checker.recordWitness(asd, match); } } @@ -7407,7 +7407,7 @@ void TypeChecker::inferDefaultWitnesses(ProtocolDecl *proto) { continue; Type defaultAssocTypeInContext = - proto->mapTypeIntoContext(defaultAssocType); + proto->mapTypeIntoEnvironment(defaultAssocType); auto requirementProto = req.getProtocolDecl(); auto conformance = checkConformance(defaultAssocTypeInContext, requirementProto); diff --git a/lib/Sema/TypeCheckRequestFunctions.cpp b/lib/Sema/TypeCheckRequestFunctions.cpp index 199ae697e79d3..4effb4bc8b2b5 100644 --- a/lib/Sema/TypeCheckRequestFunctions.cpp +++ b/lib/Sema/TypeCheckRequestFunctions.cpp @@ -479,7 +479,7 @@ Type ResultBuilderTypeRequest::evaluate(Evaluator &evaluator, } } - return type->mapTypeOutOfContext(); + return type->mapTypeOutOfEnvironment(); } Type GenericTypeParamDeclGetValueTypeRequest::evaluate( diff --git a/lib/Sema/TypeCheckStmt.cpp b/lib/Sema/TypeCheckStmt.cpp index c9a03f2f22937..ddea97a1087c6 100644 --- a/lib/Sema/TypeCheckStmt.cpp +++ b/lib/Sema/TypeCheckStmt.cpp @@ -1310,7 +1310,7 @@ class StmtChecker : public StmtVisitor { if (!diagnosed) { auto *nominalDecl = fn->getDeclContext()->getSelfNominalTypeDecl(); Type nominalType = - fn->mapTypeIntoContext(nominalDecl->getDeclaredInterfaceType()); + fn->mapTypeIntoEnvironment(nominalDecl->getDeclaredInterfaceType()); // must be noncopyable if (nominalType->isCopyable()) { diff --git a/lib/Sema/TypeCheckStorage.cpp b/lib/Sema/TypeCheckStorage.cpp index cbe8911700c83..48a90c449a717 100644 --- a/lib/Sema/TypeCheckStorage.cpp +++ b/lib/Sema/TypeCheckStorage.cpp @@ -421,7 +421,7 @@ getLazilySynthesizedPattern(PatternBindingDecl *PBD, Pattern *P) { auto *DC = var->getDeclContext(); auto &ctx = DC->getASTContext(); - auto patternTy = DC->mapTypeIntoContext(interfaceTy); + auto patternTy = DC->mapTypeIntoEnvironment(interfaceTy); return TypedPattern::createImplicit(ctx, P, patternTy); } @@ -925,7 +925,7 @@ OpaqueReadOwnershipRequest::evaluate(Evaluator &evaluator, if (storage->getAttrs().hasAttribute()) return usesBorrowed(DiagKind::BorrowedAttr); - if (storage->getInnermostDeclContext()->mapTypeIntoContext( + if (storage->getInnermostDeclContext()->mapTypeIntoEnvironment( storage->getValueInterfaceType())->isNoncopyable()) return usesBorrowed(DiagKind::NoncopyableType); @@ -3460,7 +3460,7 @@ PropertyWrapperInitializerInfoRequest::evaluate(Evaluator &evaluator, if (!wrapperType || wrapperType->hasError()) return PropertyWrapperInitializerInfo(); - Type storageType = dc->mapTypeIntoContext(wrapperType); + Type storageType = dc->mapTypeIntoEnvironment(wrapperType); Expr *initializer = nullptr; PropertyWrapperValuePlaceholderExpr *wrappedValue = nullptr; diff --git a/lib/Sema/TypeCheckType.cpp b/lib/Sema/TypeCheckType.cpp index 6cd9afaf64d6c..df987877e12c9 100644 --- a/lib/Sema/TypeCheckType.cpp +++ b/lib/Sema/TypeCheckType.cpp @@ -684,7 +684,7 @@ bool TypeChecker::checkContextualRequirements(GenericTypeDecl *decl, if (contextSig) { // Avoid building this generic environment unless we need it. auto *genericEnv = contextSig.getGenericEnvironment(); - return genericEnv->mapTypeIntoContext(result); + return genericEnv->mapTypeIntoEnvironment(result); } } return result; @@ -1298,7 +1298,7 @@ Type TypeResolution::applyUnboundGenericArguments( if (result->hasTypeParameter()) { if (const auto contextSig = getGenericSignature()) { auto *genericEnv = contextSig.getGenericEnvironment(); - // FIXME: This should just use mapTypeIntoContext(), but we can't yet + // FIXME: This should just use mapTypeIntoEnvironment(), but we can't yet // because we sometimes have type parameters here that are invalid for // our generic signature. This can happen if the type parameter was // found via unqualified lookup, but the current context's @@ -2660,7 +2660,7 @@ Type TypeResolution::resolveContextualType( packElementOpener, requirementOpener); const auto ty = resolution.resolveType(TyR, silContext); - return GenericEnvironment::mapTypeIntoContext( + return GenericEnvironment::mapTypeIntoEnvironment( resolution.getGenericSignature().getGenericEnvironment(), ty); } @@ -2769,7 +2769,7 @@ bool swift::diagnoseMissingOwnership(ParamSpecifier ownership, // The parameter type is written with respect to the surrounding // generic environment. - ty = GenericEnvironment::mapTypeIntoContext( + ty = GenericEnvironment::mapTypeIntoEnvironment( resolution.getGenericSignature().getGenericEnvironment(), ty); @@ -3125,7 +3125,7 @@ TypeResolver::resolveOpenedExistentialArchetype( }, LookUpConformanceInModule()); - archetypeType = env->mapTypeIntoContext(interfaceType); + archetypeType = env->mapTypeIntoEnvironment(interfaceType); ASSERT(archetypeType->is()); } @@ -4468,7 +4468,7 @@ NeverNullType TypeResolver::resolveASTFunctionType( thrownTy = Type(); } else if (inStage(TypeResolutionStage::Interface) && !options.contains(TypeResolutionFlags::SilenceErrors)) { - auto thrownTyInContext = GenericEnvironment::mapTypeIntoContext( + auto thrownTyInContext = GenericEnvironment::mapTypeIntoEnvironment( resolution.getGenericSignature().getGenericEnvironment(), thrownTy); if (!checkConformance(thrownTyInContext, ctx.getErrorDecl())) { diagnoseInvalid( @@ -4851,7 +4851,7 @@ NeverNullType TypeResolver::resolveSILFunctionType(FunctionTypeRepr *repr, // Only once we've done all the necessary substitutions, map the type // into the function's environment. - selfType = GenericEnvironment::mapTypeIntoContext( + selfType = GenericEnvironment::mapTypeIntoEnvironment( genericSig.getGenericEnvironment(), selfType); // The Self type can be nested in a few layers of metatypes (etc.). @@ -5419,7 +5419,7 @@ TypeResolver::resolveIsolatedTypeRepr(IsolatedTypeRepr *repr, if (inStage(TypeResolutionStage::Interface) && !options.is(TypeResolverContext::Inherited)) { if (auto *env = resolution.getGenericSignature().getGenericEnvironment()) - unwrappedType = env->mapTypeIntoContext(unwrappedType); + unwrappedType = env->mapTypeIntoEnvironment(unwrappedType); if (!unwrappedType->isAnyActorType() && !unwrappedType->hasError()) { diagnoseInvalid( @@ -5851,7 +5851,7 @@ NeverNullType TypeResolver::resolveVarargType(VarargTypeRepr *repr, // do not allow move-only types as the element of a vararg // FIXME: This does not correctly handle type variables and unbound generics. if (inStage(TypeResolutionStage::Interface)) { - auto contextTy = GenericEnvironment::mapTypeIntoContext( + auto contextTy = GenericEnvironment::mapTypeIntoEnvironment( resolution.getGenericSignature().getGenericEnvironment(), element); if (!contextTy->hasError() && contextTy->isNoncopyable()) { diagnoseInvalid(repr, repr->getLoc(), diag::noncopyable_generics_variadic, @@ -6000,7 +6000,7 @@ NeverNullType TypeResolver::resolvePackElement(PackElementTypeRepr *repr, // Open the pack reference to an element archetype if requested. if (auto openPackElement = resolution.getPackElementOpener()) { auto *env = resolution.getGenericSignature().getGenericEnvironment(); - return openPackElement(env->mapTypeIntoContext(packReference), repr); + return openPackElement(env->mapTypeIntoEnvironment(packReference), repr); } return packReference; @@ -6044,7 +6044,7 @@ NeverNullType TypeResolver::resolveTupleType(TupleTypeRepr *repr, !ty->hasUnboundGenericType() && !ty->hasTypeVariable() && !isa(tyR)) { - auto contextTy = GenericEnvironment::mapTypeIntoContext( + auto contextTy = GenericEnvironment::mapTypeIntoEnvironment( resolution.getGenericSignature().getGenericEnvironment(), ty); if (!contextTy->hasError() && contextTy->isNoncopyable()) moveOnlyElementIndex = i; diff --git a/lib/Sema/TypeCheckUnsafe.cpp b/lib/Sema/TypeCheckUnsafe.cpp index 774df349cf3ec..8a9c162c2ede7 100644 --- a/lib/Sema/TypeCheckUnsafe.cpp +++ b/lib/Sema/TypeCheckUnsafe.cpp @@ -507,7 +507,7 @@ void swift::checkUnsafeStorage(NominalTypeDecl *nominal) { ASTContext &ctx = nominal->getASTContext(); if (auto classDecl = dyn_cast(nominal)) { if (Type superclassType = classDecl->getSuperclass()) { - superclassType = classDecl->mapTypeIntoContext(superclassType); + superclassType = classDecl->mapTypeIntoEnvironment(superclassType); bool diagnosed = false; diagnoseUnsafeType(ctx, classDecl->getLoc(), superclassType, [&](Type type) { if (diagnosed) diff --git a/lib/Sema/TypeChecker.cpp b/lib/Sema/TypeChecker.cpp index bb49ccc5d914d..cc567c0cbb377 100644 --- a/lib/Sema/TypeChecker.cpp +++ b/lib/Sema/TypeChecker.cpp @@ -614,7 +614,7 @@ bool TypeChecker::isDifferentiable(Type type, bool tangentVectorEqualsSelf, DeclContext *dc, std::optional stage) { if (stage) - type = dc->mapTypeIntoContext(type); + type = dc->mapTypeIntoEnvironment(type); auto tanSpace = type->getAutoDiffTangentSpace( LookUpConformanceInModule()); if (!tanSpace) diff --git a/lib/Sema/TypeOfReference.cpp b/lib/Sema/TypeOfReference.cpp index 88b9a3544b4da..ade219eaffa12 100644 --- a/lib/Sema/TypeOfReference.cpp +++ b/lib/Sema/TypeOfReference.cpp @@ -67,7 +67,7 @@ Type ConstraintSystem::openUnboundGenericType(GenericTypeDecl *decl, isTypeResolution // Type resolution produces interface types, so we have to map // the parent type into context before binding type variables. - ? DC->mapTypeIntoContext(parentTy) + ? DC->mapTypeIntoEnvironment(parentTy) : parentTy; const auto subs = @@ -115,7 +115,7 @@ Type ConstraintSystem::openUnboundGenericType(GenericTypeDecl *decl, [](auto, auto) { /*will be called, but we already handled reqs*/ }) .applyUnboundGenericArguments(decl, parentTy, SourceLoc(), arguments); if (!parentTy && !isTypeResolution) { - result = DC->mapTypeIntoContext(result); + result = DC->mapTypeIntoEnvironment(result); } return result; @@ -787,8 +787,8 @@ Type ConstraintSystem::getUnopenedTypeOfReference( if (!wantInterfaceType && requestedType->hasArchetype()) { auto valueDC = value->getDeclContext(); if (valueDC != UseDC) { - Type mapped = requestedType->mapTypeOutOfContext(); - requestedType = UseDC->mapTypeIntoContext(mapped); + Type mapped = requestedType->mapTypeOutOfEnvironment(); + requestedType = UseDC->mapTypeIntoEnvironment(mapped); } } @@ -1168,7 +1168,7 @@ ConstraintSystem::getTypeOfReferencePre(OverloadChoice choice, /*packElementOpener*/ nullptr) .resolveTypeInContext(typeDecl, /*foundDC*/ nullptr, /*isSpecialized=*/false); - type = useDC->mapTypeIntoContext(type); + type = useDC->mapTypeIntoEnvironment(type); checkNestedTypeConstraints(*this, type, locator, preparedOverload); @@ -1401,7 +1401,7 @@ static void bindArchetypesFromContext( auto genericSig = parentDC->getGenericSignatureOfContext(); for (auto *paramTy : genericSig.getGenericParams()) { - Type contextTy = cs.DC->mapTypeIntoContext(paramTy); + Type contextTy = cs.DC->mapTypeIntoEnvironment(paramTy); if (paramTy->isParameterPack()) contextTy = PackType::getSingletonPackExpansion(contextTy); bindPrimaryArchetype(paramTy, contextTy); @@ -1688,7 +1688,7 @@ Type constraints::getDynamicSelfReplacementType( const auto *selfDecl = SuperExpr->getSelf(); return selfDecl->getDeclContext() ->getInnermostTypeContext() - ->mapTypeIntoContext(selfDecl->getInterfaceType()) + ->mapTypeIntoEnvironment(selfDecl->getInterfaceType()) ->getMetatypeInstanceType(); } diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index 7e2629211f0ce..c92bbead37038 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -7649,7 +7649,7 @@ Expected DESERIALIZE_TYPE(PRIMARY_ARCHETYPE_TYPE)( return interfaceTypeOrError.takeError(); Type contextType = - sigOrError.get().getGenericEnvironment()->mapTypeIntoContext( + sigOrError.get().getGenericEnvironment()->mapTypeIntoEnvironment( interfaceTypeOrError.get()); if (contextType->hasError()) @@ -7675,7 +7675,7 @@ Expected DESERIALIZE_TYPE(EXISTENTIAL_ARCHETYPE_TYPE)( if (!envOrError) return envOrError.takeError(); - return envOrError.get()->mapTypeIntoContext(interfaceTypeOrError.get()); + return envOrError.get()->mapTypeIntoEnvironment(interfaceTypeOrError.get()); } Expected DESERIALIZE_TYPE(OPAQUE_ARCHETYPE_TYPE)( @@ -7717,7 +7717,7 @@ Expected DESERIALIZE_TYPE(PACK_ARCHETYPE_TYPE)( Type interfaceType = MF.getType(interfaceTypeID); Type contextType = - sig.getGenericEnvironment()->mapTypeIntoContext(interfaceType); + sig.getGenericEnvironment()->mapTypeIntoEnvironment(interfaceType); if (contextType->hasError()) return MF.diagnoseFatal(); @@ -7742,7 +7742,7 @@ Expected DESERIALIZE_TYPE(ELEMENT_ARCHETYPE_TYPE)( if (!envOrError) return envOrError.takeError(); - return envOrError.get()->mapTypeIntoContext(interfaceTypeOrError.get()); + return envOrError.get()->mapTypeIntoEnvironment(interfaceTypeOrError.get()); } Expected diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp index c7b48d53dc7ee..9c0d9eb8834fc 100644 --- a/lib/Serialization/Serialization.cpp +++ b/lib/Serialization/Serialization.cpp @@ -1957,7 +1957,7 @@ void Serializer::writeLocalNormalProtocolConformance( // in terms of interface types; hence the hasPrimaryArchetype() check is // necessary for correctness, not just as a fast path. if (subs.getRecursiveProperties().hasPrimaryArchetype()) - subs = subs.mapReplacementTypesOutOfContext(); + subs = subs.mapReplacementTypesOutOfEnvironment(); data.push_back(addSubstitutionMapRef(subs)); data.push_back(witness.getEnterIsolation().has_value() ? 1 : 0); @@ -3956,7 +3956,7 @@ class Serializer::DeclSerializer : public DeclVisitor { // If we have a contextual type, map out to an interface type. if (type->hasArchetype()) - type = type->mapTypeOutOfContext(); + type = type->mapTypeOutOfEnvironment(); return type; }; diff --git a/test/AutoDiff/compiler_crashers/issue-54722-apply-opened-opened-existential-argument.swift b/test/AutoDiff/compiler_crashers/issue-54722-apply-opened-opened-existential-argument.swift index a4df1ab92b0a0..5e195f0ed14b2 100644 --- a/test/AutoDiff/compiler_crashers/issue-54722-apply-opened-opened-existential-argument.swift +++ b/test/AutoDiff/compiler_crashers/issue-54722-apply-opened-opened-existential-argument.swift @@ -53,7 +53,7 @@ public func abs(_ x: T) -> T where T.Element: Numer // #9 0x000000000179a806 swift::SILFunctionType::get(swift::GenericSignature, swift::SILFunctionType::ExtInfo, swift::SILCoroutineKind, swift::ParameterConvention, llvm::ArrayRef, llvm::ArrayRef, llvm::ArrayRef, llvm::Optional, swift::SubstitutionMap, swift::SubstitutionMap, swift::ASTContext const&, swift::ProtocolConformanceRef) (build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x179a806) // #10 0x00000000010bf7e8 (anonymous namespace)::SILTypeSubstituter::substSILFunctionType(swift::CanTypeWrapper, bool) (build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x10bf7e8) // #11 0x00000000010be86c swift::SILType::subst(swift::Lowering::TypeConverter&, llvm::function_ref, llvm::function_ref, swift::CanGenericSignature, bool) const (build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x10be86c) -// #12 0x00000000010ae3fe swift::GenericEnvironment::mapTypeIntoContext(swift::SILModule&, swift::SILType) const (build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x10ae3fe) +// #12 0x00000000010ae3fe swift::GenericEnvironment::mapTypeIntoEnvironment(swift::SILModule&, swift::SILType) const (build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x10ae3fe) // #13 0x0000000000f1a1e1 swift::autodiff::LinearMapInfo::addLinearMapToStruct(swift::autodiff::ADContext&, swift::ApplyInst*) (build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0xf1a1e1) // #14 0x0000000000f17925 swift::autodiff::LinearMapInfo::generateDifferentiationDataStructures(swift::autodiff::ADContext&, swift::SILFunction*) (build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0xf17925) // #15 0x0000000000f2615f swift::autodiff::VJPEmitter::VJPEmitter(swift::autodiff::ADContext&, swift::SILFunction*, swift::SILDifferentiabilityWitness*, swift::SILFunction*, swift::autodiff::DifferentiationInvoker) (build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0xf2615f) diff --git a/test/decl/protocol/conforms/failure.swift b/test/decl/protocol/conforms/failure.swift index 4fe3ff14877f1..955c3aa0587ae 100644 --- a/test/decl/protocol/conforms/failure.swift +++ b/test/decl/protocol/conforms/failure.swift @@ -240,7 +240,7 @@ protocol P12 { // '(Self) -> Never' instead of '(Self) -> Self.A.Element', and the invalid // type parameter is never found (see 'hasInvalidTypeInConformanceContext'). // This happens because getInterfaceType() on properties returns contextual - // types that have been mapped out of context, but mapTypeOutOfContext() does + // types that have been mapped out of context, but mapTypeOutOfEnvironment() does // not reconstitute type parameters that were substituted with concrete types. // Instead, patterns should be refactored to use interface types, at least if // they appear in type contexts. diff --git a/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp b/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp index a3ef9b2944292..34caf4b5f44f0 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp @@ -2453,7 +2453,7 @@ static void resolveCursorFromUSR( if (DC->isTypeContext()) { auto ContainerType = DC->getSelfInterfaceType(); ContainerType = - D->getInnermostDeclContext()->mapTypeIntoContext(ContainerType); + D->getInnermostDeclContext()->mapTypeIntoEnvironment(ContainerType); } ResolvedValueRefCursorInfoPtr Info = new ResolvedValueRefCursorInfo( diff --git a/tools/swift-ide-test/swift-ide-test.cpp b/tools/swift-ide-test/swift-ide-test.cpp index 1361ec48e8ea4..d0db96f679be6 100644 --- a/tools/swift-ide-test/swift-ide-test.cpp +++ b/tools/swift-ide-test/swift-ide-test.cpp @@ -4108,7 +4108,7 @@ class TypeReconstructWalker : public SourceEntityWalker { if (T) { T = T->getRValueType(); - tryDemangleType(T->mapTypeOutOfContext(), + tryDemangleType(T->mapTypeOutOfEnvironment(), (NestedDCs.empty() ? D->getDeclContext() : NestedDCs.back()), @@ -4122,7 +4122,7 @@ class TypeReconstructWalker : public SourceEntityWalker { Mangle::ASTMangler Mangler(Ctx); auto sig = DC->getGenericSignatureOfContext(); std::string mangledName(Mangler.mangleTypeForDebugger(T, sig)); - Type ReconstructedType = DC->mapTypeIntoContext( + Type ReconstructedType = DC->mapTypeIntoEnvironment( Demangle::getTypeForMangling(Ctx, mangledName)); Stream << "type: "; if (ReconstructedType) { diff --git a/validation-test/IDE/crashers/CodeCompletionCallbacksImpl-typecheckParsedType-0ee20e.swift b/validation-test/IDE/crashers/CodeCompletionCallbacksImpl-typecheckParsedType-0ee20e.swift index becf9284e7715..8e6f069e2a00d 100644 --- a/validation-test/IDE/crashers/CodeCompletionCallbacksImpl-typecheckParsedType-0ee20e.swift +++ b/validation-test/IDE/crashers/CodeCompletionCallbacksImpl-typecheckParsedType-0ee20e.swift @@ -1,3 +1,3 @@ -// {"kind":"complete","original":"0057cadb","signature":"(anonymous namespace)::CodeCompletionCallbacksImpl::typecheckParsedType()","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"complete","original":"0057cadb","signature":"(anonymous namespace)::CodeCompletionCallbacksImpl::typecheckParsedType()","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s {class ahasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"complete","original":"029049d6","signature":"swift::ide::CompletionLookup::foundDecl(swift::ValueDecl*, swift::DeclVisibilityKind, swift::DynamicLookupInfo)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s struct c(swift::Stmt*&)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"complete","original":"44c76fac","signature":"bool (anonymous namespace)::StmtChecker::typeCheckStmt(swift::Stmt*&)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s protocol a where b == <#type#>[ { func c() -> Self { diff --git a/validation-test/IDE/crashers/TypePrinter-printParentType-2f8724.swift b/validation-test/IDE/crashers/TypePrinter-printParentType-2f8724.swift index 270444b0356f5..6ef733940d195 100644 --- a/validation-test/IDE/crashers/TypePrinter-printParentType-2f8724.swift +++ b/validation-test/IDE/crashers/TypePrinter-printParentType-2f8724.swift @@ -1,3 +1,3 @@ -// {"kind":"complete","original":"1615843d","signature":"(anonymous namespace)::TypePrinter::printParentType(swift::Type)","signatureAssert":"Assertion failed: (!hasTypeParameter() && \"already have an interface type\"), function mapTypeOutOfContext"} +// {"kind":"complete","original":"1615843d","signature":"(anonymous namespace)::TypePrinter::printParentType(swift::Type)","signatureAssert":"Assertion failed: (!hasTypeParameter() && \"already have an interface type\"), function mapTypeOutOfEnvironment"} // RUN: not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s class a> { class d let builder = d#^^# diff --git a/validation-test/IDE/crashers/TypeResolution-resolveContextualType-276e19.swift b/validation-test/IDE/crashers/TypeResolution-resolveContextualType-276e19.swift index 76c140c2faf9c..3fc78d9ebd7d6 100644 --- a/validation-test/IDE/crashers/TypeResolution-resolveContextualType-276e19.swift +++ b/validation-test/IDE/crashers/TypeResolution-resolveContextualType-276e19.swift @@ -1,4 +1,4 @@ -// {"kind":"complete","original":"14893775","signature":"swift::TypeResolution::resolveContextualType(swift::TypeRepr*, swift::DeclContext*, swift::GenericSignature, swift::TypeResolutionOptions, llvm::function_ref, llvm::function_ref, llvm::function_ref, llvm::function_ref)>, swift::SILTypeResolutionContext*)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"complete","original":"14893775","signature":"swift::TypeResolution::resolveContextualType(swift::TypeRepr*, swift::DeclContext*, swift::GenericSignature, swift::TypeResolutionOptions, llvm::function_ref, llvm::function_ref, llvm::function_ref, llvm::function_ref)>, swift::SILTypeResolutionContext*)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s @a( #^^#) func b() diff --git a/validation-test/IDE/crashers/TypeResolver-resolveTupleType-cdc75e.swift b/validation-test/IDE/crashers/TypeResolver-resolveTupleType-cdc75e.swift index b40c059dbb413..e5ed631eb5c97 100644 --- a/validation-test/IDE/crashers/TypeResolver-resolveTupleType-cdc75e.swift +++ b/validation-test/IDE/crashers/TypeResolver-resolveTupleType-cdc75e.swift @@ -1,4 +1,4 @@ -// {"kind":"complete","original":"a4349038","signature":"(anonymous namespace)::TypeResolver::resolveTupleType(swift::TupleTypeRepr*, swift::TypeResolutionOptions)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"complete","original":"a4349038","signature":"(anonymous namespace)::TypeResolver::resolveTupleType(swift::TupleTypeRepr*, swift::TypeResolutionOptions)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s func a -> () [ { var : (b) #^^# diff --git a/validation-test/IDE/crashers/TypeResolver-resolveVarargType-32fa0d.swift b/validation-test/IDE/crashers/TypeResolver-resolveVarargType-32fa0d.swift index cf8957d54f020..61f6d305f3120 100644 --- a/validation-test/IDE/crashers/TypeResolver-resolveVarargType-32fa0d.swift +++ b/validation-test/IDE/crashers/TypeResolver-resolveVarargType-32fa0d.swift @@ -1,4 +1,4 @@ -// {"kind":"complete","original":"95ab8e45","signature":"(anonymous namespace)::TypeResolver::resolveVarargType(swift::VarargTypeRepr*, swift::TypeResolutionOptions)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"complete","original":"95ab8e45","signature":"(anonymous namespace)::TypeResolver::resolveVarargType(swift::VarargTypeRepr*, swift::TypeResolutionOptions)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s struct ahasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"complete","original":"1bd67425","signature":"swift::diagnoseMissingOwnership(swift::ParamSpecifier, swift::TypeRepr*, swift::Type, swift::TypeResolution const&)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s @a(0#^^#-> b->func > )","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"complete","original":"3a52f860","signature":"resolveDeclRefExpr(swift::UnresolvedDeclRefExpr*, swift::DeclContext*, swift::optionset::OptionSet)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s extension Sequence where a == b [ { func c { map#^^# diff --git a/validation-test/compiler_crashers/ConstraintSystem-openGenericParameters-981bb1.swift b/validation-test/compiler_crashers/ConstraintSystem-openGenericParameters-981bb1.swift index 4571c1f1bf5f0..2a250a278d580 100644 --- a/validation-test/compiler_crashers/ConstraintSystem-openGenericParameters-981bb1.swift +++ b/validation-test/compiler_crashers/ConstraintSystem-openGenericParameters-981bb1.swift @@ -1,4 +1,4 @@ -// {"kind":"typecheck","original":"0639ef40","signature":"swift::constraints::ConstraintSystem::openGenericParameters(swift::DeclContext*, swift::GenericSignature, llvm::SmallVectorImpl>&, swift::constraints::ConstraintLocatorBuilder, swift::constraints::PreparedOverloadBuilder*)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"typecheck","original":"0639ef40","signature":"swift::constraints::ConstraintSystem::openGenericParameters(swift::DeclContext*, swift::GenericSignature, llvm::SmallVectorImpl>&, swift::constraints::ConstraintLocatorBuilder, swift::constraints::PreparedOverloadBuilder*)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-frontend -typecheck %s protocol a { struct b { diff --git a/validation-test/compiler_crashers/LifetimeDependenceChecker-diagnoseMissingResultDependencies-5ccf43.swift b/validation-test/compiler_crashers/LifetimeDependenceChecker-diagnoseMissingResultDependencies-5ccf43.swift index 966a8c18b54e3..c1757a7809e4d 100644 --- a/validation-test/compiler_crashers/LifetimeDependenceChecker-diagnoseMissingResultDependencies-5ccf43.swift +++ b/validation-test/compiler_crashers/LifetimeDependenceChecker-diagnoseMissingResultDependencies-5ccf43.swift @@ -1,3 +1,3 @@ -// {"kind":"typecheck","signature":"swift::LifetimeDependenceChecker::diagnoseMissingResultDependencies(swift::DiagID)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"typecheck","signature":"swift::LifetimeDependenceChecker::diagnoseMissingResultDependencies(swift::DiagID)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-frontend -typecheck %s @abi(func a->b) func a < b diff --git a/validation-test/compiler_crashers/MultiConformanceChecker-checkAllConformances-f795c2.swift b/validation-test/compiler_crashers/MultiConformanceChecker-checkAllConformances-f795c2.swift index eca245fb9e824..6298c7c4fb400 100644 --- a/validation-test/compiler_crashers/MultiConformanceChecker-checkAllConformances-f795c2.swift +++ b/validation-test/compiler_crashers/MultiConformanceChecker-checkAllConformances-f795c2.swift @@ -1,4 +1,4 @@ -// {"kind":"typecheck","original":"c950cc2e","signature":"(anonymous namespace)::MultiConformanceChecker::checkAllConformances()","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"typecheck","original":"c950cc2e","signature":"(anonymous namespace)::MultiConformanceChecker::checkAllConformances()","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-frontend -typecheck %s struct a)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoContext"} +// {"kind":"typecheck","original":"115aa383","signature":"swift::TypeChecker::lookupUnqualified(swift::DeclContext*, swift::DeclNameRef, swift::SourceLoc, swift::optionset::OptionSet)","signatureAssert":"Assertion failed: (!type->hasTypeParameter() && \"no generic environment provided for type with type parameters\"), function mapTypeIntoEnvironment"} // RUN: not --crash %target-swift-frontend -typecheck %s protocol a { struct b