Commit Graph

6 Commits

Author SHA1 Message Date
Slava Pestov
0d167a435c AST: Move GenericSignatureBuilder.h from include/swift/AST/ to lib/AST/ 2021-10-30 00:35:59 -04:00
Slava Pestov
df3c87911c GSB: PotentialArchetypes now store their canonical type
Instead of recomputing it on every call to getDependentType(),
we can just store it in there instead of the GenericParamKey
or AssociatedTypeDecl.

We still need to 're-sugar' user-visible dependent types to
get the right generic parameter name; a new getSugaredDependentType()
utility method is called in the right places for that.
2021-02-05 17:23:31 -05:00
Slava Pestov
b76733b614 GSB: Simplify ResolvedType implementation
We don't need to store the EquivalenceClass anymore.
2020-07-16 23:31:34 -04:00
Slava Pestov
c0d981ad61 GSB: Simplify maybeResolveEquivalenceClass()
When passing in wantExactPotentialArchetype=false, we don't actually ever
call getDependentType() on the result. So the Type + EquivalenceClass form
of ResolvedType can be removed.
2020-07-16 23:31:34 -04:00
Slava Pestov
2a0c8d1090 GSB: Fix use-after-free error when vending ResolvedType
The maybeResolveEquivalenceClass() method can deallocate equivalence
classes, because it calls updateNestedTypeForConformance(), which
calls addSameTypeRequirement().

Therefore, the EquivalenceClass stored inside a ResolvedType could
become invalid across calls to maybeResolveEquivalenceClass().

This was a problem in one place in particular, when adding a new
same-type constraint between two type parameters.

Fix this by not caching the equivalence class of a PotentialArchetype
in the ResolvedType implementation. The only time an equivalence class
is now stored is when returning an unresolved type, which is acted
upon immediately.

Fixes <https://bugs.swift.org/browse/SR-12812>, <rdar://problem/63422600>.
2020-07-16 23:31:33 -04:00
Doug Gregor
fc7eb0d3b6 [AST] Pull GenericSignature::ResolvedType definition into a header.
We’re going to need to use this in GenericSignature.cpp. NFC
2018-12-17 09:22:10 -08:00