mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Few fixes related to coroutine function types.
This commit is contained in:
@@ -7468,7 +7468,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
|
||||
#include "swift/AST/TypeNodes.def"
|
||||
|
||||
case TypeKind::Error:
|
||||
case TypeKind::YieldResult:
|
||||
return getTypeMatchFailure(locator);
|
||||
|
||||
// BuiltinGenericType subclasses
|
||||
@@ -7494,6 +7493,24 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
case TypeKind::YieldResult: {
|
||||
if (kind != ConstraintKind::Bind && kind != ConstraintKind::Subtype)
|
||||
return getTypeMatchFailure(locator);
|
||||
|
||||
auto *yield1 = cast<YieldResultType>(desugar1);
|
||||
auto *yield2 = cast<YieldResultType>(desugar2);
|
||||
|
||||
// TODO: In theory we can convert inout yield to non-inout one,
|
||||
// however, we disallow this for now as overall generic coroutine
|
||||
// semantics is a bit vague.
|
||||
if (yield1->isInOut() != yield2->isInOut())
|
||||
return getTypeMatchFailure(locator);
|
||||
|
||||
return matchTypes(yield1->getResultType(), yield2->getResultType(),
|
||||
ConstraintKind::Bind, subflags,
|
||||
locator.withPathElement(ConstraintLocator::LValueConversion));
|
||||
}
|
||||
|
||||
case TypeKind::Placeholder: {
|
||||
// If it's allowed to attempt fixes, let's delegate
|
||||
@@ -8504,7 +8521,6 @@ ConstraintSystem::simplifyConstructionConstraint(
|
||||
|
||||
case TypeKind::Error:
|
||||
case TypeKind::Placeholder:
|
||||
case TypeKind::YieldResult:
|
||||
return SolutionKind::Error;
|
||||
|
||||
case TypeKind::GenericFunction:
|
||||
@@ -8604,6 +8620,7 @@ ConstraintSystem::simplifyConstructionConstraint(
|
||||
case TypeKind::Function:
|
||||
case TypeKind::LValue:
|
||||
case TypeKind::InOut:
|
||||
case TypeKind::YieldResult:
|
||||
case TypeKind::Module:
|
||||
case TypeKind::Pack:
|
||||
case TypeKind::PackExpansion:
|
||||
|
||||
Reference in New Issue
Block a user