Skip to content

Instantly share code, notes, and snippets.

@mbrandonw
Last active June 24, 2022 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbrandonw/abb100582061fa16c7f7fcebb7927b3a to your computer and use it in GitHub Desktop.
Save mbrandonw/abb100582061fa16c7f7fcebb7927b3a to your computer and use it in GitHub Desktop.

Implicitly opened existentials do not work in playgrounds

FB10447228

Running the following code in Swift playgrounds (in Xcode):

func open<A: Equatable>(_ a: A) {}

func existentialFun(_ value: Any) {
  guard let value = value as? any Equatable
  else { return }
  open(value)
}

Produces the following error:

error: type 'any Equatable' cannot conform to 'Equatable’

But does compile in a regular Swift project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment