[CS] Better diagnose inout argument in tuple construction

Previously we relied on `TupleTypeElt::getType`
returning an `InOutType` to fail the tuple type
matching logic. Instead, add logic to reject any
inout arguments up-front with a more specific
diagnostic.

Also, while we're here, strip the `_const`
parameter flag, as it's not something that needs
to be considered for tuple construction.
This commit is contained in:
Hamish Knight
2022-08-02 13:56:30 +01:00
parent 227f0deb5b
commit 1bf954c61f
3 changed files with 42 additions and 3 deletions

View File

@@ -5608,6 +5608,13 @@ Solution::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
if (simplifyType(rawFnType)->is<UnresolvedType>())
return None;
// A tuple construction is spelled in the AST as a function call, but
// is really more like a tuple conversion.
if (auto metaTy = simplifyType(rawFnType)->getAs<MetatypeType>()) {
if (metaTy->getInstanceType()->is<TupleType>())
return None;
}
assert(!shouldHaveDirectCalleeOverload(call) &&
"Should we have resolved a callee for this?");
}