mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
In such a case the overridden function gets a new separate vtable entry. With this change, the computation of class method callees only uses the information in sil_vtables (instead of ClassDecl members). Fixes a compiler crash in various optimization passes. rdar://problem/56146633
42 lines
721 B
Swift
42 lines
721 B
Swift
// RUN: %target-swift-frontend -O %s -emit-ir -o /dev/null
|
|
|
|
// Check that we don't crash here.
|
|
|
|
enum E<T> {
|
|
case A
|
|
case B(T)
|
|
}
|
|
|
|
public protocol P {
|
|
associatedtype A
|
|
}
|
|
|
|
internal class Base<T: P> {
|
|
func foo() -> E<T.A> {
|
|
return .A
|
|
}
|
|
}
|
|
|
|
struct Outer<T: P> where T.A == Int {
|
|
private class Inner : Base<T> {
|
|
|
|
// This overridden function has a different ABI than the base implementation.
|
|
// The BasicCalleeAnalysis put both methods in the callee list, which let
|
|
// some optimizations crash.
|
|
override func foo() -> E<T.A> {
|
|
return .A
|
|
}
|
|
}
|
|
}
|
|
|
|
@inline(never)
|
|
func getit<T: P>(_ t: T) -> Base<T> {
|
|
return Base<T>()
|
|
}
|
|
|
|
public func testit<T: P>(_ t: T) {
|
|
let b = getit(t)
|
|
b.foo()
|
|
}
|
|
|