EnclosingSelf Compiler Crash

When building this, the compiler crashes with cryptic messages.

just swift test the branch feature/keypath-observer to reproduce, or check the PR's CI

Edit: It seems to be a problem when building in tests

Basically, the crashing change ist adding this to the property wrapper @Fusing:


  public static subscript<EnclosingSelf: ObservableObject>(
    _enclosingInstance object: EnclosingSelf,
    wrapped wrappedKeyPath: ReferenceWritableKeyPath<EnclosingSelf, T>,
    storage storageKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Fusing<T>>
  ) -> T {
    get {
      if object[keyPath: storageKeyPath].objectWillChange == nil {
        object[keyPath: storageKeyPath].objectWillChange = object.objectWillChange as? ObservableObjectPublisher
      }
      return object[keyPath: storageKeyPath].wrappedValue
    }

    set {
      (object.objectWillChange as? ObservableObjectPublisher)?.send()

      if object[keyPath: storageKeyPath].objectWillChange == nil {
        object[keyPath: storageKeyPath].objectWillChange = object.objectWillChange as? ObservableObjectPublisher
      }

      object[keyPath: storageKeyPath].wrappedValue = newValue
    }
  }