Skip to content

Commit 75ca32e

Browse files
authored
Merge pull request #38550 from nkcsgexi/80918826
ModuleInterface: skip printing the override keyword if the overriden decl is skipped
2 parents a9b5239 + a25d5ec commit 75ca32e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/AST/Attr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
747747
// implication. Thus we can skip them.
748748
if (auto *VD = dyn_cast<ValueDecl>(D)) {
749749
if (auto *BD = VD->getOverriddenDecl()) {
750+
// If the overriden decl won't be printed, printing override will fail
751+
// the build of the interface file.
752+
if (!Options.shouldPrint(BD))
753+
return false;
750754
if (!BD->hasClangNode() &&
751755
!BD->getFormalAccessScope(VD->getDeclContext(),
752756
/*treatUsableFromInlineAsPublic*/ true)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/inputs)
3+
// RUN: %empty-directory(%t/modulecache)
4+
// RUN: echo "public class HideyHole { @_spi(Private) public init() {} }" > %t/Foo.swift
5+
// RUN: echo "public class StashyCache: HideyHole {}" >> %t/Foo.swift
6+
7+
// RUN: %target-swift-frontend -emit-module -emit-module-interface-path %t/inputs/Foo.swiftinterface %t/Foo.swift -module-name Foo
8+
9+
// RUN: %target-swift-frontend -emit-module-path %t/Bar.swiftmodule -enable-library-evolution -enable-objc-interop -disable-objc-attr-requires-foundation-module -module-name Bar %s -I %t/inputs -disable-availability-checking -module-cache-path %t/modulecache
10+
11+
import Foo

0 commit comments

Comments
 (0)