Skip to content

Commit bc0a18f

Browse files
committed
[Type Checker] Only resolveOverriddenDecl() for decls with ‘override’.
resolveOverriddenDecl() is meant to be used to provide access to the overridden declarations, e.g., from another source file. Only resolve when the declaration has an explicit ‘override’ modifier or is an initializer (for which there are cases where ‘override’ is not required). This does not yet reduce override checking across source files, because checkOverrides() is still called during validateDeclForNameLookup(), and we’re still doing too much work to compute overrides.
1 parent d5bd991 commit bc0a18f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,8 +1644,10 @@ void TypeChecker::resolveOverriddenDecl(ValueDecl *VD) {
16441644
if (isa<TypeDecl>(VD))
16451645
return;
16461646

1647-
// FIXME: We should check for the 'override' or 'required' keywords
1648-
// here, to short-circuit checking in the common case.
1647+
// Only initializers and declarations marked with the 'override' declaration
1648+
// modifier can override declarations.
1649+
if (!isa<ConstructorDecl>(VD) && !VD->getAttrs().hasAttribute<OverrideAttr>())
1650+
return;
16491651

16501652
// FIXME: We should perform more minimal validation.
16511653
validateDeclForNameLookup(VD);

0 commit comments

Comments
 (0)