Skip to content

[ModuleInterface] Don't print @_staticInitializeObjCMetadata #28204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,13 @@ PrintOptions PrintOptions::printSwiftInterfaceFile(bool preferTypeRepr) {
// the default to 'public' and mark the 'internal' things.
result.PrintAccess = true;

result.ExcludeAttrList = {DAK_AccessControl, DAK_SetterAccess, DAK_Lazy};
result.ExcludeAttrList = {
DAK_AccessControl,
DAK_SetterAccess,
DAK_Lazy,
DAK_StaticInitializeObjCMetadata,
DAK_RestatedObjCConformance
};

return result;
}
Expand Down
22 changes: 22 additions & 0 deletions test/ModuleInterface/static-initialize-objc-metadata-attr.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path - %s -enable-library-evolution -target %target-pre-stable-abi-triple -module-name Module | %FileCheck %s
// REQUIRES: objc_interop

import Foundation

// To infer @_staticInitializeObjCMetadata, the following needs to be true
// Our class needs to be:
// - A subclass of a generic Objective-C class
// - That inherits a conformance to a protocol
// - Declared in a module with a deployment target before the stable ABI

public class Super<T>: NSObject, NSCoding {
required public init(coder: NSCoder) {}
public func encode(with: NSCoder) {}
}

// CHECK-NOT: @_staticInitializeObjCMetadata
// CHECK: public class Sub : Module.Super<Swift.Int>
public class Sub: Super<Int> {
required public init(coder: NSCoder) {}
override public func encode(with: NSCoder) {}
}