Files
swift-mirror/test/SILGen/witnesses_inheritance.swift
Michael Gottesman 75ea31dba9 Turn on +0 self by default.
The only caveat is that:

1. We do not properly recognize when we have a let binding and we
perform a guaranteed dynamic call. In such a case, we add an extra
retain, release pair around the call. In order to get that case I will
need to refactor some code in Callee. I want to make this change, but
not at the expense of getting the rest of this work in.

2. Some of the protocol witness thunks generated have unnecessary
retains or releases in a similar manner.

But this is a good first step.

I am going to send a large follow up email with all of the relevant results, so
I can let the bots chew on this a little bit.

rdar://19933044

Swift SVN r27241
2015-04-12 22:23:37 +00:00

43 lines
1.5 KiB
Swift

// RUN: %target-swift-frontend -emit-silgen %s | FileCheck %s
protocol Fooable {
func foo()
static func class_foo()
}
protocol Barrable : Fooable {
func bar()
static func class_bar()
}
class X : Fooable {
func foo() {}
class func class_foo() {}
}
// -- Derived class conforms to a refined protocol
class Y : X, Barrable {
func bar() {}
// CHECK-NOT: sil hidden [transparent] [thunk] @_TTWC21witnesses_inheritance1YS_7FooableS_FS1_3fooUS1___fQPS1_FT_T_
class func class_bar() {}
// CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWC21witnesses_inheritance1YS_8BarrableS_ZFS1_9class_barUS1___fMQPS1_FT_T_
}
class A : Fooable {
func foo() {}
func bar() {}
class func class_foo() {}
class func class_bar() {}
}
// -- Derived class conforms to a refined protocol using its base's methods
class B : A, Barrable {}
// CHECK-NOT: sil hidden [transparent] [thunk] @_TTWC21witnesses_inheritance1BS_7FooableS_FS1_3fooUS1___fQPS1_FT_T_
// CHECK-NOT: sil hidden [transparent] [thunk] @_TTWC21witnesses_inheritance1BS_7FooableS_ZFS1_9class_fooUS1___fMQPS1_FT_T_
// CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWC21witnesses_inheritance1BS_8BarrableS_FS1_3barUS1___fQPS1_FT_T_
// CHECK: upcast {{%.*}} : $*B to $*A
// CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWC21witnesses_inheritance1BS_8BarrableS_ZFS1_9class_barUS1___fMQPS1_FT_T_
// CHECK: upcast {{%.*}} : $@thick B.Type to $@thick A.Type
// Add tests to make sure that we handle address only case correctly.