# \[Pitch\] Metatype Keypaths

**URL:** <https://forums.swift.org/t/pitch-metatype-keypaths/70767>\
**Category:** Pitches\
**Tags:** keypaths, keypath\
**Created:** [March 18, 2024, 9:19pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767 "2024-03-18T21:19:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![amritpan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/amritpan/32/39281_2.png) [@amritpan](https://forums.swift.org/u/amritpan)\
**Post date:** [March 18, 2024, 9:19pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/1 "2024-03-18T21:19:16Z")

</div>

Hello everyone,

The following is a pitch for metatype keypaths in the Swift language. We welcome any feedback or questions about this pitch!

* * *

# [Pitch] Metatype Keypaths

- Proposal: SE-NNNN
- Authors: [Amritpan Kaur](https://github.com/amritpan), [Pavel Yaskevich](https://github.com/xedin)
- Review Manager: TBD
- Status: Awaiting Implementation

## Introduction

Key path expressions access properties dynamically. They are declared with a concrete root type and one or more key path components that define a path to a resulting value via the type’s properties, subscripts, optional-chaining expressions, forced unwrapped expressions, or self. This proposal expands key path expression access to include static properties of a type, i.e., metatype keypaths.

## Motivation

Metatype keypaths were briefly explored in the pitch for [SE-0254](https://forums.swift.org/t/pitch-static-and-class-subscripts/21850) and the [proposal](https://github.com/apple/swift-evolution/blob/main/proposals/0254-static-subscripts.md#metatype-key-paths) later recommended them as a future direction. Allowing key path expressions to directly refer to static properties has also been discussed on the Swift Forums for database lookups when used [in conjunction with @dynamicMemberLookup](https://forums.swift.org/t/dynamic-key-path-member-lookup-cannot-refer-to-static-member/30212) and as a way to avoid verbose hacks like [referring to a static property through another computed property](https://forums.swift.org/t/key-path-cannot-refer-to-static-member/28055). Supporting metatype keypaths in the Swift language will address these challenges and improve language semantics.

## Proposed solution

We propose to allow keypath expressions to define a reference to static properties. The following usage, which currently generates a compiler error, will be allowed as valid Swift code.

```swift
struct Bee {
  static let name = "honeybee"
}

let kp = \Bee.Type.name

```

## Detailed design

### Metatype syntax

Keypath expressions where the first component refers to a static property will include `.Type` on their root types stated in the key path contextual type or in the key path literal. For example:

```swift
struct Bee {
  static let name = "honeybee"
}

let kpWithContextualType: KeyPath<Bee.Type, String> = \.name // key path contextual root type of Bee.Type
let kpWithLiteral = \Bee.Type.name // key path literal \Bee.Type

```

Attempting to write a metatype keypath without including `.Type` will trigger a diagnostic with a fix-it that recommends adding `.Type`:

```swift
let kpWithLiteral = \Bee.name // cannot refer to static member `name` on instance `Bee` without `.Type`.

```

Keypath expressions where the component referencing a static property is not the first component do not require `.Type`:

```swift
struct Species {
  static let isNative = true
}

struct Wasp {
  var species: Species.Type {Species.self}
}

let kpSecondComponentIsStatic = \Wasp.species.isNative

```

### Access semantics

Immutable static properties will form the read-only keypaths just like immutable instance properties.

```swift
struct Tip {
  static let isIncluded = True
  let isVoluntary = False
}

let kpStaticImmutable: KeyPath<Tip.Type, Bool> = \.isIncluded 
let kpInstanceImmutable: KeyPath<Tip, Bool> = \.isVoluntary 

```

However, unlike instance members, keypaths to mutable static properties will conform to `ReferenceWritableKeyPath` because metatypes are reference types.

```swift
struct Tip {
  static var total = 0
  var flatRate = 20
}

let kpStaticMutable: ReferenceWriteableKeyPath<Tip.Type, Int> = \.total 
let kpInstanceMutable: WriteableKeyPath<Tip, Int> = \.flatRate 

```

## Effect on source compatibility

This feature breaks source compatibility for key path expressions that reference static properties after subscript overloads. For example, the compiler cannot differentiate between subscript keypath components by return type in the following:

```swift
struct S {
  static var count: Int { 42 }
}

struct Test {
  subscript(x: Int) -> String { "" }
  subscript(y: Int) -> S.Type { S.self }
}

let kpViaSubscript = \Test.[42] // fails to typecheck

```

This keypath does not specify a contextual type, without which the key path value type is unknown. To form a keypath to the metatype subscript and return an `Int`, we can specify a contextual type with a value type of `S.Type` and chain the metatype keypath:

```swift
let kpViaSubscript: KeyPath<Test, S.Type> = \Test.[42]
let kpAppended = kpViaSubscript.appending(path: \.count)

```

## Implications on adoption

Metatype keypaths are not back-deployable.

Implementation of metatype keypaths requires changes to the `KeyPath` type in the Swift standard library and a new runtime is necessary to take full advantage of this feature. Older compilers will continue to be supported but the correctness of operator comparisons (eg. `Equatable` or `Hashable`) will not be guaranteed for keypath references to static properties.

For example, `Bank `is a library compiled with Swift 5.10 or older:

```swift
public struct Bank {
  public static var checking: Double = 10.00
  public static var savings: Double = 200.00
}

```

Lets use `Bank`’s static properties in libraries compiled with the latest compiler that includes the metatype keypath implementation:

```swift
//--- UIManager.swift
import Bank
public let checkingUI = \Bank.Type.checking
public let savingsUI = \Bank.Type.savings

//--- StorageManager.swift
import Bank
public let checkingStorage = \Bank.Type.checking
public let savingsStorage = \Bank.Type.savings

```

When the above keypaths are compared elsewhere in the codebase, they may not reliably produce correct results unless the `Bank` library is updated to support the metatype keypath feature:

```swift
print(checkingUI == checkingStorage) // prints false, should print true
print(checkingUI != savingsStorage) // prints false, should print true

```

To leverage metatype keypaths effectively, library and framework binaries will need to be recompiled with a compiler that includes this implementation.

## Future directions

### Key Paths to Enum cases

Adding language support for read-only key paths to enum cases has been widely discussed on the [Swift Forums](https://forums.swift.org/t/enum-case-key-paths-an-update/68436) but has been left out of this proposal as this merits a separate discussion around [syntax design and implementation concerns](https://forums.swift.org/t/enum-case-keypaths/60899/32).

Since references to enum cases must be metatypes, extending keypath expressions to include references to metatypes will hopefully bring the Swift language closer to adopting keypaths to enum cases in a future pitch.

## Acknowledgments

Thank you to Joe Groff for providing pivotal feedback on this pitch and its possible implementation and to Becca Royal-Gordon for an insightful discussion around the anticipated hurdles in implementing this feature.

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [March 18, 2024, 9:30pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/2 "2024-03-18T21:30:14Z")

</div>

> [@amritpan](#):
>
> The compiler cannot differentiate between subscript key path components by return type. To circumvent this, we can declare a keypath with components up to the subscript and then compose a new keypath that appends the static reference component to that keypath

If this works, why doesn’t it apply to the full key-path in one expression? That is, there already must be a rule preferring instance key path elements over static ones; isn’t that sufficient here?

> [@amritpan](#):
>
> ```swift
> print(checkingUI == checkingStorage) // prints true, should print false
> print(checkingUI != savingsStorage) // prints true, should print false
> 
> ```

Are these comments correct? I’d want the two “checking” ones to compare equal and the two “savings” ones to compare unequal, and I’d expect a naive, backwards-compatible implementation to treat them both as unequal for now.

* * *

> **QoI suggestion**
>
> If I forget to write `.Type`, but the key path is otherwise unambiguous, can I get a nice fix-it?

---

<div class="post-metadata">

**Author:** ![amritpan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/amritpan/32/39281_2.png) [@amritpan](https://forums.swift.org/u/amritpan)\
**Post date:** [March 19, 2024, 6:23pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/3 "2024-03-19T18:23:33Z")

</div>

> [@jrose](#):
>
> QoI suggestion
> 
> If I forget to write `.Type`, but the key path is otherwise unambiguous, can I get a nice fix-it?

Yes! I have added a diagnostic that should appear when `.Type` is forgotten to the pitch.

The operator results were a mistype. Both will incorrectly print false if a library is using an older compiler. I have updated that as well.

> If this works, why doesn’t it apply to the full key-path in one expression? That is, there already must be a rule preferring instance key path elements over static ones; isn’t that sufficient here?

There is no rule that prefers instance members over static members for forming keypaths to subscripts, which is why we have this issue. I've updated this section to fix an error as well. Essentially, this will not typecheck:

`let kpViaSubscript = \Test.[42]`

as the solver is unable to pick between the two subscript options because we don't know the expected value type of this key path expression. So it does not pick the subscript with the `String` return overload. We could write:

`let kpViaStringSubscript: KeyPath<Test, String> = \Test.[42]`

to help the typechecker pick the `String` subscript because the key path value type is now `String`. If we need the `Int` value instead, we could specify a contextual type that includes the metatype as the value type:

`let kpViaMetatypeSubscript: KeyPath<Test, S.Type> = \Test.[42]`

then chain the `Int` returning component:

`let kpAppended = kpViaMetatypeSubscript.appending(path: \.count)`

or in one go:

`let kpViaMetatypeSubscript: KeyPath<Test, Int> = \Test.[42].count`

---

<div class="post-metadata">

**Author:** ![gwendal.roue](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gwendal.roue/32/13992_2.png) [@gwendal.roue](https://forums.swift.org/u/gwendal.roue)\
**Post date:** [March 19, 2024, 7:18pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/4 "2024-03-19T19:18:48Z")

</div>

Thank you for the pitch!

I'm not sure I understand the "Implications on adoption" section correctly. It looks that metatype keypaths will have an observable behavior of Equatable that will depend on the operating system?

Also, one of the linked use cases mentions the interaction of metatype keypaths with [SE-0252 Key Path Member Lookup](https://github.com/apple/swift-evolution/blob/master/proposals/0252-keypath-dynamic-member-lookup.md). Does the proposal include support for the [mentioned use case](https://forums.swift.org/t/key-path-cannot-refer-to-static-member/28055#a-solution-se-0252-and-key-paths-to-static-members-2)?

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [March 19, 2024, 7:40pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/5 "2024-03-19T19:40:08Z")

</div>

> [@amritpan](#):
>
> Both will incorrectly print false if a library is using an older compiler.

I think this is _still_ wrong, the `==` one will incorrectly (/ conservatively) print false, but the `!=` will _correctly_ print false, just for the wrong reason. Or am I still misunderstanding?

---

<div class="post-metadata">

**Author:** ![benpious](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/benpious/32/17944_2.png) [@benpious](https://forums.swift.org/u/benpious)\
**Post date:** [March 19, 2024, 7:45pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/6 "2024-03-19T19:45:46Z")

</div>

This looks great, it's something that I've found myself needing many times over the years.

Also, strong +1 to exploring key paths to enum cases as a future direction.

---

<div class="post-metadata">

**Author:** ![amritpan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/amritpan/32/39281_2.png) [@amritpan](https://forums.swift.org/u/amritpan)\
**Post date:** [March 19, 2024, 8:16pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/7 "2024-03-19T20:16:51Z")

</div>

> [@jrose](#):
>
> but the `!=` will _correctly_ print false, just for the wrong reason

Could you explain this further? I may be missing something obvious here, but comparing:

```swift
checkingUI != savingsStorage

```

will return `true` if all of the libraries are using the latest compiler, but may return `false` if the library where the static properties being referred is using a compiler without this implementation.

Edit: Are we referring to how Equatable flips the result for `==` and returns it for `!=` ?

---

<div class="post-metadata">

**Author:** ![amritpan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/amritpan/32/39281_2.png) [@amritpan](https://forums.swift.org/u/amritpan)\
**Post date:** [March 19, 2024, 8:23pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/8 "2024-03-19T20:23:59Z")

</div>

> [@gwendal.roue](#):
>
> I'm not sure I understand the "Implications on adoption" section correctly. It looks that metatype keypaths will have an observable behavior of Equatable that will depend on the operating system?

Yes, or if a library has not been updated and was compiled with a compiler that doesn't include this implementation but is used in a codebase that is regularly updated/recompiled.

> [@gwendal.roue](#):
>
> Also, one of the linked use cases mentions the interaction of metatype keypaths with [SE-0252 Key Path Member Lookup](https://github.com/apple/swift-evolution/blob/master/proposals/0252-keypath-dynamic-member-lookup.md). Does the proposal include support for the [mentioned use case](https://forums.swift.org/t/key-path-cannot-refer-to-static-member/28055#a-solution-se-0252-and-key-paths-to-static-members-2)?

Yes. This feature will allow us to refer to keypaths to static members from types with the `@dynamicMemberLook` attribute, like:

```swift
struct Weekday {
    static let day = "Monday"
}

@dynamicMemberLookup
struct StaticExample<T> {
    subscript<U>(dynamicMember keyPath: KeyPath<T.Type, U>) -> U {
        return T.self[keyPath: keyPath]
    }
}

let _ = StaticExample<Weekday>().day

```

---

<div class="post-metadata">

**Author:** ![gwendal.roue](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gwendal.roue/32/13992_2.png) [@gwendal.roue](https://forums.swift.org/u/gwendal.roue)\
**Post date:** [March 19, 2024, 8:34pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/9 "2024-03-19T20:34:50Z")

</div>

> [@amritpan](#):
>
> > It looks that metatype keypaths will have an observable behavior of Equatable that will depend on the operating system?
> 
> Yes, or if a library has not been updated and was compiled with a compiler that doesn't include this implementation but is used in a codebase that is regularly updated/recompiled.

Is there any precedent of previous compiler features that were shipped in this odd way in the past? If so, experience about the problems people have met would be interesting to hear. If not... Doesn't this sound _concerning_ to anyone?

> > Does the proposal include support for [...] SE-0252?
> 
> Yes

That's good to hear 🙂

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [March 19, 2024, 8:51pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/10 "2024-03-19T20:51:03Z")

</div>

These are two different properties, referred to from two different libraries. On an OS with perfect information, they should be unequal because they are distinct. On an OS that has to treat them as opaque functions (like paths through computed properties), they should _also_ be unequal because they _might_ be distinct. So, shouldn’t we get the same answer either way?

---

<div class="post-metadata">

**Author:** ![arennow](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/arennow/32/27261_2.png) [@arennow](https://forums.swift.org/u/arennow)\
**Post date:** [March 20, 2024, 1:41pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/11 "2024-03-20T13:41:27Z")

</div>

I forget about this feature gap and then run into it every few months. This would be a very welcome improvement!

---

<div class="post-metadata">

**Author:** ![Ian\_Keen](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ian_keen/32/18492_2.png) [@Ian\_Keen](https://forums.swift.org/u/Ian_Keen)\
**Post date:** [March 20, 2024, 11:27pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/12 "2024-03-20T23:27:29Z")

</div>

+1 very exciting, I’ve been wanting this for a long time to build a static level version of this: [Combined: A type composed of other types (potential alternative to my Partial\<T\> type) · GitHub](https://gist.github.com/IanKeen/890910d344d9cab9b2ab2ec409370e14)

---

<div class="post-metadata">

**Author:** ![beccadax](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/beccadax/32/34217_2.png) [@beccadax](https://forums.swift.org/u/beccadax)\
**Post date:** [March 21, 2024, 9:37pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/13 "2024-03-21T21:37:23Z")

</div>

> [@gwendal.roue](#):
>
> Is there any precedent of previous compiler features that were shipped in this odd way in the past?

There are all sorts of strange limitations in back deployment, but they aren't normally considered to be a matter for Evolution.

> [@gwendal.roue](#):
>
> Doesn't this sound _concerning_ to anyone?

A little, but the alternative is to _entirely_ limit use of metatype key paths to sufficiently new library compiler versions (which also means sufficiently new OS minimum deployment targets for key paths to OS types) _solely_ to make sure the `Equatable` conformance handles key paths created in different places correctly. That seems like a pretty high price to pay for niche functionality—how often do you use `KeyPath`s as dictionary keys/set elements vs. all of their other uses (and how often do you rely on this working even for key paths generated in different modules)?

---

<div class="post-metadata">

**Author:** ![gwendal.roue](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gwendal.roue/32/13992_2.png) [@gwendal.roue](https://forums.swift.org/u/gwendal.roue)\
**Post date:** [March 22, 2024, 12:45am UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/14 "2024-03-22T00:45:26Z")

</div>

Thank you for the rationale. Indeed the use cases I envision for metatype keypaths don't use their equitability. I hope the people who do read this forum thread.

---

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [March 22, 2024, 1:49am UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/15 "2024-03-22T01:49:53Z")

</div>

> [@beccadax](#):
>
> That seems like a pretty high price to pay for niche functionality—how often do you use `KeyPath`s as dictionary keys/set elements vs. all of their other uses (and how often do you rely on this working even for key paths generated in different modules)?

> [@gwendal.roue](#):
>
> Indeed the use cases I envision for metatype keypaths don't use their equitability. I hope the people who do read this forum thread.

i can think of many use cases for `Equatable` on key paths, but they are all poorly-thought out attempts to wrap key paths in `CodingKey`(s). this is usually motivated by a desire to avoid SwiftSyntax macros.

please, let us make SwiftSyntax macros usable, instead of trying to match on key paths.

---

<div class="post-metadata">

**Author:** ![rvsrvs](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rvsrvs/32/5270_2.png) [@rvsrvs](https://forums.swift.org/u/rvsrvs)\
**Post date:** [March 22, 2024, 2:50am UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/16 "2024-03-22T02:50:01Z")

</div>

> [@beccadax](#):
>
> That seems like a pretty high price to pay for niche functionality—how often do you use `KeyPath`s as dictionary keys/set elements vs. all of their other uses (and how often do you rely on this working even for key paths generated in different modules)?

fwiw, I recently began a major effort on a large swiftui app to use keypaths as dictionary keys as the basis for a big improvement in styling. not sure that statics matter that much to me but i'm pretty enamored of the possibilities we're bringing to light with the technique.

---

<div class="post-metadata">

**Author:** ![RobertKoval](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/robertkoval/32/12501_2.png) [@RobertKoval](https://forums.swift.org/u/RobertKoval)\
**Post date:** [March 22, 2024, 6:29pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/17 "2024-03-22T18:29:45Z")

</div>

The first thought after reading the title was "Finally enum support?" but ... no, unfortunately. 🥲

---

<div class="post-metadata">

**Author:** ![amritpan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/amritpan/32/39281_2.png) [@amritpan](https://forums.swift.org/u/amritpan)\
**Post date:** [April 25, 2024, 3:38pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/18 "2024-04-25T15:38:59Z")

</div>

I'd like to share two updates to this pitch that we discovered after working through the implementation:

1. Metatype keypaths are back deployable. Modules/libraries using older compilers will not need to re-compile to see correct operator overloading results. (The entire Implications on adoption section is no longer an issue).

2. Diagnostics will show an error message if `.Type` is left out of a metatype keypath reference (where the first component is a static property), but a fix-it is not possible at this time. We'll see the following:

```swift
let kpWithLiteral = \Bee.name // error: static member 'name' cannot be used on instance of type 'Bee'

```

I will be leaving the pitch here as is but these discoveries will be integrated into the proposal draft.

---

<div class="post-metadata">

**Author:** ![James\_Dempsey](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/james_dempsey/32/14336_2.png) [@James\_Dempsey](https://forums.swift.org/u/James_Dempsey)\
**Post date:** [April 25, 2024, 8:42pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/19 "2024-04-25T20:42:38Z")

</div>

> [@beccadax](#):
>
> > [@gwendal.roue](#):
> >
> > Doesn't this sound _concerning_ to anyone?
> 
> A little, but the alternative is to _entirely_ limit use of metatype key paths to sufficiently new library compiler versions (which also means sufficiently new OS minimum deployment targets for key paths to OS types) _solely_ to make sure the `Equatable` conformance handles key paths created in different places correctly. That seems like a pretty high price to pay for niche functionality—how often do you use `KeyPath`s as dictionary keys/set elements vs. all of their other uses (and how often do you rely on this working even for key paths generated in different modules)?

I think it is strange to introduce the idea of types in the standard library that implement fundamental protocols like `Equatable` and `Hashable` that don't work correctly without providing some kind of a warning.

It seems completely reasonable to have sets of key paths or dictionaries keyed by key paths. The fact that KeyPath is Hashable implies it is intended to be used as a Hashable type.

As a developer, seeing KeyPath implements Equatable and Hashable, how would I have any idea that it may or may not _really_ be properly equatable and hashable, depending on which type is at the root of the key path and how that type was compiled?

I understand the rationale for trying to avoid entirely limiting the use of metatype key paths for types in libraries compiled with older compiler versions.

Is there any way that diagnostics could be generated for uses of Equatable and Hashable that are going to be incorrect?

---

<div class="post-metadata">

**Author:** ![amritpan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/amritpan/32/39281_2.png) [@amritpan](https://forums.swift.org/u/amritpan)\
**Post date:** [April 25, 2024, 9:17pm UTC](https://forums.swift.org/t/pitch-metatype-keypaths/70767/20 "2024-04-25T21:17:03Z")

</div>

> 1. Metatype keypaths are back deployable. Modules/libraries using older compilers will not need to re-compile to see correct operator overloading results. (The entire Implications on adoption section is no longer an issue).

I think my update here was not clear. The original pitch assumed that we would not be able to guarantee correct results for Equatable/Hashable comparisons for static properties declared in modules/libraries that were compiled with a compiler that did not include this feature's implementation.

Since implementing this feature, we have discovered that this is not true. Metatype keypaths will return correct results for Equatable/Hashable even if the static property is declared in a module compiled with an older compiler.

> Is there any way that diagnostics could be generated for uses of Equatable and Hashable that are going to be incorrect?

So these will not be necessary. As a developer, you will be able to use metatype keypaths with the assurance that they will return correct results for operator comparisons just like any other keypath.

[Next page](https://forums.swift.org/t/pitch-metatype-keypaths/70767.md?page=2)
