<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/existential-any-in-swift-and-when-it-becomes-required-fibagr0rl" -->

---
title: Existential any in Swift, and when it becomes required
description: The any keyword in Swift marks existential types—type-erased boxes that hold any value conforming to a protocol at runtime cost, unlike generics which the...
canonical: https://daily.dev/posts/existential-any-in-swift-and-when-it-becomes-required-fibagr0rl
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Existential any in Swift, and when it becomes required | daily.dev
og:description: The any keyword in Swift marks existential types—type-erased boxes that hold any value conforming to a protocol at runtime cost, unlike generics which the...
og:url: https://daily.dev/posts/existential-any-in-swift-and-when-it-becomes-required-fibagr0rl
og:image: https://api.daily.dev/og/posts/fIBAgR0rL.png
og:image:alt: Existential any in Swift, and when it becomes required
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Existential any in Swift, and when it becomes required

**[Sarunw](https://daily.dev/sources/sarunw)** · [@sarunw](https://daily.dev/sarunw) · 8 min read · 1 upvotes · 1 comments

## Summary

The any keyword in Swift marks existential types—type-erased boxes that hold any value conforming to a protocol at runtime cost, unlike generics which the compiler can specialize. SE-0335 introduced any in Swift 5.6 to make this cost visible, but Swift 6 language mode still does not require it, and there's no date for when it will. One case already warns without any flag: protocols with associated types or Self requirements, per SE-0309/SE-0335. Developers can opt in early via -enable-upcoming-feature ExistentialAny, escalate warnings to errors with -Werror, and use the Swift 6.4 @diagnose attribute to exempt individual files. The piece also covers when some is the better fix than any, and how SE-0521 in Swift 6.4 removes the need for parentheses around optional existentials.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://sarunw.com/posts/existential-any-in-swift>

## Questions this post answers

### Does Swift 6 language mode require the any keyword for existential types?

No, Swift 6 language mode does not require any before protocol names used as existential types; code without any compiles cleanly under -swift-version 6 with no error or warning. The Language Steering Group deliberately left this requirement out of Swift 6, and as of a May 2026 forum discussion there is still no version or date set for when any will become mandatory.

_Developers planning a Swift 6 migration can track any-related language changes on daily.dev before assuming the upgrade forces this rewrite._

### How do I enable warnings for missing any before existential protocol types in Swift?

Use the upcoming feature flag -enable-upcoming-feature ExistentialAny, which shipped in Swift 5.8, to make every bare protocol name in type position emit a warning with a fix-it that inserts any automatically. Once a module has no warnings left, add -Werror ExistentialAny to turn missing any into a build error so new instances cannot creep back in.

_Teams cleaning up existential usage across a Swift codebase can follow tooling changes like this on daily.dev._

### Why does Swift require parentheses around optional existential types like (any P)?, and when does that change?

Parentheses are required because the question mark binds more tightly than any, so any P? would be ambiguous without them; the compiler's fix-it currently wraps optional existentials as (any P)?. Swift 6.4 introduces SE-0521, which lets a trailing ? cover the whole existential so any P? becomes legal and the fix-it stops adding parentheses for single optional protocol types.

_Anyone migrating a large Swift codebase's optional protocol properties can watch for syntax cleanups like SE-0521 on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@agustinbarrientos** · 0 upvotes

> Are library authors already adding `any` before Swift makes it mandatory? I'd rather absorb that diff now than during a larger language migration.

## Similar posts on daily.dev

- [Swift Internals: Why any Protocol Can Be Slower Than Generics](https://daily.dev/posts/swift-internals-why-any-protocol-can-be-slower-than-generics-xmnlfjdqp) · Medium · 0 upvotes · 0 comments
- [some View? without parentheses in Swift 6.4](https://daily.dev/posts/some-view-without-parentheses-in-swift-6-4-c9swn8gkl) · Sarunw · 2 upvotes · 0 comments
- [Using Swift’s ‘some’ keyword beyond SwiftUI](https://daily.dev/posts/using-swift-s-some-keyword-beyond-swiftui-y1xqy9rzm) · Swift by Sundell · 0 upvotes · 0 comments
- [Erasing Existentials](https://daily.dev/posts/erasing-existentials-wccogvwj2) · Lobsters · 0 upvotes · 0 comments

---

Tags: [#performance](https://daily.dev/tags/performance), [#swift](https://daily.dev/tags/swift)

[View this post on daily.dev](https://daily.dev/posts/existential-any-in-swift-and-when-it-becomes-required-fibagr0rl)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Existential any in Swift, and when it becomes required","url":"https://daily.dev/posts/existential-any-in-swift-and-when-it-becomes-required-fibagr0rl","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/existential-any-in-swift-and-when-it-becomes-required-fibagr0rl"},"datePublished":"2026-09-09T17:16:12.209Z","dateModified":"2026-09-13T22:00:15.791Z","description":"The any keyword in Swift marks existential types—type-erased boxes that hold any value conforming to a protocol at runtime cost, unlike generics which the...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b50061c71a1f8911666cb7bc6c8d7a78?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b50061c71a1f8911666cb7bc6c8d7a78?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Sarunw","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Sarun Wongpatcharapakorn","url":"https://daily.dev/sarunw","image":"https://avatars.githubusercontent.com/u/795368?v=4","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":20}},"commentCount":1,"discussionUrl":"https://daily.dev/posts/existential-any-in-swift-and-when-it-becomes-required-fibagr0rl","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"performance,swift","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Sarunw","item":"https://daily.dev/sources/sarunw"},{"@type":"ListItem","position":3,"name":"Existential any in Swift, and when it becomes required"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/existential-any-in-swift-and-when-it-becomes-required-fibagr0rl","comment":[{"@type":"Comment","text":"Are library authors already adding any before Swift makes it mandatory? I’d rather absorb that diff now than during a larger language migration.","datePublished":"2026-09-10T22:19:13.947Z","url":"https://daily.dev/posts/fIBAgR0rL#c-OxJw05zOh","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/existential-any-in-swift-and-when-it-becomes-required-fibagr0rl#faq","mainEntity":[{"@type":"Question","name":"Does Swift 6 language mode require the any keyword for existential types?","acceptedAnswer":{"@type":"Answer","text":"No, Swift 6 language mode does not require any before protocol names used as existential types; code without any compiles cleanly under -swift-version 6 with no error or warning. The Language Steering Group deliberately left this requirement out of Swift 6, and as of a May 2026 forum discussion there is still no version or date set for when any will become mandatory. Developers planning a Swift 6 migration can track any-related language changes on daily.dev before assuming the upgrade forces this rewrite."}},{"@type":"Question","name":"How do I enable warnings for missing any before existential protocol types in Swift?","acceptedAnswer":{"@type":"Answer","text":"Use the upcoming feature flag -enable-upcoming-feature ExistentialAny, which shipped in Swift 5.8, to make every bare protocol name in type position emit a warning with a fix-it that inserts any automatically. Once a module has no warnings left, add -Werror ExistentialAny to turn missing any into a build error so new instances cannot creep back in. Teams cleaning up existential usage across a Swift codebase can follow tooling changes like this on daily.dev."}},{"@type":"Question","name":"Why does Swift require parentheses around optional existential types like (any P)?, and when does that change?","acceptedAnswer":{"@type":"Answer","text":"Parentheses are required because the question mark binds more tightly than any, so any P? would be ambiguous without them; the compiler's fix-it currently wraps optional existentials as (any P)?. Swift 6.4 introduces SE-0521, which lets a trailing ? cover the whole existential so any P? becomes legal and the fix-it stops adding parentheses for single optional protocol types. Anyone migrating a large Swift codebase's optional protocol properties can watch for syntax cleanups like SE-0521 on daily.dev."}}]}
```

