Skip to content
Merged
2 changes: 1 addition & 1 deletion include/swift/AST/Attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ class DeclAttributes {
/// Retrieve the first attribute of the given attribute class.
template <typename ATTR>
const ATTR *getAttribute(bool AllowInvalid = false) const {
return const_cast<DeclAttributes *>(this)->getAttribute<ATTR>();
return const_cast<DeclAttributes *>(this)->getAttribute<ATTR>(AllowInvalid);
}

template <typename ATTR>
Expand Down
9 changes: 0 additions & 9 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -1976,15 +1976,6 @@ NOTE(overridden_here,none,
NOTE(overridden_here_can_be_objc,none,
"add '@objc' to make this declaration overridable", ())

ERROR(override_objc_type_mismatch_method,none,
"overriding method with selector %0 has incompatible type %1",
(ObjCSelector, Type))
ERROR(override_objc_type_mismatch_subscript,none,
"overriding %select{|indexed |keyed }0subscript with incompatible type "
"%1",
(unsigned, Type))
NOTE(overridden_here_with_type,none,
"overridden declaration here has type %0", (Type))
ERROR(missing_override,none,
"overriding declaration requires an 'override' keyword", ())

Expand Down
12 changes: 0 additions & 12 deletions lib/AST/NameLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,8 @@ bool swift::removeOverriddenDecls(SmallVectorImpl<ValueDecl*> &decls) {
if (decls.size() < 2)
return false;

auto lazyResolver = decls.front()->getASTContext().getLazyResolver();
llvm::SmallPtrSet<ValueDecl*, 8> overridden;
for (auto decl : decls) {
// Compute enough information to make the overridden-declaration available.
if (lazyResolver)
lazyResolver->resolveOverriddenDecl(decl);

while (auto overrides = decl->getOverriddenDecl()) {
overridden.insert(overrides);

Expand All @@ -105,10 +100,6 @@ bool swift::removeOverriddenDecls(SmallVectorImpl<ValueDecl*> &decls) {
/// cause instead (incomplete circularity detection).
assert(decl != overrides && "Circular class inheritance?");
decl = overrides;

if (lazyResolver)
lazyResolver->resolveOverriddenDecl(decl);

continue;
}

Expand Down Expand Up @@ -1908,9 +1899,6 @@ bool DeclContext::lookupQualified(Type type,
// If the declaration has an override, name lookup will also have
// found the overridden method. Skip this declaration, because we
// prefer the overridden method.
if (typeResolver)
typeResolver->resolveOverriddenDecl(decl);

if (decl->getOverriddenDecl())
continue;

Expand Down
9 changes: 9 additions & 0 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6389,6 +6389,12 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
}

void SwiftDeclConverter::recordObjCOverride(AbstractFunctionDecl *decl) {
// Make sure that we always set the overriden declarations.
SWIFT_DEFER {
if (!decl->overriddenDeclsComputed())
(void)decl->setOverriddenDecls({ });
};

// Figure out the class in which this method occurs.
if (!decl->getDeclContext()->isTypeContext())
return;
Expand Down Expand Up @@ -6419,6 +6425,7 @@ void SwiftDeclConverter::recordObjCOverride(AbstractFunctionDecl *decl) {
func->getObjCSelector() != foundFunc->getObjCSelector())
continue;
func->setOverriddenDecl(foundFunc);
func->getAttrs().add(new (func->getASTContext()) OverrideAttr(true));
return;
}
// Set constructor override.
Expand All @@ -6429,6 +6436,8 @@ void SwiftDeclConverter::recordObjCOverride(AbstractFunctionDecl *decl) {
ctor->getObjCSelector() != memberCtor->getObjCSelector())
continue;
ctor->setOverriddenDecl(memberCtor);
ctor->getAttrs().add(new (ctor->getASTContext()) OverrideAttr(true));

// Propagate 'required' to subclass initializers.
if (memberCtor->isRequired() &&
!ctor->getAttrs().hasAttribute<RequiredAttr>()) {
Expand Down
Loading