Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SwiftCompilerSources/Sources/AST/GenericSignature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions SwiftCompilerSources/Sources/SIL/Function.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion SwiftCompilerSources/Sources/SIL/Type.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/ASTBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions include/swift/AST/ASTBridgingImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()};
}

//===----------------------------------------------------------------------===//
Expand Down
4 changes: 2 additions & 2 deletions include/swift/AST/AnyFunctionRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class AnyFunctionRef {
Type getBodyResultType() const {
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
if (auto *FD = dyn_cast<FuncDecl>(AFD))
return FD->mapTypeIntoContext(FD->getResultInterfaceType());
return FD->mapTypeIntoEnvironment(FD->getResultInterfaceType());
return TupleType::getEmpty(AFD->getASTContext());
}
return cast<AbstractClosureExpr *>(TheFunction)->getResultType();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/DeclContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions include/swift/AST/GenericEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/ProtocolConformanceRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/SubstitutionMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/TypeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
14 changes: 7 additions & 7 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down
2 changes: 1 addition & 1 deletion include/swift/SIL/SILBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions include/swift/SIL/SILBridgingImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions include/swift/SIL/SILCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct SubstitutionMapWithLocalArchetypes {
auto *newEnv = found->second;

auto interfaceTy = local->getInterfaceType();
return newEnv->mapTypeIntoContext(interfaceTy);
return newEnv->mapTypeIntoEnvironment(interfaceTy);
}

if (SubsMap)
Expand All @@ -89,7 +89,7 @@ struct SubstitutionMapWithLocalArchetypes {
if (SubsMap) {
if (origType->is<PrimaryArchetypeType>() ||
origType->is<PackArchetypeType>()) {
origType = origType->mapTypeOutOfContext();
origType = origType->mapTypeOutOfEnvironment();
}

return SubsMap->lookupConformance(
Expand Down
4 changes: 2 additions & 2 deletions include/swift/SIL/SILFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions include/swift/SIL/SILType.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions include/swift/SIL/TypeSubstCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
});
}

SubsMap = SubsMap.mapReplacementTypesOutOfContext();
SubsMap = SubsMap.mapReplacementTypesOutOfEnvironment();
}

// One abstract function in the debug info can only have one set of variables
Expand All @@ -427,7 +427,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
!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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions include/swift/SILOptimizer/Differentiation/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/swift/SILOptimizer/Utils/Generics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
2 changes: 1 addition & 1 deletion include/swift/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5812,7 +5812,7 @@ CanExistentialArchetypeType ExistentialArchetypeType::get(CanType existential) {
existentialSig.Generalization, UUID::fromTime());

return cast<ExistentialArchetypeType>(
genericEnv->mapTypeIntoContext(existentialSig.SelfType)
genericEnv->mapTypeIntoEnvironment(existentialSig.SelfType)
->getCanonicalType());
}

Expand Down
4 changes: 2 additions & 2 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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())
Expand Down
Loading