@@ -318,6 +318,10 @@ enum TypeVariableOptions {
318318
319319 // / Whether the type variable can be bound only to a pack expansion type.
320320 TVO_PackExpansion = 0x40 ,
321+
322+ // / Whether the hole for this type variable origates from a different
323+ // / type variable in the equivalence class.
324+ TVO_NonRepresentativeHole = 0x80 ,
321325};
322326
323327enum class KeyPathMutability : uint8_t {
@@ -397,6 +401,8 @@ class TypeVariableType::Implementation {
397401 // / Whether this type variable can bind only to PackExpansionType.
398402 bool isPackExpansion () const { return getRawOptions () & TVO_PackExpansion; }
399403
404+ bool isNonRepresentativeHole () const { return getRawOptions () & TVO_NonRepresentativeHole; }
405+
400406 // / Whether this type variable prefers a subtype binding over a supertype
401407 // / binding.
402408 bool prefersSubtypeBinding () const {
@@ -588,6 +594,12 @@ class TypeVariableType::Implementation {
588594 recordBinding (*trail);
589595 getTypeVariable ()->Bits .TypeVariableType .Options &= ~TVO_CanBindToPack;
590596 }
597+
598+ if (!canBindToHole () && otherRep->getImpl ().canBindToHole ()) {
599+ if (trail)
600+ recordBinding (*trail);
601+ getTypeVariable ()->Bits .TypeVariableType .Options |= (TVO_CanBindToHole | TVO_NonRepresentativeHole);
602+ }
591603 }
592604
593605 // / Retrieve the fixed type that corresponds to this type variable,
@@ -701,6 +713,7 @@ class TypeVariableType::Implementation {
701713 ENTRY (TVO_PrefersSubtypeBinding, " " );
702714 ENTRY (TVO_CanBindToPack, " pack" );
703715 ENTRY (TVO_PackExpansion, " pack expansion" );
716+ ENTRY (TVO_NonRepresentativeHole, " non-rep hole" );
704717 }
705718 #undef ENTRY
706719 }
@@ -3485,6 +3498,8 @@ class ConstraintSystem {
34853498 getImplicitValueConversionLocator (ConstraintLocatorBuilder root,
34863499 ConversionRestrictionKind restriction);
34873500
3501+ ConstraintLocator *getHoleLocator (TypeVariableType *tv);
3502+
34883503 // / Lookup and return parent associated with given expression.
34893504 Expr *getParentExpr (Expr *expr) {
34903505 if (auto result = getExprDepthAndParent (expr))
0 commit comments