Skip to content

any cannot be used for reference type parameters like some can #66165

Open
@JessyCatterwaul

Description

@JessyCatterwaul

The last line doesn't compile.

protocol Protocol { }
final class Class { }
actor Actor { }
func ƒ(_: some Class & Protocol, _: some Actor & Protocol) { }
func ƒ(_: some Class, _: some Actor) { }
func ƒ(_: any Class & Protocol, _: any Actor & Protocol) { }
func ƒ(_: any Class, _: any Actor) { }

I think it would be better if it wouldn't compile for some, either, but they should both behave similarly regardless of what that behavior is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.classFeature → type declarations: Class declarationscompilerThe Swift compiler itselfexistentialsFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesnot a bugResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer errorswift 5.9type checkerArea → compiler: Semantic analysistypesFeature: typesunexpected errorBug: Unexpected error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions