Skip to content

[SR-11920] Bogus Warning When Invalid Protocol is Used in Existential Position #54339

@CodaFi

Description

@CodaFi
Previous ID SR-11920
Radar rdar://problem/57715257
Original Reporter @CodaFi
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug, TypeChecker
Assignee None
Priority Medium

md5: 6a0184667d6dc91a903498b162ead4ab

Issue Description:

protocol P { associatedtype T }
class C : P {}

func i<T: C>(_ x : T?) -> Bool {
  //  warning: checking a value with optional type 'T?' against dynamic type 'P' succeeds whenever the value is non-nil; did you mean to use '!= nil'?
  return x is P
}

This warning's text makes no sense. `P` is not a dynamic protocol and may not be used in existential position. The wording of this diagnostic needs to be amended not to make reference to dynamism when a protocol may not be used in existential position.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationgood first issueGood for newcomerstype checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions