-
-
Save rintaro/b56487baafcfde7767c21193c540ffce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private protocol Factory {} | |
extension Factory { | |
init(_ s: Self) { | |
self = s | |
} | |
} | |
public class Base { | |
fileprivate init() { } | |
} | |
extension Base: Factory { | |
fileprivate convenience init(_ dummy: Int) { | |
self.init(Base()) | |
} | |
} | |
public func makeBase(a: Int) -> Base { | |
return Base(a) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sil_stage canonical | |
import Builtin | |
import Swift | |
import SwiftShims | |
// Base.deinit | |
sil @_T04test4BaseCfd : $@convention(method) (@guaranteed Base) -> @owned Builtin.NativeObject { | |
// %0 // users: %2, %1 | |
bb0(%0 : $Base): | |
debug_value %0 : $Base, let, name "self", argno 1 // id: %1 | |
%2 = unchecked_ref_cast %0 : $Base to $Builtin.NativeObject // user: %3 | |
return %2 : $Builtin.NativeObject // id: %3 | |
} // end sil function '_T04test4BaseCfd' | |
// Base.__deallocating_deinit | |
sil @_T04test4BaseCfD : $@convention(method) (@owned Base) -> () { | |
// %0 // users: %3, %2, %1 | |
bb0(%0 : $Base): | |
debug_value %0 : $Base, let, name "self", argno 1 // id: %1 | |
debug_value %0 : $Base, let, name "self", argno 1 // id: %2 | |
dealloc_ref %0 : $Base // id: %3 | |
%4 = tuple () // user: %5 | |
return %4 : $() // id: %5 | |
} // end sil function '_T04test4BaseCfD' | |
// makeBase(a:) | |
sil @_T04test8makeBaseAA0C0CSi1a_tF : $@convention(thin) (Int) -> @owned Base { | |
bb0(%0 : $Int): | |
%1 = alloc_ref $Base // users: %6, %7 | |
%2 = alloc_ref $Base // users: %8, %5, %4, %3 | |
debug_value %2 : $Base, let, name "self" // id: %3 | |
debug_value %2 : $Base, let, name "s", argno 1 // id: %4 | |
debug_value %2 : $Base, let, name "s", argno 1 // id: %5 | |
%6 = value_metatype $@thick Base.Type, %1 : $Base // user: %7 | |
dealloc_partial_ref %1 : $Base, %6 : $@thick Base.Type // id: %7 | |
return %2 : $Base // id: %8 | |
} // end sil function '_T04test8makeBaseAA0C0CSi1a_tF' | |
sil_vtable Base { | |
#Base.deinit!deallocator: _T04test4BaseCfD // Base.__deallocating_deinit | |
} | |
sil_witness_table private Base: Factory module test { | |
} | |
sil_default_witness_table hidden Factory { | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment