@@ -71,15 +71,12 @@ enum class LiteralBindingKind : uint8_t {
7171// / along with information that can be used to construct related
7272// / bindings, e.g., the supertypes of a given type.
7373struct PotentialBinding {
74- friend class BindingSet ;
75-
7674 // / The type to which the type variable can be bound.
7775 Type BindingType;
7876
7977 // / The kind of bindings permitted.
8078 AllowedBindingKind Kind;
8179
82- protected:
8380 // / The source of the type information.
8481 // /
8582 // / Determines whether this binding represents a "hole" in
@@ -91,7 +88,6 @@ struct PotentialBinding {
9188 PointerUnion<Constraint *, ConstraintLocator *> source)
9289 : BindingType(type), Kind(kind), BindingSource(source) {}
9390
94- public:
9591 PotentialBinding (Type type, AllowedBindingKind kind, Constraint *source)
9692 : PotentialBinding(
9793 type, kind,
@@ -219,25 +215,11 @@ struct LiteralRequirement {
219215
220216struct PotentialBindings {
221217 // / The set of all constraints that have been added via infer().
222- llvm::SmallPtrSet <Constraint *, 2 > Constraints;
218+ llvm::SmallSetVector <Constraint *, 2 > Constraints;
223219
224220 // / The set of potential bindings.
225221 llvm::SmallVector<PotentialBinding, 4 > Bindings;
226222
227- // / The set of protocol requirements placed on this type variable.
228- llvm::SmallVector<Constraint *, 4 > Protocols;
229-
230- // / The set of unique literal protocol requirements placed on this
231- // / type variable or inferred transitively through subtype chains.
232- // /
233- // / Note that ordering is important when it comes to bindings, we'd
234- // / like to add any "direct" default types first to attempt them
235- // / before transitive ones.
236- llvm::SmallPtrSet<Constraint *, 2 > Literals;
237-
238- // / The set of constraints which would be used to infer default types.
239- llvm::SmallPtrSet<Constraint *, 2 > Defaults;
240-
241223 // / The set of constraints which delay attempting this type variable.
242224 llvm::TinyPtrVector<Constraint *> DelayedBy;
243225
@@ -247,22 +229,17 @@ struct PotentialBindings {
247229 // / bindings (contained in the binding type e.g. `Foo<$T0>`), or
248230 // / reachable through subtype/conversion relationship e.g.
249231 // / `$T0 subtype of $T1` or `$T0 arg conversion $T1`.
250- llvm::SmallDenseSet<std::pair<TypeVariableType *, Constraint *>, 2 >
251- AdjacentVars;
252-
253- ASTNode AssociatedCodeCompletionToken = ASTNode();
232+ llvm::SmallVector<std::pair<TypeVariableType *, Constraint *>, 2 > AdjacentVars;
254233
255234 // / A set of all not-yet-resolved type variables this type variable
256235 // / is a subtype of, supertype of or is equivalent to. This is used
257236 // / to determine ordering inside of a chain of subtypes to help infer
258237 // / transitive bindings and protocol requirements.
259- llvm::SmallSetVector<std::pair<TypeVariableType *, Constraint *>, 4 > SubtypeOf;
260- llvm::SmallSetVector<std::pair<TypeVariableType *, Constraint *>, 4 > SupertypeOf;
261- llvm::SmallSetVector<std::pair<TypeVariableType *, Constraint *>, 4 > EquivalentTo;
262-
263- void addDefault (Constraint *constraint);
238+ llvm::SmallVector<std::pair<TypeVariableType *, Constraint *>, 4 > SubtypeOf;
239+ llvm::SmallVector<std::pair<TypeVariableType *, Constraint *>, 4 > SupertypeOf;
240+ llvm::SmallVector<std::pair<TypeVariableType *, Constraint *>, 4 > EquivalentTo;
264241
265- void addLiteral (Constraint *constraint );
242+ ASTNode AssociatedCodeCompletionToken = ASTNode( );
266243
267244 // / Add a potential binding to the list of bindings,
268245 // / coalescing supertype bounds when we are able to compute the meet.
@@ -385,28 +362,26 @@ class BindingSet {
385362
386363public:
387364 swift::SmallSetVector<PotentialBinding, 4 > Bindings;
365+
366+ // / The set of protocol conformance requirements placed on this type variable.
367+ llvm::SmallVector<Constraint *, 4 > Protocols;
368+
369+ // / The set of unique literal protocol requirements placed on this
370+ // / type variable or inferred transitively through subtype chains.
371+ // /
372+ // / Note that ordering is important when it comes to bindings, we'd
373+ // / like to add any "direct" default types first to attempt them
374+ // / before transitive ones.
388375 llvm::SmallMapVector<ProtocolDecl *, LiteralRequirement, 2 > Literals;
376+
389377 llvm::SmallDenseMap<CanType, Constraint *, 2 > Defaults;
390378
391379 // / The set of transitive protocol requirements inferred through
392380 // / subtype/conversion/equivalence relations with other type variables.
393381 std::optional<llvm::SmallPtrSet<Constraint *, 4 >> TransitiveProtocols;
394382
395383 BindingSet (ConstraintSystem &CS, TypeVariableType *TypeVar,
396- const PotentialBindings &info)
397- : CS(CS), TypeVar(TypeVar), Info(info) {
398- for (const auto &binding : info.Bindings )
399- addBinding (binding, /* isTransitive=*/ false );
400-
401- for (auto *literal : info.Literals )
402- addLiteralRequirement (literal);
403-
404- for (auto *constraint : info.Defaults )
405- addDefault (constraint);
406-
407- for (auto &entry : info.AdjacentVars )
408- AdjacentVars.insert (entry.first );
409- }
384+ const PotentialBindings &info);
410385
411386 ConstraintSystem &getConstraintSystem () const { return CS; }
412387
@@ -512,7 +487,7 @@ class BindingSet {
512487 }
513488
514489 ArrayRef<Constraint *> getConformanceRequirements () const {
515- return Info. Protocols ;
490+ return Protocols;
516491 }
517492
518493 unsigned getNumViableLiteralBindings () const ;
0 commit comments