AST: Introduce ProtocolDecl::get{AssociatedType,ProtocolRequirement}()

This commit is contained in:
Slava Pestov
2019-08-29 22:04:38 -04:00
parent 7f6ef1e12d
commit 22cb6f1176
20 changed files with 114 additions and 196 deletions

View File

@@ -6856,16 +6856,15 @@ ConstraintSystem::simplifyDynamicCallableApplicableFnConstraint(
ctx.getProtocol(KnownProtocolKind::ExpressibleByArrayLiteral);
addConstraint(ConstraintKind::ConformsTo, tvParam,
arrayLitProto->getDeclaredType(), locator);
auto elementAssocType = cast<AssociatedTypeDecl>(
arrayLitProto->lookupDirect(ctx.Id_ArrayLiteralElement).front());
auto elementAssocType = arrayLitProto->getAssociatedType(
ctx.Id_ArrayLiteralElement);
argumentType = DependentMemberType::get(tvParam, elementAssocType);
} else {
auto dictLitProto =
ctx.getProtocol(KnownProtocolKind::ExpressibleByDictionaryLiteral);
addConstraint(ConstraintKind::ConformsTo, tvParam,
dictLitProto->getDeclaredType(), locator);
auto valueAssocType = cast<AssociatedTypeDecl>(
dictLitProto->lookupDirect(ctx.Id_Value).front());
auto valueAssocType = dictLitProto->getAssociatedType(ctx.Id_Value);
argumentType = DependentMemberType::get(tvParam, valueAssocType);
}