# Why is overriding a non-failable init with a failable init not allowed?

**URL:** <https://forums.swift.org/t/why-is-overriding-a-non-failable-init-with-a-failable-init-not-allowed/85543>\
**Category:** Using Swift\
**Tags:** init\
**Created:** [March 24, 2026, 3:29pm UTC](https://forums.swift.org/t/why-is-overriding-a-non-failable-init-with-a-failable-init-not-allowed/85543 "2026-03-24T15:29:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nevan](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@nevan](https://forums.swift.org/u/nevan)\
**Post date:** [March 24, 2026, 3:29pm UTC](https://forums.swift.org/t/why-is-overriding-a-non-failable-init-with-a-failable-init-not-allowed/85543/1 "2026-03-24T15:29:30Z")

</div>

Swift will allow me to override a failable initializer with a non-failable initializer but not the other way around:

```swift
class Animal {
    var name: String
    init(name: String) {
        self.name = name
    }
}
class Dog: Animal {
    var isGood = true
    // Error: Failable initializer 'init(name:)'
    // cannot override a non-failable initializer
    override init?(name: String) {
        if name.isEmpty { return nil }
        super.init(name: name)
    }
}

```

The docs cover this with a small note:

> **Note**
> 
> You can override a failable initializer with a nonfailable initializer but not the other way around.

What is the reason for this restriction?

Is it similar to not being allowed to override a read-write property with a read-only property, that the subclass can’t be more restrictive?

---

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [March 24, 2026, 3:40pm UTC](https://forums.swift.org/t/why-is-overriding-a-non-failable-init-with-a-failable-init-not-allowed/85543/2 "2026-03-24T15:40:53Z")

</div>

> [@nevan](#):
>
> What is the reason for this restriction?
> 
> Is it similar to not being allowed to override a read-write property with a read-only property, that the subclass can’t be more restrictive?

Yep, pretty much. Same reason you cannot override a method that returns some type T with one that returns a T?.

Because if you could, then what happens if you do this:

```swift
class Base {
  convenience init(x: Int) {
    self.init(y: x)
    print(self)
  }

  init(y: Int) {}
}

class Sub: Base {
  override init?(y: Int) { return nil }
}

Sub(x: 0) // what does this print?

```

---

<div class="post-metadata">

**Author:** ![maartene](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/maartene/32/42076_2.png) [@maartene](https://forums.swift.org/u/maartene)\
**Post date:** [March 24, 2026, 4:02pm UTC](https://forums.swift.org/t/why-is-overriding-a-non-failable-init-with-a-failable-init-not-allowed/85543/3 "2026-03-24T16:02:12Z")

</div>

The superclass’s initializer defines a contract for what callers can expect.

A non‑failable `init` promises to always produce an instance; a failable `init?` only promises to _maybe_ produce one.

When overriding, you’re allowed to strengthen this contract but not weaken it.

Overriding a failable initializer with a non‑failable one is fine: callers that are prepared for `nil` still work if they never actually get `nil`.

But overriding a non‑failable initializer with a failable one would break the contract, because callers relying on a guaranteed instance could suddenly receive `nil`.

(full disclosure: I used AI to help clarify my text in this post 🤖)

---

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [March 24, 2026, 5:58pm UTC](https://forums.swift.org/t/why-is-overriding-a-non-failable-init-with-a-failable-init-not-allowed/85543/4 "2026-03-24T17:58:10Z")

</div>

> [@maartene](#):
>
> A non‑failable `init` promises to always produce an instance; a failable `init?` only promises to _maybe_ produce one.

You can also think of a call to an initializer as being pretty much the same as calling a static method that either returns Self, or Self? (if it’s failable). A similar rule is enforced for method overrides, where you can override a method returning T? with one returning T but not vice versa.

Overriding a property works the same if the property is read only. If it has a setter, the override is required to have the same exact type.
