mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ConstraintSystem] Implement type checking for converting a tuple to a
pack using the `.element` syntax.
This commit is contained in:
@@ -2567,6 +2567,7 @@ Type ConstraintSystem::getEffectiveOverloadType(ConstraintLocator *locator,
|
||||
case OverloadChoiceKind::KeyPathDynamicMemberLookup:
|
||||
case OverloadChoiceKind::KeyPathApplication:
|
||||
case OverloadChoiceKind::TupleIndex:
|
||||
case OverloadChoiceKind::MaterializePack:
|
||||
return Type();
|
||||
}
|
||||
|
||||
@@ -3247,6 +3248,7 @@ void ConstraintSystem::bindOverloadType(
|
||||
case OverloadChoiceKind::DeclViaBridge:
|
||||
case OverloadChoiceKind::DeclViaUnwrappedOptional:
|
||||
case OverloadChoiceKind::TupleIndex:
|
||||
case OverloadChoiceKind::MaterializePack:
|
||||
case OverloadChoiceKind::KeyPathApplication:
|
||||
bindTypeOrIUO(openedType);
|
||||
return;
|
||||
@@ -3488,6 +3490,14 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
|
||||
refType = adjustedRefType;
|
||||
break;
|
||||
|
||||
case OverloadChoiceKind::MaterializePack: {
|
||||
auto *tuple = choice.getBaseType()->castTo<TupleType>();
|
||||
auto *expansion = tuple->getElementType(0)->castTo<PackExpansionType>();
|
||||
adjustedRefType = expansion->getPatternType();
|
||||
refType = adjustedRefType;
|
||||
break;
|
||||
}
|
||||
|
||||
case OverloadChoiceKind::KeyPathApplication: {
|
||||
// Key path application looks like a subscript(keyPath: KeyPath<Base, T>).
|
||||
// The element type is T or @lvalue T based on the key path subtype and
|
||||
@@ -3927,6 +3937,7 @@ DeclName OverloadChoice::getName() const {
|
||||
case OverloadChoiceKind::KeyPathDynamicMemberLookup:
|
||||
return DeclName(DynamicMember.getPointer());
|
||||
|
||||
case OverloadChoiceKind::MaterializePack:
|
||||
case OverloadChoiceKind::TupleIndex:
|
||||
llvm_unreachable("no name!");
|
||||
}
|
||||
@@ -5219,6 +5230,7 @@ bool ConstraintSystem::diagnoseAmbiguity(ArrayRef<Solution> solutions) {
|
||||
break;
|
||||
|
||||
case OverloadChoiceKind::TupleIndex:
|
||||
case OverloadChoiceKind::MaterializePack:
|
||||
// FIXME: Actually diagnose something here.
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user