@@ -2250,9 +2250,8 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
2250
2250
}
2251
2251
}
2252
2252
2253
- template <typename Fn>
2254
- Type simplifyTypeImpl (const ConstraintSystem &cs, Type type,
2255
- Fn getFixedTypeFn) {
2253
+ Type ConstraintSystem::simplifyTypeImpl (Type type,
2254
+ llvm::function_ref<Type(TypeVariableType *)> getFixedTypeFn) const {
2256
2255
return type.transform ([&](Type type) -> Type {
2257
2256
if (auto tvt = dyn_cast<TypeVariableType>(type.getPointer ()))
2258
2257
return getFixedTypeFn (tvt);
@@ -2261,7 +2260,7 @@ Type simplifyTypeImpl(const ConstraintSystem &cs, Type type,
2261
2260
// the base to a non-type-variable, perform lookup.
2262
2261
if (auto depMemTy = dyn_cast<DependentMemberType>(type.getPointer ())) {
2263
2262
// Simplify the base.
2264
- Type newBase = simplifyTypeImpl (cs, depMemTy->getBase (), getFixedTypeFn);
2263
+ Type newBase = simplifyTypeImpl (depMemTy->getBase (), getFixedTypeFn);
2265
2264
2266
2265
// If nothing changed, we're done.
2267
2266
if (newBase.getPointer () == depMemTy->getBase ().getPointer ())
@@ -2279,7 +2278,7 @@ Type simplifyTypeImpl(const ConstraintSystem &cs, Type type,
2279
2278
2280
2279
if (lookupBaseType->mayHaveMembers ()) {
2281
2280
auto *proto = assocType->getProtocol ();
2282
- auto conformance = cs. DC ->getParentModule ()->lookupConformance (
2281
+ auto conformance = DC->getParentModule ()->lookupConformance (
2283
2282
lookupBaseType, proto);
2284
2283
if (!conformance)
2285
2284
return DependentMemberType::get (lookupBaseType, assocType);
@@ -2298,21 +2297,15 @@ Type simplifyTypeImpl(const ConstraintSystem &cs, Type type,
2298
2297
});
2299
2298
}
2300
2299
2301
- Type ConstraintSystem::simplifyType (Type type, bool forDiagnostics ) const {
2300
+ Type ConstraintSystem::simplifyType (Type type) const {
2302
2301
if (!type->hasTypeVariable ())
2303
2302
return type;
2304
2303
2305
2304
// Map type variables down to the fixed types of their representatives.
2306
- return simplifyTypeImpl (
2307
- *this , type,
2305
+ return simplifyTypeImpl (type,
2308
2306
[&](TypeVariableType *tvt) -> Type {
2309
- if (auto fixed = getFixedType (tvt)) {
2310
- if (forDiagnostics && fixed->isHole () &&
2311
- tvt->getImpl ().getLocator ()->isForGenericParameter ())
2312
- return tvt->getImpl ().getLocator ()->getGenericParameter ();
2313
-
2307
+ if (auto fixed = getFixedType (tvt))
2314
2308
return simplifyType (fixed);
2315
- }
2316
2309
2317
2310
return getRepresentative (tvt);
2318
2311
});
@@ -2323,8 +2316,7 @@ Type Solution::simplifyType(Type type) const {
2323
2316
return type;
2324
2317
2325
2318
// Map type variables to fixed types from bindings.
2326
- return simplifyTypeImpl (
2327
- getConstraintSystem (), type,
2319
+ return getConstraintSystem ().simplifyTypeImpl (type,
2328
2320
[&](TypeVariableType *tvt) -> Type {
2329
2321
auto known = typeBindings.find (tvt);
2330
2322
assert (known != typeBindings.end ());
0 commit comments