Skip to content

Implicitly-opened existentials after explicit erasure require extra parentheses #63953

@JessyCatterwaul

Description

@JessyCatterwaul

Given

protocol P { }
struct S: P { }
func ƒ(_: some P) { }
let p: any P = S()

These compile:

ƒ(p)
ƒ((S() as any P))

This produces the error "Type 'any P' cannot conform to 'P'":

ƒ(S() as any P)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfexistentialsFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesexpressionsFeature: expressionsimplicit existential openingFeature → existentials: implicit opening of existentials when passed to parameters of generic typenot a bugResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer errorswift 5.9type checkerArea → compiler: Semantic analysisunexpected errorBug: Unexpected error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions