Skip to content

Commit fe4ba8a

Browse files
committed
[TypeCheckAttr] Use the correct APIs for checking protocol conformance
and replacing type parameters in a generic signature when type checking the typeEraser attribute.
1 parent 2185f43 commit fe4ba8a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,9 +2415,7 @@ TypeEraserHasViableInitRequest::evaluate(Evaluator &evaluator,
24152415
}
24162416

24172417
// The type eraser must conform to the annotated protocol
2418-
SmallVector<ProtocolConformance *, 2> conformances;
2419-
if (!nominalTypeDecl->lookupConformance(dc->getParentModule(), protocol,
2420-
conformances)) {
2418+
if (!TypeChecker::conformsToProtocol(typeEraser, protocol, dc, None)) {
24212419
diags.diagnose(typeEraserLoc.getLoc(), diag::type_eraser_does_not_conform,
24222420
typeEraser, protocolType);
24232421
diags.diagnose(nominalTypeDecl->getLoc(), diag::type_eraser_declared_here);
@@ -2464,13 +2462,15 @@ TypeEraserHasViableInitRequest::evaluate(Evaluator &evaluator,
24642462
typeEraser->getContextSubstitutionMap(nominalTypeDecl->getParentModule(),
24652463
nominalTypeDecl);
24662464
QuerySubstitutionMap getSubstitution{baseMap};
2467-
auto subMap = genericSignature->getIdentitySubstitutionMap().subst(
2465+
auto subMap = SubstitutionMap::get(
2466+
genericSignature,
24682467
[&](SubstitutableType *type) -> Type {
24692468
if (type->isEqual(genericParamType))
24702469
return protocol->getSelfTypeInContext();
24712470

24722471
return getSubstitution(type);
2473-
}, TypeChecker::LookUpConformance(dc));
2472+
},
2473+
TypeChecker::LookUpConformance(dc));
24742474

24752475
// Use invalid 'SourceLoc's to suppress diagnostics.
24762476
auto result = TypeChecker::checkGenericArguments(

0 commit comments

Comments
 (0)