Skip to content

Commit 5a8fdaf

Browse files
authored
Merge pull request #32638 from CodaFi/let-it-override
Use Formal Access To Compute Override Elision Check
2 parents b766544 + 89ae325 commit 5a8fdaf

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/AST/Attr.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,11 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
749749
if (auto *VD = dyn_cast<ValueDecl>(D)) {
750750
if (auto *BD = VD->getOverriddenDecl()) {
751751
if (!BD->hasClangNode() &&
752-
VD->isEffectiveLinkageMoreVisibleThan(BD))
752+
!BD->getFormalAccessScope(VD->getDeclContext(),
753+
/*treatUsableFromInlineAsPublic*/ true)
754+
.isPublic()) {
753755
return false;
756+
}
754757
}
755758
}
756759
break;

test/ModuleInterface/skip-override-keyword.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@
22
// RUN: %target-swift-frontend -typecheck -module-name Foo -emit-module-interface-path %t/Foo.swiftinterface %s
33
// RUN: %target-swift-frontend -compile-module-from-interface %t/Foo.swiftinterface -o %t/Foo.swiftmodule
44

5+
// RUN: %target-swift-frontend -typecheck -enable-testing -module-name FooWithTesting -emit-module-interface-path %t/FooWithTesting.swiftinterface %s
6+
// RUN: %target-swift-frontend -compile-module-from-interface %t/FooWithTesting.swiftinterface -o %t/FooWithTesting.swiftmodule
7+
58
public class BaseClass {
9+
init() { }
610
var property: Int { return 1 }
711
func doSomething() { }
812
subscript(index: Int) -> Int { get { return 0 } set(newValue) {} }
13+
@usableFromInline func doSomethingInline() {}
14+
@usableFromInline func doSomethingUsableFromInline() {}
915
}
16+
1017
public class DerivedClass: BaseClass {
18+
public override init() { super.init() }
1119
public override var property : Int { return 0 }
1220
public override func doSomething() { }
1321
public override subscript(index: Int) -> Int { get {return 0} set(newValue) {} }
22+
@inlinable public override func doSomethingInline() { super.doSomethingInline() }
23+
@usableFromInline override func doSomethingUsableFromInline() { super.doSomethingUsableFromInline() }
1424
}

0 commit comments

Comments
 (0)