Skip to content

tune "convert to set literal" assist to avoid producing code w/ type errors #35907

Closed
@pq

Description

@pq

In the world of set-literals, an assist is presented on this snippet.

Set<String> s = new HashSet<String>();

If you perform it, and get:

Set<String> s = <String>{};

which provokes the following error:

error: The set literal type 'Set<String>' isn't of expected type 'HashSet<String>'. The set's type can be changed with an explicit generic type argument or by changing the element types. (strong_mode_invalid_cast_literal_set at ...)

As discussed in #57905, we should consider not providing the assist if it would produce errored results.

/cc @bwilkerson

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-quick-fixIssues with analysis server (quick) fixeslegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions