Skip to content

[SR-9919] Classes marked as @objcMembers don't warn if not inherited from NSObject #52325

@AliSoftware

Description

@AliSoftware
Previous ID SR-9919
Radar None
Original Reporter @AliSoftware
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 924803a6681795b962e04f6332511076

Issue Description:

Summary

A pure Swift class non-inheriting NSObject can be marked as @objcMembers

Expected results

The compiler should error when classes not inheriting NSObjects are declared as @objcMembers, the same way it errors about those with @objc

Actual results

No error (and the class is omitted from the generated interface)

Example

When annotating with @objc we get the following expected error:

import Foundation

@objc class Foo {} // error: Only classes that inherit from NSObject can be declared @objc

But when annotating with @objcMembers we don't and this compiles without any error:

import Foundation

@objcMembers class Foo {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions