// RUN: %target-swift-frontend -primary-file %s -emit-ir // https://github.com/apple/swift/issues/47048 protocol P: AnyObject {} protocol Foo { // The compiler crash goes away if you remove the P constraint on this associated type associatedtype ObjectType: P } protocol UpcastHelper { associatedtype Sub: Foo associatedtype Super: Foo // ObjectIdentifier(object) == ObjectIdentifier(Self.cast(object)) static func cast(_ object: Sub.ObjectType) -> Super.ObjectType } struct AnyFoo: Foo { typealias ObjectType = Object class Base {} final class Derived: Base where Helper.Super == AnyFoo { init(_ foo: Helper.Sub) { self.foo = foo } let foo: Helper.Sub } init (foo: Helper.Sub, helper: Helper.Type) where Helper.Super == AnyFoo { // This is the expression that causes the crash _ = Derived(foo) } }