Skip to content

Commit f35c90a

Browse files
authored
Merge pull request #76445 from slavapestov/maptypeintocontext
Overhaul mapTypeIntoContext()
2 parents 6fb66db + 4afdc9d commit f35c90a

16 files changed

+446
-335
lines changed

include/swift/AST/GenericEnvironment.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,14 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
157157
friend ArchetypeType;
158158
friend QueryInterfaceTypeSubstitutions;
159159

160-
Type getOrCreateArchetypeFromInterfaceType(Type depType);
161-
162-
/// Add a mapping of a generic parameter to a specific type (which may be
163-
/// an archetype)
164-
void addMapping(GenericParamKey key, Type contextType);
160+
/// Add a mapping of a type parameter to a contextual type, usually
161+
/// an archetype.
162+
void addMapping(CanType depType, Type contextType);
165163

166-
/// Retrieve the mapping for the given generic parameter, if present.
164+
/// Retrieve the mapping for the given type parameter, if present.
167165
///
168166
/// This is only useful when lazily populating a generic environment.
169-
std::optional<Type> getMappingIfPresent(GenericParamKey key) const;
167+
Type getMappingIfPresent(CanType depType) const;
170168

171169
public:
172170
GenericSignature getGenericSignature() const {
@@ -283,13 +281,12 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
283281
/// Map an interface type to a contextual type.
284282
Type mapTypeIntoContext(Type type) const;
285283

286-
/// Map an interface type to a contextual type.
287-
Type mapTypeIntoContext(Type type,
288-
LookupConformanceFn lookupConformance) const;
289-
290284
/// Map a generic parameter type to a contextual type.
291285
Type mapTypeIntoContext(GenericTypeParamType *type) const;
292286

287+
/// Map a type parameter type to a contextual type.
288+
Type getOrCreateArchetypeFromInterfaceType(Type depType);
289+
293290
/// Map an interface type containing parameter packs to a contextual
294291
/// type in the opened element generic context.
295292
Type mapPackTypeIntoElementContext(Type type) const;

include/swift/AST/GenericSignature.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ class GenericSignature {
170170
/// Stores a set of requirements on a type parameter. Used by
171171
/// GenericEnvironment for building archetypes.
172172
struct LocalRequirements {
173-
Type anchor;
174-
175-
Type concreteType;
176173
Type superclass;
177174

178175
RequiredProtocols protos;
@@ -407,6 +404,11 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
407404

408405
bool isReducedType(Type type) const;
409406

407+
/// Return the reduced version of the given type parameter under this generic
408+
/// signature. To reduce a type that more generally contains type parameters,
409+
/// use GenericSignature::getReducedType().
410+
CanType getReducedTypeParameter(CanType type) const;
411+
410412
/// Determine whether the given type parameter is defined under this generic
411413
/// signature.
412414
bool isValidTypeParameter(Type type) const;

include/swift/AST/Types.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6588,11 +6588,7 @@ class ArchetypeType : public SubstitutableType,
65886588
bool requiresClass() const;
65896589

65906590
/// Retrieve the superclass of this type, if such a requirement exists.
6591-
Type getSuperclass() const {
6592-
if (!Bits.ArchetypeType.HasSuperclass) return Type();
6593-
6594-
return *getSubclassTrailingObjects<Type>();
6595-
}
6591+
Type getSuperclass() const;
65966592

65976593
/// Retrieve the layout constraint of this type, if such a requirement exists.
65986594
LayoutConstraint getLayoutConstraint() const {

0 commit comments

Comments
 (0)