Skip to content

[SR-15096] Add diagnostic for usage of 'open' extension methods on pure Swift classes #57422

@typesanitizer

Description

@typesanitizer
Previous ID SR-15096
Radar None
Original Reporter @typesanitizer
Type Bug
Status In Progress
Resolution
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee mininny (JIRA)
Priority Medium

md5: f58fc20f557cce2f2ade639d7c1ce432

Issue Description:

The following code snippet:

public class C { }
extension C {
  open func f() { }
}

compiles without a diagnostic today. Superficially, it might seem like you can override f from a subclass of C. However, that's not the case; you can only overload it. Being able to override methods declared in extensions would require a mechanism like objc_msgSend, which is why such overloading only works when @objc is present, there is no Swift equivalent for pure Swift classes.

This means that the open is misleading to a reader; we should issue a diagnostic with a fix-it to replace this with public instead in such situations.

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