Skip to content

[SR-4744] @objc Attribute validation should support Protocol Extension declaration #47321

@swift-ci

Description

@swift-ci
Previous ID SR-4744
Radar None
Original Reporter garricn (JIRA User)
Type Improvement
Status Resolved
Resolution Won't Do
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, Runtime
Assignee None
Priority Medium

md5: f63bdf0f8e3527e2918ab4f55f8dc55b

duplicates:

  • SR-3349 @objc methods cannot be contained in protocol extensions

Issue Description:

According to https://twitter.com/garricn/status/858489431270936577 the following code should compile:
Apparently, this is a known issue:

import Foundation

@objc protocol SomeProtocol {}

extension SomeProtocol {
    @objc func someFunction() {}
}

However, this code produces the following error at the second use of @objc:

@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions