Skip to content

Deprecated variables used in generated inits, could the init be marked deprecated as well? #932

Description

@StianFlatby

Question

When a struct includes a deprecated variable, the generated variable correctly gets a @available(*, deprecated) notation. However, the struct also gets an autogenerated init which uses this deprecated variable, and is not itself marked as deprecated, thus generating a workspace-wide warning message.

Image

I was initially hoping you could just autogenerate a pragma silence to the specific line in the init that uses the deprecated value, but I now realize it's not possible to do so in Swift.
However - if the entire init is marked as deprecated, it would silence the use within.

Image

I don't know, maybe this just moves the problem elsewhere, or maybe it's better with one deprecated init (including all deprecated variables) and one non-deprecated init that just omits the deprecated variabels and just don't set them (as long as they are optional, I think they should implicitly resolve to nil without warnings?)

I'm not sure what's best, I'm just sad about the warnings we're getting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/generatorAffects: plugin, CLI, config file.kind/bugFeature doesn't work as expected.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions