@@ -848,7 +848,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
848
848
// An @autoclosure function type can be a subtype of a
849
849
// non-@autoclosure function type.
850
850
if (func1->isAutoClosure () != func2->isAutoClosure () &&
851
- (func2-> isAutoClosure () || kind < TypeMatchKind::Subtype) )
851
+ kind < TypeMatchKind::Subtype)
852
852
return SolutionKind::Error;
853
853
854
854
// A non-throwing function can be a subtype of a throwing function.
@@ -1480,10 +1480,17 @@ ConstraintSystem::matchTypes(Type type1, Type type2, TypeMatchKind kind,
1480
1480
ConstraintLocator::InstanceType));
1481
1481
}
1482
1482
1483
- case TypeKind::Function:
1484
- return matchFunctionTypes (cast<FunctionType>(desugar1),
1485
- cast<FunctionType>(desugar2),
1486
- kind, flags, locator);
1483
+ case TypeKind::Function: {
1484
+ auto func1 = cast<FunctionType>(desugar1);
1485
+ auto func2 = cast<FunctionType>(desugar2);
1486
+
1487
+ // If the 2nd type is an autoclosure, then we don't actually want to
1488
+ // treat these as parallel. The first type needs wrapping in a closure
1489
+ // despite already being a function type.
1490
+ if (!func1->isAutoClosure () && func2->isAutoClosure ())
1491
+ break ;
1492
+ return matchFunctionTypes (func1, func2, kind, flags, locator);
1493
+ }
1487
1494
1488
1495
case TypeKind::PolymorphicFunction:
1489
1496
case TypeKind::GenericFunction:
0 commit comments