Files
swift-mirror/test/SILOptimizer/specialize_anyobject.swift
Michael Gottesman 1b97c0393c [ownership] Loosen restrictions around what we specialize and add generic specialization tests behind a flag.
The idea is that this will let me remove these assertions that were in place to
make sure we were really conservative around specializing ownership code. For me
to remove that I need to be able to actually test out this code (since I think
there are some code paths where this will trigger in other parts of the compiler
now).

So to work out the kinks, I added a flag that allows for the generic specializer
to process ownership code and translated most of the .sil test cases/fixed any
bugs that I found. This hopefully will expose anything that is missing.

NOTE: I have not enabled the generic specializer running in ownership in the
pipeline. This is just a step in that direction by adding tests/etc.
2020-07-03 02:54:19 -07:00

23 lines
644 B
Swift

// RUN: %target-swift-frontend -module-name specialize_anyobject -O -sil-inline-threshold 0 -emit-sil -primary-file %s | %FileCheck %s
// rdar://problem/20338028
protocol PA: class { }
protocol PB { associatedtype B: PA }
class CA: PA { }
class CB: PB { typealias B = CA }
struct S<A: PB> {
@_transparent
func crash() -> Bool {
let a: A.B? = nil
return a === a
}
}
// CHECK-LABEL: sil hidden @$s20specialize_anyobject6callit{{[_0-9a-zA-Z]*}}F
func callit(s: S<CB>) {
// CHECK: function_ref @$ss3eeeoiySbyXlSg_ABtF : $@convention(thin) (@guaranteed Optional<AnyObject>, @guaranteed Optional<AnyObject>) -> Bool
s.crash()
}