@@ -883,7 +883,6 @@ ConstraintSystem::getPotentialBindingForRelationalConstraint(
883
883
// of bindings for them until closure's body is opened.
884
884
if (auto *typeVar = first->getAs <TypeVariableType>()) {
885
885
if (typeVar->getImpl ().isClosureType ()) {
886
- result.InvolvesTypeVariables = true ;
887
886
result.DelayedBy .push_back (constraint);
888
887
return None;
889
888
}
@@ -1140,17 +1139,14 @@ bool ConstraintSystem::PotentialBindings::infer(
1140
1139
break ;
1141
1140
1142
1141
case ConstraintKind::Disjunction:
1143
- // FIXME: Recurse into these constraints to see whether this
1144
- // type variable is fully bound by any of them.
1145
- InvolvesTypeVariables = true ;
1146
-
1147
1142
// If there is additional context available via disjunction
1148
1143
// associated with closure literal (e.g. coercion to some other
1149
1144
// type) let's delay resolving the closure until the disjunction
1150
1145
// is attempted.
1151
1146
if (TypeVar->getImpl ().isClosureType ())
1152
1147
return true ;
1153
1148
1149
+ DelayedBy.push_back (constraint);
1154
1150
break ;
1155
1151
1156
1152
case ConstraintKind::ConformsTo:
@@ -1188,25 +1184,30 @@ bool ConstraintSystem::PotentialBindings::infer(
1188
1184
1189
1185
case ConstraintKind::ValueMember:
1190
1186
case ConstraintKind::UnresolvedValueMember:
1191
- case ConstraintKind::ValueWitness:
1192
- // If our type variable shows up in the base type, there's
1193
- // nothing to do.
1194
- // FIXME: Can we avoid simplification here?
1195
- if (ConstraintSystem::typeVarOccursInType (
1196
- TypeVar, cs.simplifyType (constraint->getFirstType ()),
1197
- &InvolvesTypeVariables)) {
1198
- return false ;
1187
+ case ConstraintKind::ValueWitness: {
1188
+ // If current type variable represents a member type of some reference,
1189
+ // it would be bound once member is resolved either to a actual member
1190
+ // type or to a hole if member couldn't be found.
1191
+ auto memberTy = constraint->getSecondType ()->castTo <TypeVariableType>();
1192
+
1193
+ if (memberTy->getImpl ().hasRepresentativeOrFixed ()) {
1194
+ if (auto type = memberTy->getImpl ().getFixedType (/* record=*/ nullptr )) {
1195
+ // It's possible that member has been bound to some other type variable
1196
+ // instead of merged with it because it's wrapped in an l-value type.
1197
+ if (type->getWithoutSpecifierType ()->isEqual (TypeVar)) {
1198
+ DelayedBy.push_back (constraint);
1199
+ break ;
1200
+ }
1201
+ } else {
1202
+ memberTy = memberTy->getImpl ().getRepresentative (/* record=*/ nullptr );
1203
+ }
1199
1204
}
1200
1205
1201
- // If the type variable is in the list of member type
1202
- // variables, it is fully bound.
1203
- // FIXME: Can we avoid simplification here?
1204
- if (ConstraintSystem::typeVarOccursInType (
1205
- TypeVar, cs.simplifyType (constraint->getSecondType ()),
1206
- &InvolvesTypeVariables)) {
1206
+ if (memberTy == TypeVar)
1207
1207
DelayedBy.push_back (constraint);
1208
- }
1208
+
1209
1209
break ;
1210
+ }
1210
1211
1211
1212
case ConstraintKind::OneWayEqual:
1212
1213
case ConstraintKind::OneWayBindParam: {
0 commit comments