mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
AST: Requestify lookup of protocol referenced by ImplementsAttr
Direct lookup relied in primary file checking to have filled in the protocol type stored in the ImplementsAttr. This was already wrong with multi-file test cases in non-WMO mode, and crashed in the ASTPrinter if printing a declaration in a non-primary file. I don't have a standalone test case that is independent of my upcoming ASTPrinter changes, but this is a nice cleanup regardless.
This commit is contained in:
@@ -417,16 +417,12 @@ deriveEquatable_eq(
|
||||
// Add the @_implements(Equatable, ==(_:_:)) attribute
|
||||
if (generatedIdentifier != C.Id_EqualsOperator) {
|
||||
auto equatableProto = C.getProtocol(KnownProtocolKind::Equatable);
|
||||
auto equatableTy = equatableProto->getDeclaredInterfaceType();
|
||||
auto equatableTyExpr = TypeExpr::createImplicit(equatableTy, C);
|
||||
SmallVector<Identifier, 2> argumentLabels = { Identifier(), Identifier() };
|
||||
auto equalsDeclName = DeclName(C, DeclBaseName(C.Id_EqualsOperator),
|
||||
argumentLabels);
|
||||
eqDecl->getAttrs().add(new (C) ImplementsAttr(SourceLoc(),
|
||||
SourceRange(),
|
||||
equatableTyExpr,
|
||||
equalsDeclName,
|
||||
DeclNameLoc()));
|
||||
eqDecl->getAttrs().add(ImplementsAttr::create(parentDC,
|
||||
equatableProto,
|
||||
equalsDeclName));
|
||||
}
|
||||
|
||||
if (!C.getEqualIntDecl()) {
|
||||
|
||||
Reference in New Issue
Block a user