Skip to content

Add @_objcImplementation attribute #798

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
Oct 21, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ extension Parser {
case _objcRuntimeName = "_objcRuntimeName"
case _staticInitializeObjCMetadata = "_staticInitializeObjCMetadata"
case _restatedObjCConformance = "_restatedObjCConformance"
case _objcImplementation = "_objcImplementation"
case _optimize = "_optimize"
case _clangImporterSynthesizedType = "_clangImporterSynthesizedType"
case _weakLinked = "_weakLinked"
Expand Down
11 changes: 11 additions & 0 deletions Tests/SwiftParserTest/Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,15 @@ final class AttributeTests: XCTestCase {
"""
)
}

func testObjcImplementationAttribute() throws {
AssertParse("""
@_objcImplementation extension MyClass {
func fn() {}
}
@_objcImplementation(Category) extension MyClass {
func fn2() {}
}
""")
}
}
6 changes: 5 additions & 1 deletion gyb_syntax_support/AttributeKinds.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ def __init__(self, name, swift_name=None):
ABIStableToAdd, ABIStableToRemove, APIStableToAdd, APIStableToRemove,
code=70),
# NOTE: 71 is unused
# NOTE: 72 is unused
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a vague memory of reading somewhere that it’s unsafe to reuse old codes but can’t find it anymore. @CodaFi do you remember readings something of the sort when migrating AttributeKinds.py from the compiler repository?

DeclAttribute('_objcImplementation', 'ObjCImplementation',
OnExtension,
UserInaccessible,
ABIBreakingToAdd, ABIBreakingToRemove, APIBreakingToAdd, APIBreakingToRemove,
code=72),
DeclAttribute('_optimize', 'Optimize',
OnAbstractFunction, OnSubscript, OnVar,
UserInaccessible,
Expand Down