@@ -1258,8 +1258,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
1258
1258
// Obviously, this must not happen at the top level, or the
1259
1259
// algorithm would not terminate.
1260
1260
addUnsolvedConstraint (Constraint::create (*this , kind, type1, type2,
1261
- DeclName (),
1262
- FunctionRefKind::Compound,
1263
1261
getConstraintLocator (locator)));
1264
1262
return SolutionKind::Solved;
1265
1263
}
@@ -2182,6 +2180,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
2182
2180
ConstraintSystem::SolutionKind
2183
2181
ConstraintSystem::simplifyConstructionConstraint (
2184
2182
Type valueType, FunctionType *fnType, TypeMatchOptions flags,
2183
+ DeclContext *useDC,
2185
2184
FunctionRefKind functionRefKind, ConstraintLocator *locator) {
2186
2185
2187
2186
// Desugar the value type.
@@ -2256,9 +2255,9 @@ ConstraintSystem::simplifyConstructionConstraint(
2256
2255
}
2257
2256
2258
2257
NameLookupOptions lookupOptions = defaultConstructorLookupOptions;
2259
- if (isa<AbstractFunctionDecl>(DC ))
2258
+ if (isa<AbstractFunctionDecl>(useDC ))
2260
2259
lookupOptions |= NameLookupFlags::KnownPrivate;
2261
- auto ctors = TC.lookupConstructors (DC , valueType, lookupOptions);
2260
+ auto ctors = TC.lookupConstructors (useDC , valueType, lookupOptions);
2262
2261
if (!ctors)
2263
2262
return SolutionKind::Error;
2264
2263
@@ -2275,7 +2274,8 @@ ConstraintSystem::simplifyConstructionConstraint(
2275
2274
// variable T. T2 is the result type provided via the construction
2276
2275
// constraint itself.
2277
2276
addValueMemberConstraint (MetatypeType::get (valueType, TC.Context ), name,
2278
- FunctionType::get (tv, resultType), functionRefKind,
2277
+ FunctionType::get (tv, resultType),
2278
+ useDC, functionRefKind,
2279
2279
getConstraintLocator (
2280
2280
fnLocator,
2281
2281
ConstraintLocator::ConstructorMember));
@@ -2317,7 +2317,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
2317
2317
if (flags.contains (TMF_GenerateConstraints)) {
2318
2318
addUnsolvedConstraint (
2319
2319
Constraint::create (*this , kind, type, protocol->getDeclaredType (),
2320
- DeclName (), FunctionRefKind::Compound,
2321
2320
getConstraintLocator (locator)));
2322
2321
return SolutionKind::Solved;
2323
2322
}
@@ -2410,8 +2409,7 @@ ConstraintSystem::simplifyCheckedCastConstraint(
2410
2409
if (flags.contains (TMF_GenerateConstraints)) {
2411
2410
addUnsolvedConstraint (
2412
2411
Constraint::create (*this , ConstraintKind::CheckedCast, fromType,
2413
- toType, DeclName (), FunctionRefKind::Compound,
2414
- getConstraintLocator (locator)));
2412
+ toType, getConstraintLocator (locator)));
2415
2413
return SolutionKind::Solved;
2416
2414
}
2417
2415
@@ -2541,8 +2539,7 @@ ConstraintSystem::simplifyOptionalObjectConstraint(
2541
2539
if (flags.contains (TMF_GenerateConstraints)) {
2542
2540
addUnsolvedConstraint (
2543
2541
Constraint::create (*this , ConstraintKind::OptionalObject, optLValueTy,
2544
- second, DeclName (), FunctionRefKind::Compound,
2545
- getConstraintLocator (locator)));
2542
+ second, getConstraintLocator (locator)));
2546
2543
return SolutionKind::Solved;
2547
2544
}
2548
2545
@@ -3110,6 +3107,7 @@ ConstraintSystem::SolutionKind
3110
3107
ConstraintSystem::simplifyMemberConstraint (ConstraintKind kind,
3111
3108
Type baseTy, DeclName member,
3112
3109
Type memberTy,
3110
+ DeclContext *useDC,
3113
3111
FunctionRefKind functionRefKind,
3114
3112
TypeMatchOptions flags,
3115
3113
ConstraintLocatorBuilder locatorB) {
@@ -3141,8 +3139,8 @@ ConstraintSystem::simplifyMemberConstraint(ConstraintKind kind,
3141
3139
// If requested, generate a constraint.
3142
3140
if (flags.contains (TMF_GenerateConstraints)) {
3143
3141
addUnsolvedConstraint (
3144
- Constraint::create (*this , kind, baseTy, memberTy, member,
3145
- functionRefKind, locator));
3142
+ Constraint::createMember (*this , kind, baseTy, memberTy, member, useDC ,
3143
+ functionRefKind, locator));
3146
3144
return SolutionKind::Solved;
3147
3145
}
3148
3146
@@ -3158,7 +3156,7 @@ ConstraintSystem::simplifyMemberConstraint(ConstraintKind kind,
3158
3156
3159
3157
// If we found viable candidates, then we're done!
3160
3158
if (!result.ViableCandidates .empty ()) {
3161
- addOverloadSet (memberTy, result.ViableCandidates , locator,
3159
+ addOverloadSet (memberTy, result.ViableCandidates , useDC, locator,
3162
3160
result.getFavoredChoice ());
3163
3161
3164
3162
return SolutionKind::Solved;
@@ -3196,7 +3194,7 @@ ConstraintSystem::simplifyMemberConstraint(ConstraintKind kind,
3196
3194
3197
3195
// Look through one level of optional.
3198
3196
addValueMemberConstraint (baseObjTy->getOptionalObjectType (),
3199
- member, memberTy, functionRefKind, locator);
3197
+ member, memberTy, useDC, functionRefKind, locator);
3200
3198
return SolutionKind::Solved;
3201
3199
}
3202
3200
return SolutionKind::Error;
@@ -3213,7 +3211,6 @@ ConstraintSystem::simplifyDefaultableConstraint(
3213
3211
if (flags.contains (TMF_GenerateConstraints)) {
3214
3212
addUnsolvedConstraint (
3215
3213
Constraint::create (*this , ConstraintKind::Defaultable, first, second,
3216
- DeclName (), FunctionRefKind::Compound,
3217
3214
getConstraintLocator (locator)));
3218
3215
return SolutionKind::Solved;
3219
3216
}
@@ -3238,7 +3235,6 @@ ConstraintSystem::simplifyDynamicTypeOfConstraint(
3238
3235
if (flags.contains (TMF_GenerateConstraints)) {
3239
3236
addUnsolvedConstraint (
3240
3237
Constraint::create (*this , ConstraintKind::DynamicTypeOf, type1, type2,
3241
- DeclName (), FunctionRefKind::Compound,
3242
3238
getConstraintLocator (locator)));
3243
3239
return SolutionKind::Solved;
3244
3240
}
@@ -3300,8 +3296,7 @@ ConstraintSystem::simplifyBridgingConstraint(Type type1,
3300
3296
if (flags.contains (TMF_GenerateConstraints)) {
3301
3297
addUnsolvedConstraint (
3302
3298
Constraint::create (*this , ConstraintKind::BridgingConversion, type1,
3303
- type2, DeclName (), FunctionRefKind::Compound,
3304
- getConstraintLocator (locator)));
3299
+ type2, getConstraintLocator (locator)));
3305
3300
return SolutionKind::Solved;
3306
3301
}
3307
3302
@@ -3527,9 +3522,7 @@ ConstraintSystem::simplifyEscapableFunctionOfConstraint(
3527
3522
if (flags.contains (TMF_GenerateConstraints)) {
3528
3523
addUnsolvedConstraint (
3529
3524
Constraint::create (*this , ConstraintKind::EscapableFunctionOf,
3530
- type1, type2,
3531
- DeclName (), FunctionRefKind::Compound,
3532
- getConstraintLocator (locator)));
3525
+ type1, type2, getConstraintLocator (locator)));
3533
3526
return SolutionKind::Solved;
3534
3527
}
3535
3528
@@ -3602,8 +3595,7 @@ ConstraintSystem::simplifyApplicableFnConstraint(
3602
3595
if (flags.contains (TMF_GenerateConstraints)) {
3603
3596
addUnsolvedConstraint (
3604
3597
Constraint::create (*this , ConstraintKind::ApplicableFunction, type1,
3605
- type2, DeclName (), FunctionRefKind::Compound,
3606
- getConstraintLocator (locator)));
3598
+ type2, getConstraintLocator (locator)));
3607
3599
return SolutionKind::Solved;
3608
3600
}
3609
3601
@@ -3673,6 +3665,7 @@ ConstraintSystem::simplifyApplicableFnConstraint(
3673
3665
3674
3666
// Construct the instance from the input arguments.
3675
3667
return simplifyConstructionConstraint (instance2, func1, subflags,
3668
+ /* FIXME?*/ DC,
3676
3669
FunctionRefKind::SingleApply,
3677
3670
getConstraintLocator (outerLocator));
3678
3671
}
@@ -3889,18 +3882,12 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
3889
3882
if (flags.contains (TMF_GenerateConstraints)) {
3890
3883
auto int8Con = Constraint::create (*this , ConstraintKind::Bind,
3891
3884
baseType2, TC.getInt8Type (DC),
3892
- DeclName (),
3893
- FunctionRefKind::Compound,
3894
3885
getConstraintLocator (locator));
3895
3886
auto uint8Con = Constraint::create (*this , ConstraintKind::Bind,
3896
3887
baseType2, TC.getUInt8Type (DC),
3897
- DeclName (),
3898
- FunctionRefKind::Compound,
3899
3888
getConstraintLocator (locator));
3900
3889
auto voidCon = Constraint::create (*this , ConstraintKind::Bind,
3901
3890
baseType2, TC.Context .TheEmptyTupleType ,
3902
- DeclName (),
3903
- FunctionRefKind::Compound,
3904
3891
getConstraintLocator (locator));
3905
3892
3906
3893
Constraint *disjunctionChoices[] = {int8Con, uint8Con, voidCon};
@@ -4229,8 +4216,7 @@ void ConstraintSystem::addConstraint(ConstraintKind kind, Type first,
4229
4216
case SolutionKind::Error:
4230
4217
// Add a failing constraint, if needed.
4231
4218
if (shouldAddNewFailingConstraint ()) {
4232
- auto c = Constraint::create (*this , kind, first, second, DeclName (),
4233
- FunctionRefKind::Compound,
4219
+ auto c = Constraint::create (*this , kind, first, second,
4234
4220
getConstraintLocator (locator));
4235
4221
if (isFavored) c->setFavored ();
4236
4222
addNewFailingConstraint (c);
@@ -4256,9 +4242,7 @@ void ConstraintSystem::addExplicitConversionConstraint(
4256
4242
// Coercion (the common case).
4257
4243
Constraint *coerceConstraint =
4258
4244
Constraint::create (*this , ConstraintKind::Conversion,
4259
- fromType, toType, DeclName (),
4260
- FunctionRefKind::Compound,
4261
- locatorPtr);
4245
+ fromType, toType, locatorPtr);
4262
4246
coerceConstraint->setFavored ();
4263
4247
constraints.push_back (coerceConstraint);
4264
4248
@@ -4267,9 +4251,7 @@ void ConstraintSystem::addExplicitConversionConstraint(
4267
4251
// The source type can be explicitly converted to the destination type.
4268
4252
Constraint *bridgingConstraint =
4269
4253
Constraint::create (*this , ConstraintKind::BridgingConversion,
4270
- fromType, toType, DeclName (),
4271
- FunctionRefKind::Compound,
4272
- locatorPtr);
4254
+ fromType, toType, locatorPtr);
4273
4255
constraints.push_back (bridgingConstraint);
4274
4256
}
4275
4257
@@ -4347,7 +4329,8 @@ ConstraintSystem::simplifyConstraint(const Constraint &constraint) {
4347
4329
4348
4330
case ConstraintKind::BindOverload:
4349
4331
resolveOverload (constraint.getLocator (), constraint.getFirstType (),
4350
- constraint.getOverloadChoice ());
4332
+ constraint.getOverloadChoice (),
4333
+ constraint.getOverloadUseDC ());
4351
4334
return SolutionKind::Solved;
4352
4335
4353
4336
case ConstraintKind::ConformsTo:
@@ -4391,6 +4374,7 @@ ConstraintSystem::simplifyConstraint(const Constraint &constraint) {
4391
4374
constraint.getFirstType (),
4392
4375
constraint.getMember (),
4393
4376
constraint.getSecondType (),
4377
+ constraint.getMemberUseDC (),
4394
4378
constraint.getFunctionRefKind (),
4395
4379
TMF_GenerateConstraints,
4396
4380
constraint.getLocator ());
0 commit comments