Respect resilience when specializing opaque type archetypes

This commit is contained in:
Arnold Schwaighofer
2019-04-24 10:03:57 -07:00
parent 881d9ad2bf
commit a793dfb451
11 changed files with 188 additions and 37 deletions

View File

@@ -111,8 +111,9 @@ public:
/// Replace opaque types in the conforming type with their underlying types,
/// and resolve opaque conformances to their underlying conformances.
ProtocolConformanceRef substOpaqueTypesWithUnderlyingTypes(Type origType) const;
ProtocolConformanceRef substOpaqueTypesWithUnderlyingTypes(
Type origType, ModuleDecl *modulePerformingSubstitution) const;
/// Given a dependent type (expressed in terms of this conformance's
/// protocol), follow it from the conforming type.
Type getAssociatedType(Type origType, Type dependentType,

View File

@@ -177,7 +177,8 @@ public:
/// Replace opaque types in the replacement types in the map with their
/// underlying types. Does not change keys.
SubstitutionMap substOpaqueTypesWithUnderlyingTypes() const;
SubstitutionMap substOpaqueTypesWithUnderlyingTypes(
ModuleDecl *modulePerformingSubstitution) const;
/// Create a substitution map for a protocol conformance.
static SubstitutionMap

View File

@@ -318,7 +318,8 @@ public:
/// Replace opaque types with their underlying types when visible at the given
/// resilience expansion.
Type substOpaqueTypesWithUnderlyingTypes() const;
Type substOpaqueTypesWithUnderlyingTypes(
ModuleDecl *modulePerformingSubstitution) const;
bool isPrivateStdlibType(bool treatNonBuiltinProtocolsAsPublic = true) const;

View File

@@ -4827,8 +4827,11 @@ END_CAN_TYPE_WRAPPER(OpaqueTypeArchetypeType, ArchetypeType)
/// to their underlying types.
class ReplaceOpaqueTypesWithUnderlyingTypes {
public:
ReplaceOpaqueTypesWithUnderlyingTypes() {}
ModuleDecl *modulePerformingSubstitution;
ReplaceOpaqueTypesWithUnderlyingTypes(
ModuleDecl *modulePerformingSubstitution)
: modulePerformingSubstitution(modulePerformingSubstitution) {}
/// TypeSubstitutionFn
Type operator()(SubstitutableType *maybeOpaqueType) const;