{"id":1231,"date":"2020-03-24T18:26:31","date_gmt":"2020-03-24T09:26:31","guid":{"rendered":"https:\/\/it1.jp\/?p=1231"},"modified":"2020-03-24T20:04:51","modified_gmt":"2020-03-24T11:04:51","slug":"post-1231","status":"publish","type":"post","link":"https:\/\/it1.jp\/?p=1231","title":{"rendered":"\u30ad\u30e3\u30b9\u30c8\u3092\u3059\u308b\u6642\u3001\u88cf\u5074\u3067\u4f55\u304c\u8d77\u3053\u3063\u3066\u3044\u308b\u306e\u304b\uff1f\u3010Swift\u3011"},"content":{"rendered":"<p>\u5148\u65e5\u3001\u30ad\u30e3\u30b9\u30c8\uff08Type Casting\uff09\u306b\u3064\u3044\u3066\u539f\u70b9\u7684\u306a\u7591\u554f\u306b\u3076\u3064\u304b\u3063\u305f\u3002<\/p>\n<div class=\"bgBox\"><code>let a: Int = 28<\/code><br \/>\n<code>let b = a as Any<\/code><br \/>\n<code>let c = b as! Int<\/code><br \/>\n<code>print(c - 1) \/\/ 27<\/code><\/div>\n<p>\u3053\u306e\u3088\u3046\u306bInt\u578b\u3067\u5b9a\u7fa9\u3057\u305f\u5024\u3092\u3001Any\u578b\u306b\u30ad\u30e3\u30b9\u30c8\u3057\u3001\u518d\u5ea6Int\u578b\u306b\u30ad\u30e3\u30b9\u30c8\u3057\u305f\u3068\u3059\u308b\u3002<br \/>\n\u3053\u306e\u6642\u3001Int\u578b\u3078\u306eforce cast\u306f\u7121\u4e8b\u6210\u529f\u3057\u3001\u5909\u6570 c \u306f\u6574\u6570\u578b\u3068\u3057\u3066\u6271\u3046\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<\/p>\n<p>\u4e00\u898b\u3042\u308a\u304c\u305f\u3044\u6319\u52d5\u306b\u3082\u898b\u3048\u308b\u53cd\u9762\u3001Any\u578b\u3078\u306e\u30ad\u30e3\u30b9\u30c8\u3092\u884c\u3063\u305f\u5f8c\u306b\u3082\u5909\u6570 b \u304cInt\u578b\u3068\u3057\u3066\u306e\u5024\u306e\u60c5\u5831\u3092\u4fdd\u6301\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u95a2\u3057\u3066\u4e0d\u601d\u8b70\u306b\u601d\u3063\u305f\u3002<\/p>\n<p>\u3053\u308c\u306fSwift\u306e\u8a00\u8a9e\u4ed5\u69d8\u3068\u3057\u3066\u4e00\u4f53\u3069\u306e\u3088\u3046\u306a\u4ed5\u7d44\u307f\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3060\u308d\u3046\u304b\u3002Swift\u3068\u3044\u3046\u8a00\u8a9e\u306b\u304a\u3044\u3066\u578b\u30b7\u30b9\u30c6\u30e0\u5468\u8fba\u306e\u30c7\u30fc\u30bf\u304c\u3069\u306e\u3088\u3046\u306b\u8868\u73fe\u3055\u308c\u3066\u3044\u308b\u306e\u304b\u3001\u305d\u3057\u3066\u5b9f\u884c\u6642\u306e\u578b\u306e\u632f\u308b\u821e\u3044\u306b\u3064\u3044\u3066\u3001\u8a73\u3057\u304f\u898b\u3066\u307f\u3088\u3046\u3002<\/p>\n<h2 id=\"outline__1\">SIL\u304b\u3089\u898b\u308b\u30ad\u30e3\u30b9\u30c8\u306e\u6319\u52d5<\/h2>\n<p>Swift\u306b\u8a73\u3057\u3044 <a href=\"https:\/\/twitter.com\/orga_chem\">@Kuniwak<\/a> \u3055\u3093\u306b\u4e0a\u8a18\u306e\u8cea\u554f\u3092\u3057\u305f\u3068\u3053\u308d\u300cSIL\u3092\u8aad\u3081\u3070\u308f\u304b\u308a\u305d\u3046\u300d\u3068\u8a00\u3063\u3066\u3001\u624b\u53d6\u308a\u8db3\u53d6\u308a\u8272\u3005\u6559\u3048\u3066\u9802\u3044\u305f\u3002\u305d\u308c\u3092\u30d9\u30fc\u30b9\u306b\u88dc\u8db3\u3057\u306a\u304c\u3089\u89e3\u8aac\u3057\u3088\u3046\u3068\u601d\u3046\u3002<\/p>\n<p>SIL\u3068\u306fSwift Intermediate Language\u306e\u7565\u3067\u3001Swift\u306e\u30b3\u30fc\u30c9\u3092\u30d0\u30a4\u30ca\u30ea\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u6642\u306b\u51fa\u3066\u304f\u308b\u4e2d\u9593\u8868\u73fe\u3060\u3002\u3053\u306e\u4e2d\u9593\u8868\u73fe\u3092\u89e3\u8aad\u3059\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u30b3\u30f3\u30d1\u30a4\u30e9\u306e\u6c17\u6301\u3061\u3092\u3057\u3063\u304b\u308a\u3068\u53cd\u6620\u3057\u305f\u601d\u7d22\u304c\u53ef\u80fd\u306b\u306a\u308b\u3002<\/p>\n<p>\u9ad8\u7d1a\u306aSwift\u306e\u8868\u73fe\u306e\u307e\u307e\u3060\u3068\u4eba\u9593\u306e\u8a00\u8449\u306b\u8fd1\u3059\u304e\u3066\u96a0\u853d\u3055\u308c\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u60c5\u5831\u304c\u3042\u308b\u306e\u3067\u3001\u4e2d\u9593\u8868\u73fe\u3067\u3042\u308bSIL\u3092\u8aad\u3080\u3053\u3068\u306b\u3088\u3063\u3066\u3088\u308a\u4f4e\u30ec\u30d9\u30eb\u306a\u60c5\u5831\u3092\u5f97\u3088\u3046\u3068\u3044\u3046\u308f\u3051\u3060\u3002<\/p>\n<h3 id=\"outline__1_1\">\u3068\u308a\u3042\u3048\u305aSIL\u3092\u8aad\u3080<\/h3>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u53e9\u304f\u3053\u3068\u3067SIL\u3092\u5f97\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002\uff08SIL\u306e\u30b3\u30fc\u30c9\u306e\u90e8\u5206\u306f\u6d41\u3057\u898b\u3092\u3057\u3066\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u623b\u3063\u3066\u8aad\u3080\u3068\u3044\u3046\u30b9\u30bf\u30a4\u30eb\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002\uff09<\/p>\n<div class=\"bgBox\"><code>$ cat .\/cast.swift<\/code><br \/>\n<code>func makeInt() -&gt; Int {<\/code><br \/>\n<code>\u00a0 \u00a0 let a: Int = 28<\/code><br \/>\n<code>\u00a0 \u00a0 let b = a as Any<\/code><br \/>\n<code>\u00a0 \u00a0 let c = b as! Int<\/code><br \/>\n<code>\u00a0 \u00a0 return c<\/code><br \/>\n<code>}<\/code><\/div>\n<div class=\"bgBox\"><code><\/code><code>$ swiftc -emit-sil -Onone -o .\/cast.sil .\/cast.swift<\/code><\/div>\n<p>\u5f97\u305f\u51fa\u529b\u304b\u3089\u3001\u8a72\u5f53\u3059\u308b\u95a2\u6570\u306e\u90e8\u5206\u3092\u4e0b\u8a18\u306b\u629c\u7c8b\u3057\u305f\u3002<\/p>\n<div class=\"bgBox\"><code>\/\/ makeInt()<\/code><br \/>\n<code>sil hidden @$s4cast7makeIntSiyF : $@convention(thin) () -&gt; Int {<\/code><br \/>\n<code>bb0:<\/code><br \/>\n<code>\u00a0 %0 = integer_literal $Builtin.Int64, 28 \/\/ user: %1<\/code><br \/>\n<code>\u00a0 %1 = struct $Int (%0 : $Builtin.Int64) \/\/ users: %5, %2<\/code><br \/>\n<code>\u00a0 debug_value %1 : $Int, let, name \"a\" \/\/ id: %2<\/code><br \/>\n<code>\u00a0 %3 = alloc_stack $Any, let, name \"b\" \/\/ users: %15, %14, %7, %4<\/code><br \/>\n<code>\u00a0 %4 = init_existential_addr %3 : $*Any, $Int \/\/ user: %5<\/code><br \/>\n<code>\u00a0 store %1 to %4 : $*Int \/\/ id: %5<\/code><br \/>\n<code>\u00a0 %6 = alloc_stack $Any \/\/ users: %13, %9, %7<\/code><br \/>\n<code>\u00a0 copy_addr %3 to [initialization] %6 : $*Any \/\/ id: %7<\/code><br \/>\n<code>\u00a0 %8 = alloc_stack $Int \/\/ users: %10, %12, %9<\/code><br \/>\n<code>\u00a0 unconditional_checked_cast_addr Any in %6 : $*Any to Int in %8 : $*Int \/\/ id: %9<\/code><br \/>\n<code>\u00a0 %10 = load %8 : $*Int \/\/ users: %11, %16<\/code><br \/>\n<code>\u00a0 debug_value %10 : $Int, let, name \"c\" \/\/ id: %11<\/code><br \/>\n<code>\u00a0 dealloc_stack %8 : $*Int \/\/ id: %12<\/code><br \/>\n<code>\u00a0 dealloc_stack %6 : $*Any \/\/ id: %13<\/code><br \/>\n<code>\u00a0 destroy_addr %3 : $*Any \/\/ id: %14<\/code><br \/>\n<code>\u00a0 dealloc_stack %3 : $*Any \/\/ id: %15<\/code><br \/>\n<code>\u00a0 return %10 : $Int \/\/ id: %16<\/code><br \/>\n<code>} \/\/ end sil function '$s4cast7makeIntSiyF'<\/code><\/div>\n<p>\u4e0a\u306eSIL\u306f\u3042\u307e\u308a\u8907\u96d1\u306a\u3053\u3068\u3092\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u5168\u304f\u77e5\u3089\u306a\u304f\u3066\u3082\u306a\u3093\u3068\u306a\u304f\u4f55\u304c\u66f8\u3044\u3066\u3042\u308b\u306e\u304b\u308f\u304b\u308b\u3068\u601d\u3046\u3002\u30e1\u30e2\u30ea\u9818\u57df\u3092\u5272\u308a\u5f53\u3066\u305f\u308a\u3001\u5909\u6570\u306e\u5b9a\u7fa9\u3092\u3057\u3066\u3044\u308b\u306a\u3068\u8aad\u307f\u53d6\u308c\u308b\u3002<\/p>\n<p>\u305d\u306e\u3046\u3061\u3001\u30ad\u30e3\u30b9\u30c8\u306b\u95a2\u4fc2\u304c\u3042\u308a\u305d\u3046\u306a\u90e8\u5206\u3092\u8a73\u3057\u304f\u8abf\u3079\u308b\u3053\u3068\u306b\u3059\u308b\u3002<\/p>\n<p>Any\u578b\u3078\u306e\u30ad\u30e3\u30b9\u30c8\u306f<\/p>\n<div class=\"bgBox\">\n<p><code>%4 = init_existential_addr %3 : $*Any, $Int \/\/ user: %5<\/code><\/p>\n<\/div>\n<p>\u3053\u3053\u3067\u306a\u3055\u308c\u3066\u304a\u308a\u3001<\/p>\n<p>Int\u578b\u3078\u306e\u30ad\u30e3\u30b9\u30c8\u306f<\/p>\n<div class=\"bgBox\">\n<p><code> unconditional_checked_cast_addr Any in %6 : $*Any to Int in %8 : $*Int \/\/ id: %9<\/code><\/p>\n<\/div>\n<p>\u3053\u3053\u3067\u306a\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n<h3 id=\"outline__1_2\">init_existential_addr \u3068\u306f\u4f55\u304b<\/h3>\n<p>\u300cinit_existential_addr Swift\u300d\u3067\u691c\u7d22\u3092\u3059\u308b\u3068<a href=\"https:\/\/github.com\/apple\/swift\/blob\/master\/docs\/SIL.rst#init-existential-addr\">SIL\u306e\u8aad\u307f\u65b9\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8(swift\/SIL.rst)<\/a>\u304c\u30d2\u30c3\u30c8\u3059\u308b\u3002(\u4ee5\u4e0b\u306e2\u3064\u306e\u30d6\u30ed\u30c3\u30af\u306f\u5f15\u7528)<\/p>\n<div class=\"bgBox\">\n<p><code>sil-instruction ::= 'init_existential_addr' sil-operand ',' sil-type<\/code><\/p>\n<p><code>%1 = init_existential_addr %0 : $*P, $T<\/code><br \/>\n<code>\/\/ %0 must be of a $*P address type for non-class protocol or protocol composition type P<\/code><br \/>\n<code>\/\/ $T must be an AST type that fulfills protocol(s) P<\/code><br \/>\n<code>\/\/ %1 will be of type $*T', where T' is the maximally abstract lowering of type T<\/code><\/p>\n<\/div>\n<blockquote><p>Partially initializes the memory referenced by %0 with an existential container prepared to contain a value of type $T. The result of the instruction is an address referencing the storage for the contained value, which remains uninitialized.<\/p><\/blockquote>\n<p>Int\u578b\u304b\u3089Any\u578b\u3078\u306e\u30ad\u30e3\u30b9\u30c8\u306e\u5834\u5408\u306b\u5f53\u3066\u306f\u3081\u3066\u3001\u3053\u308c\u3089\u3092\u7ffb\u8a33\u3057\u3066\u307f\u308b\u3002<\/p>\n<p>init_existential_addr \u306b\u3088\u3063\u3066\u3001Any\u578b\u306e\u5909\u6570 b \u306e\u30dd\u30a4\u30f3\u30bf\u304c\u6307\u3059\u30e1\u30e2\u30ea\u304cexistential container\u3068\u5171\u306b\u90e8\u5206\u7684\u306b\u521d\u671f\u5316\u3055\u308c\u308b\u3002\u8fd4\u308a\u5024\u306fexistential container\u304c\u4fdd\u6301\u3059\u308b\u5024\u3078\u306e\u30a2\u30c9\u30ec\u30b9\u3068\u306a\u308b\u3002<\/p>\n<p>\u3068\u3044\u3046\u611f\u3058\u3060\u3002Any\u578b\u3068\u3057\u3066\u521d\u671f\u5316\u3059\u308b\u969b\u306b\u3001Int\u578b\u306e\u5024\u3092\u4fdd\u6301\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306aexistential container\u3068\u3044\u3046\u3082\u306e\u304c\u751f\u6210\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308b\u3002<\/p>\n<p>\u3053\u306e\u30b3\u30f3\u30c6\u30ca\u306e\u304a\u304b\u3052\u3067\u3001Any\u578b\u306b\u30ad\u30e3\u30b9\u30c8\u3057\u305f\u5f8c\u306b\u3082Int\u578b\u306e\u60c5\u5831\u3092\u5931\u3046\u3053\u3068\u306f\u306a\u304b\u3063\u305f\u3068\u8a00\u3048\u308b\u3060\u308d\u3046\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u3055\u3066\u3001Existential Container\u306e\u5b9f\u88c5\u306b\u3064\u3044\u3066\u3088\u308a\u8a73\u3057\u304f\u898b\u308b\u305f\u3081\u306bSwift\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3067\u691c\u7d22\u3092\u884c\u3044\u3001\u4ee5\u4e0b\u306e\u69cb\u9020\u4f53\u3092\u898b\u3064\u3051\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<\/p>\n<div class=\"bgBox\">\n<p><code>\/\/\/ The basic layout of an opaque (non-class-bounded) existential type.<\/code><br \/>\n<code>template &lt;typename Runtime&gt;<\/code><br \/>\n<code>struct TargetOpaqueExistentialContainer {<\/code><br \/>\n<code>\u00a0 TargetValueBuffer&lt;Runtime&gt; Buffer;<\/code><br \/>\n<code>\u00a0 ConstTargetMetadataPointer&lt;Runtime, TargetMetadata&gt; Type;<\/code><\/p>\n<p><code>\u00a0 const TargetWitnessTable&lt;Runtime&gt; **getWitnessTables() {<\/code><br \/>\n<code>\u00a0 \u00a0 return reinterpret_cast&lt;const TargetWitnessTable&lt;Runtime&gt; **&gt;(this + 1);<\/code><br \/>\n<code>\u00a0 }<\/code><\/p>\n<p><code>\u00a0 const TargetWitnessTable&lt;Runtime&gt; *const *getWitnessTables() const {<\/code><br \/>\n<code>\u00a0 \u00a0 return reinterpret_cast&lt;const TargetWitnessTable&lt;Runtime&gt; *const *&gt;(this + 1);<\/code><br \/>\n<code>\u00a0 }<br \/>\n...<br \/>\n\/\/\/ Project out a pointer to the value stored in the container.<br \/>\n\/\/\/<br \/>\n\/\/\/ *NOTE* If the container contains the value inline, then this will return a<br \/>\n\/\/\/ pointer inside the container itself. Otherwise, it will return a pointer<br \/>\n\/\/\/ to out of line memory.<br \/>\nconst OpaqueValue *projectValue() const;<br \/>\n...<br \/>\n};<\/code><\/p>\n<\/div>\n<p>Buffer\u3068\u3044\u3046\u30d5\u30a3\u30fc\u30eb\u30c9\u304cExistential Container\u304c\u4fdd\u6301\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u306e\u4e2d\u8eab\uff08\u53c8\u306f\u30dd\u30a4\u30f3\u30bf\uff09\u3067Type\u3068\u3044\u3046\u30d5\u30a3\u30fc\u30eb\u30c9\u304cMetadata\u578b\u306e\u5024\u3067\u3042\u308b\u3002<\/p>\n<p>projectValue()\u3068\u3044\u3046\u95a2\u6570\u304c\u4e2d\u8eab\u306e\u5024\u3092\u8fd4\u3059\u95a2\u6570\u3060\u3068\u66f8\u3044\u3066\u3044\u308b\u3002\u3053\u306e\u95a2\u6570\u304c\u3001\u5b9f\u969b\u306e\u5024\u3092\u53d6\u308a\u51fa\u3059\u969b\u306b\u306f\u4f7f\u308f\u308c\u3066\u3044\u305d\u3046\u306a\u4e88\u611f\u304c\u3057\u305f\u3002<\/p>\n<p>Existential Container\u306b\u3064\u3044\u3066\u306e\u8a73\u3057\u3044\u3053\u3068\u306f<a href=\"https:\/\/medium.com\/@vhart\/protocols-generics-and-existential-containers-wait-what-e2e698262ab1\">\u3053\u306e\u8a18\u4e8b<\/a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h3 id=\"outline__1_3\">unconditional_checked_cast_addr \u3068\u306f\u4f55\u304b<\/h3>\n<p>SIL\u3092\u547c\u3093\u3067\u3044\u3066\u308f\u304b\u3089\u306a\u3044\u5358\u8a9e\u304c\u51fa\u3066\u304d\u305f\u3089\u3001\u3068\u308a\u3042\u3048\u305a\u5148\u7a0b\u306e SIL.rst \u3067\u691c\u7d22\u3092\u66f8\u3051\u308b\u3068\u826f\u3044\u3002\u3053\u306e sil-instruction \u3092\u691c\u7d22\u3057\u3066\u307f\u308b\u3068\u3001\u7279\u306b\u76ee\u65b0\u3057\u3044\u60c5\u5831\u306f\u51fa\u3066\u3053\u306a\u304b\u3063\u305f\u3002<\/p>\n<p><a href=\"https:\/\/developer.apple.com\/documentation\/swift\/1641250-unsafebitcast\">unsafeBitCast()<\/a> \u3068\u3044\u3046\u95a2\u6570\u304c\u30e1\u30e2\u30ea\u4e0a\u306e\u8868\u73fe\u3060\u3051\u3092\u898b\u3066\u30ad\u30e3\u30b9\u30c8\u3059\u308b\u3088\u3046\u306b\u3001\u3053\u3046\u3044\u3063\u305f\u30ad\u30e3\u30b9\u30c8\u306f\u5148\u7a0b\u5f97\u3089\u308c\u305f\u5024\u304b\u3089unsafe\u306b\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u3068\u3059\u308b\u3068\u7279\u6bb5\u7591\u554f\u306b\u601d\u3046\u3053\u3068\u3082\u306a\u3044\u3002<\/p>\n<p>projectValue()\u306a\u3069\u306e\u95a2\u6570\u306b\u3088\u3063\u3066Existential Container\u304c\u4fdd\u5b58\u3057\u3066\u3044\u305f\u5024\u3092\u53d6\u308a\u51fa\u3057\u3001\u578b\u60c5\u5831\u3068\u306e\u6574\u5408\u6027\u3092\u898b\u3066\u3001\u305d\u306e\u5024\u3092\u8fd4\u3059\u306e\u3060\u308d\u3046\u3068\u4e88\u60f3\u3057\u3066\u6b21\u306b\u9032\u3080\u3053\u3068\u306b\u3059\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"outline__2\">Protocol\u3068Class\u306e\u9055\u3044<\/h2>\n<p>\u3053\u308c\u307e\u3067\u306e\u8a71\u306f\u5168\u3066\u3001protocol\u3078\u306e\u30ad\u30e3\u30b9\u30c8\u306e\u8a71\u3092\u3057\u3066\u3044\u305f\u3002\uff08\u305d\u306e\u3053\u3068\u306b\u3064\u3044\u3066\u6700\u521d\u306f\u3042\u307e\u308a\u6c17\u306b\u3057\u3066\u3044\u306a\u304b\u3063\u305f\u3002\uff09<\/p>\n<p>\u3057\u304b\u3057protocol\u3078\u306e\u30ad\u30e3\u30b9\u30c8\u3068\u89aa\u30af\u30e9\u30b9\u3078\u306e\u30a2\u30c3\u30d7\u30ad\u30e3\u30b9\u30c8\u306fSIL\u3092\u8aad\u307f\u89e3\u304f\u3068\u5168\u7136\u9055\u3046\u3053\u3068\u306b\u6c17\u304c\u4ed8\u3044\u305f\u3002<\/p>\n<div class=\"bgBox\">\n<p><code>$ cat dog.swift<\/code><br \/>\n<code>class Dog {}<\/code><br \/>\n<code>class Doberman: Dog {<\/code><br \/>\n<code>\u00a0 \u00a0 var kawaisa = 3<\/code><br \/>\n<code>}<\/code><\/p>\n<p><code>func getKawaisa() -&gt; Int {<\/code><br \/>\n<code>\u00a0 \u00a0 let a = Doberman()<\/code><br \/>\n<code>\u00a0 \u00a0 a.kawaisa = 5<\/code><br \/>\n<code>\u00a0 \u00a0 let b = a as Dog<\/code><br \/>\n<code>\u00a0 \u00a0 let c = b as! Doberman<\/code><br \/>\n<code>\u00a0 \u00a0 return c.kawaisa<\/code><br \/>\n<code>}<\/code><\/p>\n<\/div>\n<div class=\"bgBox\"><code><\/code><code>$ swiftc -emit-sil -Onone -o .\/dog.sil .\/dog.swift<\/code><\/div>\n<p>\u4e0a\u3092\u5b9f\u884c\u3057\u305f\u3068\u3053\u308d\u3001\u30af\u30e9\u30b9\u306e\u5b9a\u7fa9\u304c\u3042\u308b\u5206\u3001\u3088\u308a\u5927\u304d\u306aSIL\u304c\u51fa\u529b\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308b\u3002\u95a2\u6570\u90e8\u5206\u306eSIL\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3060\u3002<\/p>\n<div class=\"bgBox\">\n<p><code>\/\/ getKawaisa()<\/code><br \/>\n<code>sil hidden @$s3dog10getKawaisaSiyF : $@convention(thin) () -&gt; Int {<\/code><br \/>\n<code>bb0:<\/code><br \/>\n<code>\u00a0\u3000%0 = metatype $@thick Doberman.Type \/\/ user: %2<\/code><br \/>\n<code>\u00a0\u3000\/\/ function_ref Doberman.__allocating_init()<\/code><br \/>\n<code>\u00a0\u3000%1 = function_ref @$s3dog8DobermanCACycfC : $@convention(method) (@thick Doberman.Type) -&gt; @owned Doberman \/\/ user: %2<\/code><br \/>\n<code>\u00a0\u3000%2 = apply %1(%0) : $@convention(method) (@thick Doberman.Type) -&gt; @owned Doberman \/\/ users: %18, %9, %8, %6, %7, %3<\/code><br \/>\n<code>\u00a0\u3000debug_value %2 : $Doberman, let, name \"a\" \/\/ id: %3<\/code><br \/>\n<code>\u00a0\u3000%4 = integer_literal $Builtin.Int64, 5 \/\/ user: %5<\/code><br \/>\n<code>\u00a0\u3000%5 = struct $Int (%4 : $Builtin.Int64) \/\/ user: %7<\/code><br \/>\n<code>\u00a0\u3000%6 = class_method %2 : $Doberman, #Doberman.kawaisa!setter.1 : (Doberman) -&gt; (Int) -&gt; (), $@convention(method) (Int, @guaranteed Doberman) -&gt; () \/\/ user: %7<\/code><br \/>\n<code>\u00a0\u3000%7 = apply %6(%5, %2) : $@convention(method) (Int, @guaranteed Doberman) -&gt; ()<\/code><br \/>\n<code>\u00a0\u3000strong_retain %2 : $Doberman \/\/ id: %8<\/code><br \/>\n<code>\u00a0\u3000%9 = upcast %2 : $Doberman to $Dog \/\/ users: %17, %12, %11, %10<\/code><br \/>\n<code>\u00a0\u3000debug_value %9 : $Dog, let, name \"b\" \/\/ id: %10<\/code><br \/>\n<code>\u00a0\u3000strong_retain %9 : $Dog \/\/ id: %11<\/code><br \/>\n<code>\u00a0\u3000%12 = unconditional_checked_cast %9 : $Dog to $Doberman \/\/ users: %16, %14, %15, %13<\/code><br \/>\n<code>\u00a0\u3000debug_value %12 : $Doberman, let, name \"c\" \/\/ id: %13<\/code><br \/>\n<code>\u00a0\u3000%14 = class_method %12 : $Doberman, #Doberman.kawaisa!getter.1 : (Doberman) -&gt; () -&gt; Int, $@convention(method) (@guaranteed Doberman) -&gt; Int \/\/ user: %15<\/code><br \/>\n<code>\u00a0\u3000%15 = apply %14(%12) : $@convention(method) (@guaranteed Doberman) -&gt; Int \/\/ user: %19<\/code><br \/>\n<code>\u00a0\u3000strong_release %12 : $Doberman \/\/ id: %16<\/code><br \/>\n<code>\u00a0\u3000strong_release %9 : $Dog \/\/ id: %17<\/code><br \/>\n<code>\u00a0\u3000strong_release %2 : $Doberman \/\/ id: %18<\/code><br \/>\n<code>\u00a0\u3000return %15 : $Int \/\/ id: %19<\/code><br \/>\n<code>} \/\/ end sil function '$s3dog10getKawaisaSiyF'<\/code><\/p>\n<\/div>\n<p>upcast\u3068\u3044\u3046sil-instruction\u304c\u4f7f\u7528\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308b\u3002\u305f\u3060\u3057\u3001\u3053\u306esil-instruction\u306b\u3064\u3044\u3066SIL\u306e\u5148\u7a0b\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3059\u308b\u3082\u3001\u300c\u89aa\u30af\u30e9\u30b9\u306b\u30a2\u30c3\u30d7\u30ad\u30e3\u30b9\u30c8\u3059\u308b\u300d\u3050\u3089\u3044\u306e\u60c5\u5831\u91cf\u3057\u304b\u3067\u3066\u3053\u306a\u3044\u3002<\/p>\n<p>\u3068\u306a\u308b\u3068\u3001\u3042\u308b\u30af\u30e9\u30b9\u3092\u7d99\u627f\u3057\u305f\u30b5\u30d6\u30af\u30e9\u30b9\u306e\u521d\u671f\u5316\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u4f55\u304b\u30a2\u30c3\u30d7\u30ad\u30e3\u30b9\u30c8\u3092\u3057\u305f\u3068\u3057\u3066\u3082\u30c7\u30fc\u30bf\u3092\u5931\u3046\u3053\u3068\u304c\u306a\u3044\u3088\u3046\u306a\u69cb\u9020\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u3060\u308d\u3046\u304b\u3002\u5148\u7a0b\u51fa\u529b\u3057\u305fSIL\u306e\u4e2d\u3067\u30af\u30e9\u30b9\u306e\u521d\u671f\u5316\u90e8\u5206\u3092\u629c\u7c8b\u3059\u308b\u3002<\/p>\n<div class=\"bgBox\">\n<p><code>\/\/ Doberman.__allocating_init()<\/code><br \/>\n<code>sil hidden @$s3dog8DobermanCACycfC : $@convention(method) (@thick Doberman.Type) -&gt; @owned Doberman {<\/code><br \/>\n<code>bb0(%0 : $@thick Doberman.Type):<\/code><br \/>\n<code>\u00a0 %1 = alloc_ref $Doberman \/\/ user: %3<\/code><br \/>\n<code>\u00a0\u3000\/\/ function_ref Doberman.init()<\/code><br \/>\n<code>\u00a0 %2 = function_ref @$s3dog8DobermanCACycfc : $@convention(method) (@owned Doberman) -&gt; @owned Doberman \/\/ user: %3<\/code><br \/>\n<code>\u00a0\u3000%3 = apply %2(%1) : $@convention(method) (@owned Doberman) -&gt; @owned Doberman \/\/ user: %4<\/code><br \/>\n<code>\u00a0\u3000return %3 : $Doberman \/\/ id: %4<\/code><br \/>\n<code>} \/\/ end sil function '$s3dog8DobermanCACycfC'<\/code><\/p>\n<p><code>\/\/ Doberman.init()<\/code><br \/>\n<code>sil hidden @$s3dog8DobermanCACycfc : $@convention(method) (@owned Doberman) -&gt; @owned Doberman {<\/code><br \/>\n<code>\/\/ %0 \/\/ users: %5, %9, %2<\/code><br \/>\n<code>bb0(%0 : $Doberman):<\/code><br \/>\n<code>\u00a0\u3000%1 = alloc_stack $Doberman, let, name \"self\" \/\/ users: %13, %2, %15, %16<\/code><br \/>\n<code>\u00a0\u3000store %0 to %1 : $*Doberman \/\/ id: %2<\/code><br \/>\n<code>\u00a0\u3000%3 = integer_literal $Builtin.Int64, 3 \/\/ user: %4<\/code><br \/>\n<code>\u00a0\u3000%4 = struct $Int (%3 : $Builtin.Int64) \/\/ user: %7<\/code><br \/>\n<code>\u00a0\u3000%5 = ref_element_addr %0 : $Doberman, #Doberman.kawaisa \/\/ user: %6<\/code><br \/>\n<code>\u00a0\u3000%6 = begin_access [modify] [dynamic] %5 : $*Int \/\/ users: %7, %8<\/code><br \/>\n<code>\u00a0\u3000store %4 to %6 : $*Int \/\/ id: %7<\/code><br \/>\n<code>\u00a0\u3000end_access %6 : $*Int \/\/ id: %8<\/code><br \/>\n<code>\u00a0\u3000%9 = upcast %0 : $Doberman to $Dog \/\/ user: %11<\/code><br \/>\n<code>\u00a0\u3000\/\/ function_ref Dog.init()<\/code><br \/>\n<code>\u00a0\u3000%10 = function_ref @$s3dog3DogCACycfc : $@convention(method) (@owned Dog) -&gt; @owned Dog \/\/ user: %11<\/code><br \/>\n<code>\u00a0\u3000%11 = apply %10(%9) : $@convention(method) (@owned Dog) -&gt; @owned Dog \/\/ user: %12<\/code><br \/>\n<code>\u00a0\u3000%12 = unchecked_ref_cast %11 : $Dog to $Doberman \/\/ users: %14, %17, %13<\/code><br \/>\n<code>\u00a0\u3000store %12 to %1 : $*Doberman \/\/ id: %13<\/code><br \/>\n<code>\u00a0\u3000strong_retain %12 : $Doberman \/\/ id: %14<\/code><br \/>\n<code>\u00a0\u3000destroy_addr %1 : $*Doberman \/\/ id: %15<\/code><br \/>\n<code>\u00a0\u3000dealloc_stack %1 : $*Doberman \/\/ id: %16<\/code><br \/>\n<code>\u00a0\u3000return %12 : $Doberman \/\/ id: %17<\/code><br \/>\n<code>} \/\/ end sil function '$s3dog8DobermanCACycfc'<\/code><\/p>\n<\/div>\n<p>Doberman\u30af\u30e9\u30b9\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u521d\u671f\u5316\u304c %3 ~ %8 \u3067\u884c\u308f\u308c\u305f\u5f8c\u3001\u81ea\u8eab(self)\u3092Dog\u30af\u30e9\u30b9\u306bupcast\u3057\u3001Dog\u30af\u30e9\u30b9\u306e\u521d\u671f\u5316\u95a2\u6570\u3092\u547c\u3073\u3001\u305d\u308c\u3092unchecked_ref_cast\u3067Doberman\u30af\u30e9\u30b9\u306b\u30c0\u30a6\u30f3\u30ad\u30e3\u30b9\u30c8\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>\u3053\u306e\u6642\u3001\u30e1\u30e2\u30ea\u306e\u30d2\u30fc\u30d7\u9818\u57df\u306b\u4fdd\u5b58\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u4e2d\u8eab\u306fupcast\u306b\u3088\u3063\u3066Doberman\u30af\u30e9\u30b9\u306e\u60c5\u5831\u3092\u5931\u3046\u3053\u3068\u306f\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u304c\u78ba\u8a8d\u3055\u308c\u308b\u304c\u3001\u5b9f\u969b\u306b\u3069\u306e\u3088\u3046\u306a\u30c7\u30fc\u30bf\u69cb\u9020\u306b\u3088\u3063\u3066\u5b9f\u88c5\u304c\u306a\u3055\u308c\u3066\u3044\u308b\u304b\u306f\u3001SIL\u3068\u50d5\u306e\u73fe\u5728\u306e\u77e5\u8b58\u3067\u306f\u7406\u89e3\u3067\u304d\u306a\u304b\u3063\u305f\u3002<\/p>\n<p>\u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u5834\u5408\u306bExsitential Container\u3092\u4f7f\u7528\u3057\u3066SIL\u30ec\u30d9\u30eb\u3067\u5b9f\u73fe\u3055\u308c\u3066\u3044\u305f\u30c7\u30fc\u30bf\u306e\u4fdd\u6301\u306b\u5bfe\u3057\u3066\u3001\u30af\u30e9\u30b9\u306e\u5834\u5408\u306b\u306f\u3088\u308a\u4f4e\u30ec\u30d9\u30eb\u306a\u30c7\u30fc\u30bf\u69cb\u9020\u306b\u843d\u3068\u3057\u8fbc\u307e\u308c\u3066\u30c7\u30fc\u30bf\u306e\u4fdd\u6301\u304c\u5b9f\u73fe\u3055\u308c\u3066\u3044\u308b\u3068\u898b\u3048\u305f\u3002<\/p>\n<h2 id=\"outline__3\">type(of:)\u30e1\u30bd\u30c3\u30c9\u3068dynamic type<\/h2>\n<p>\u539f\u70b9\u7684\u306a\u6700\u521d\u306e\u7591\u554f\u306b\u5bfe\u3057\u3066\u3001\u307e\u305f\u5225\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u306b\u3088\u3063\u3066\u7406\u89e3\u3092\u6df1\u3081\u3066\u307f\u305f\u3044\u3002<br \/>\n\u305d\u3082\u305d\u3082\u578b\u63a8\u8ad6\u6642\u306e\u578b\u3068\u5b9f\u884c\u6642\u306e\u578b\u306b\u3064\u3044\u3066\u3001\u4e21\u8005\u306e\u9055\u3044\u3092\u898b\u3066\u307f\u3088\u3046\u3002<\/p>\n<h3 id=\"outline__3_1\">type(of:)\u30e1\u30bd\u30c3\u30c9\u306e\u6319\u52d5<\/h3>\n<p>Swift \u306e\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc\u3092\u8d77\u52d5\u3059\u308b\u3002<\/p>\n<div class=\"bgBox\">\n<p><code> 1&gt; let a: Int = 28<\/code><br \/>\n<code>2&gt; let b = a as Any<\/code><br \/>\n<code>3&gt; let c = b as! Int<\/code><br \/>\n<code>4&gt; type(of: a)<\/code><br \/>\n<code>$R1: Int.Type = Int<\/code><br \/>\n<code>5&gt; type(of: b)<\/code><br \/>\n<code>$R2: Any.Type = Int<\/code><br \/>\n<code>6&gt; type(of: c)<\/code><br \/>\n<code>$R3: Int.Type = Int<\/code><\/p>\n<\/div>\n<p>\u3053\u308c\u3092\u898b\u308b\u3068\u3001\u305d\u3082\u305d\u3082Any\u306b\u30ad\u30e3\u30b9\u30c8\u3057\u305f\u3068\u3057\u3066\u3082type(of:)\u30e1\u30bd\u30c3\u30c9\u3067\u5f97\u3089\u308c\u308b\u578b\u306fInt\u3067\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308b\u3002<\/p>\n<p><a href=\"https:\/\/developer.apple.com\/documentation\/swift\/2885064-type\">type(of:)\u30e1\u30bd\u30c3\u30c9\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u3092\u8aad\u3080\u3068\u3001\u578b\u306b\u306fdynamic type\u3068static type\u306e2\u7a2e\u985e\u304c\u3042\u308a\u3001dynamic type\u3068\u3044\u3046\u306e\u306f\u5b9f\u884c\u6642\u306e\u5b9f\u969b\u306e\u578b\u3001static type\u3068\u3044\u3046\u306e\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306e\u578b\u3067\u3042\u308b\u3068\u3044\u3046\u8aac\u660e\u304c\u66f8\u304b\u308c\u3066\u3044\u308b\u3002<br \/>\n\u305d\u3057\u3066\u3001type(of:)\u30e1\u30bd\u30c3\u30c9\u3067\u5f97\u3089\u308c\u308b\u578b\u306fdynamic type\u306a\u306e\u3067\u3042\u308b\u3002<\/p>\n<p>\u307e\u305f\u3001static type\u306f\u578b\u63a8\u8ad6\u306b\u3088\u3063\u3066\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u6c7a\u5b9a\u3055\u308c\u308b\u306e\u3060\u308d\u3046\u3068\u4e88\u60f3\u3055\u308c\u308b\u3002\u3067\u306f\u3001dynamic type\u306f\u3069\u306e\u3088\u3046\u306b\u8868\u73fe\u3055\u308c\u308b\u306e\u3060\u308d\u3046\u304b\u3002\u4eca\u56de\u306e\u7591\u554f\u3092\u5225\u89d2\u5ea6\u304b\u3089\u89e3\u304f\u9375\u306f\u3053\u3053\u306b\u5b58\u5728\u3059\u308b\u3088\u3046\u306a\u6c17\u304c\u3057\u305f\u306e\u3067\u3001\u3082\u3046\u5c11\u3057\u3053\u306etype(of:)\u30e1\u30bd\u30c3\u30c9\u306b\u3064\u3044\u3066\u8abf\u3079\u3066\u307f\u305f\u3002<\/p>\n<p>\u3042\u3068\u3001Existential Container\u306e\u8a71\u3068\u3069\u3053\u304b\u3067\u4ea4\u308f\u308b\u3053\u3068\u3092\u305d\u308c\u3068\u306a\u304f\u671f\u5f85\u3057\u3066\u3044\u305f\u304c\u3001Existential Container\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306e\u8a71\u3067\u3001type(of:)\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u88c5\u306fRuntime\u306e\u8a71\u306a\u306e\u3067\u3001\u305d\u306e\u671f\u5f85\u306f\u9054\u6210\u3055\u308c\u3048\u306a\u3044\u3082\u306e\u306e\u3088\u3046\u306a\u6c17\u304c\u3057\u305f\u3002<\/p>\n<h3 id=\"outline__3_2\">type(of:)\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u88c5<\/h3>\n<p>type(of:)\u30e1\u30bd\u30c3\u30c9\u306e\u578b\u306f\u4e0b\u8a18\u3067\u3042\u308b\u3068\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u304b\u304b\u308c\u3066\u3044\u308b\u3002<\/p>\n<div class=\"bgBox\">\n<p><code>func type&lt;T, Metatype&gt;(of value: T) -&gt; Metatype<\/code><\/p>\n<\/div>\n<p>\u578b\u304c T \u3067\u3042\u308b\u5024\u3092\u53d7\u3051\u53d6\u3063\u3066\u3001\u305d\u306e\u578b\u306eMetatype\u3092\u8fd4\u3059\u306e\u3060\u308d\u3046\u3068\u3056\u3063\u304f\u308a\u7406\u89e3\u3067\u304d\u308b\u3002\u3067\u306fSwift\u306e\u30b3\u30fc\u30c9\u3067\u5b9f\u969b\u306b\u3069\u306e\u3088\u3046\u306b\u8868\u73fe\u3055\u308c\u3066\u3044\u308b\u306e\u3060\u308d\u3046\u304b\u3002<\/p>\n<p>Swift\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u5185\u3067\u3053\u306e\u95a2\u6570\u3092\u691c\u7d22\u3057\u3066\u3044\u308b\u3068\u3001<\/p>\n<div class=\"bgBox\">\n<p><code>@_transparent<\/code><br \/>\n<code>@_semantics(\"typechecker.type(of:)\")<\/code><br \/>\n<code>public func type&lt;T, Metatype&gt;(of value: T) -&gt; Metatype { ... }<\/code><\/p>\n<\/div>\n<p>\u3068\u3044\u3046\u95a2\u6570\u304c\u30d2\u30c3\u30c8\u3059\u308b\u304c\u3001\u3053\u306e\u95a2\u6570\u306b\u306f\u4e2d\u8eab\u306f\u306a\u3044\u3002\u5b9f\u969b\u306b\u547c\u3070\u308c\u3066\u3044\u308b\u95a2\u6570\u306b\u8fbf\u308a\u7740\u304f\u305f\u3081\u306b\u3001typechecker.type(of:)\u3067\u691c\u7d22\u3092\u3059\u308b\u3002\u3053\u306e\u3042\u305f\u308a\u304b\u3089\u3001\u50d5\u306b\u306f\u5168\u4f53\u50cf\u304c\u63b4\u307f\u306b\u304f\u304f\u306a\u3063\u3066\u304d\u305f\u3002<\/p>\n<div class=\"bgBox\">\n<p><code>Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType, ConstraintLocatorBuilder locator, ConstraintLocatorBuilder calleeLocator) { ... }<\/code><\/p>\n<\/div>\n<p>\u3053\u306e\u95a2\u6570\u306e\u5185\u90e8\u3067\u3001type(of:)\u306e\u6319\u52d5\u304c\u8a18\u8ff0\u3055\u308c\u3066\u3044\u308b\u3002C++\u306f\u5168\u304f\u66f8\u3051\u306a\u3044\u304c\u3001\u6c17\u5408\u3067\u89e3\u8aad\u3057\u3066\u3044\u304f\u3002<\/p>\n<p class=\"p1\">DynamicTypeExpr\u578b\u3068\u3044\u3046dynamic type\u3092\u8868\u73fe\u3057\u3066\u3044\u308b\u3088\u3046\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u751f\u6210\u3055\u308c\u3066\u3044\u308b\u306e\u3092\u898b\u305f\u3002<br \/>\n\u69d8\u3005\u306a\u5f15\u6570\u306e\u5024\u304b\u3089DynamicTypeExpr\u578b\u306e\u5024\u3092\u751f\u6210\u3057\u3001\u305d\u308c\u3092\u4f7f\u3063\u3066Expr\u578b\u306e\u5024\u3092\u751f\u6210\u3057\u3066\u8fd4\u3059\u3068\u3044\u3046\u306e\u304c\u3053\u306e\u95a2\u6570\u306e\u3057\u3066\u3044\u308b\u3053\u3068\u3089\u3057\u3044\u3002<\/p>\n<p>\u3053\u306eExpr\u578b\u3068\u3044\u3046\u306e\u306f<\/p>\n<div class=\"bgBox\">\n<p><code>\/\/\/ Expr - Base class for all expressions in swift.<\/code><\/p>\n<\/div>\n<p>\u3068\u3042\u308b\u3088\u3046\u306b\u3001Swift\u306e\u8868\u73fe\uff08\u3069\u3053\u307e\u3067\u306e\u7bc4\u56f2\u3092\u6307\u3059\u306e\u304b\u306f\u77e5\u3089\u306a\u3044\uff09\u306e\u57fa\u790e\u3068\u306a\u308b\u30af\u30e9\u30b9\u306e\u3088\u3046\u3067\u3001Type\u578b\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3082\u6301\u3063\u3066\u3044\u308b\u3002getType()\u3084setType()\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3082\u3042\u3063\u305f\u3002<\/p>\n<p>(2018\/3\/24 \u8ffd\u8a18\uff1a\u2191expressions\u306f\u8868\u73fe\u3067\u306f\u306a\u304f\u5f0f\u306e\u3053\u3068\u3067\u3042\u308a\u3001<a href=\"https:\/\/docs.swift.org\/swift-book\/ReferenceManual\/Expressions.html\">\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u306b\u8a73\u7d30\u306e\u89e3\u8aac\u304c\u306a\u3055\u308c\u3066\u3044\u308b\u3002)<\/p>\n<p>\u305d\u3057\u3066\u3001Expr\u578b\u3092\u7d99\u627f\u3057\u3066\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308bDynamicTypeExpr\u578b\u3092\u78ba\u8a8d\u3057\u3066\u307f\u308b\u3068\u3001\u30b3\u30e1\u30f3\u30c8\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304b\u308c\u3066\u3044\u305f\u3002<\/p>\n<div class=\"bgBox\">\n<p><code>\/\/\/ DynamicTypeExpr - \"type(of: base)\" - Produces a metatype value.<\/code><br \/>\n<code>\/\/\/<\/code><br \/>\n<code>\/\/\/ The metatype value comes from evaluating an expression then retrieving the<\/code><br \/>\n<code>\/\/\/ metatype of the result.<\/code><\/p>\n<\/div>\n<p>\u3053\u306e\u30af\u30e9\u30b9\u3092\u4f7f\u3046\u3068\u3001Expr\u578b\u306e\u5024\u3092\u8a55\u4fa1\u3057\u3066\u30e1\u30bf\u30bf\u30a4\u30d7\u3092\u8fd4\u3059\u3053\u3068\u304c\u51fa\u6765\u308b\u3001\u3068\u3044\u3046\u3056\u3063\u304f\u308a\u3068\u3057\u305f\u548c\u8a33\u3067\u7d42\u308f\u308a\u306b\u3057\u305f\u3044\u3002<\/p>\n<p>\u3082\u3063\u3068\u5185\u90e8\u306b\u6f5c\u308a\u8fbc\u3081\u3070\u3001\u578b\u304c\u3069\u306e\u3088\u3046\u306b\u8868\u73fe\u3055\u308c\u3066\u3044\u308b\u306e\u304b\u898b\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3068\u601d\u3046\u306e\u3060\u304c\u3001\u306a\u306b\u305b\u95a2\u9023\u3059\u308b\u3088\u304f\u308f\u304b\u3089\u306a\u3044\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3060\u3089\u3051\u3067\u8abf\u3079\u308b\u306e\u304c\u56f0\u96e3\u3092\u6975\u3081\u3066\u304d\u305f\u304b\u3089\u3001\u3053\u306e\u65b9\u5411\u3067\u8abf\u3079\u308b\u306e\u306f\u4e00\u65e6\u7d42\u308f\u308a\u306b\u3059\u308b\u3002<\/p>\n<p>Swift\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3084SIL\u3092\u8aad\u3080\u306e\u306f\u697d\u3057\u3044\u306e\u3067\u4eca\u5f8c\u3082\u6311\u6226\u3057\u305f\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u65e5\u3001\u30ad\u30e3\u30b9\u30c8\uff08Type Casting\uff09\u306b\u3064\u3044\u3066\u539f\u70b9\u7684\u306a\u7591\u554f\u306b\u3076\u3064\u304b\u3063\u305f\u3002 let a: Int = 28 let b = a as Any let c = b as! Int print(c &#8211; 1) \/\/ 27 \u3053\u306e\u3088\u3046\u306bInt\u578b\u3067\u5b9a\u7fa9\u3057\u305f\u5024\u3092\u3001Any\u578b\u306b\u30ad\u30e3\u30b9\u30c8\u3057\u3001\u518d\u5ea6Int\u578b\u306b\u30ad\u30e3\u30b9\u30c8\u3057\u305f\u3068\u3059\u308b\u3002 \u3053\u306e\u6642\u3001Int\u578b\u3078\u306eforce cast\u306f\u7121\u4e8b\u6210\u529f\u3057\u3001\u5909\u6570 c \u306f\u6574\u6570\u578b\u3068\u3057\u3066\u6271\u3046\u3053\u3068\u304c\u51fa [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1239,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[23],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2020\/03\/bird-1045954_1920.jpg?fit=1920%2C1277&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p89t1T-jR","jetpack-related-posts":[{"id":1163,"url":"https:\/\/it1.jp\/?p=1163","url_meta":{"origin":1231,"position":0},"title":"iOSDC 2019\u306b\u53c2\u52a0\u3057\u3066\u304d\u305f\u3002","author":"koji aomatsu","date":"2019\u5e749\u670819\u65e5","format":false,"excerpt":"\u4e45\u3057\u3076\u308a\u306b\u30d6\u30ed\u30b0\u3092\u66f8\u304f\u3068\u3044\u3046\u624b\u524d\u3001\u6e9c\u3081\u8fbc\u3093\u3060\u53d9\u60c5\u3068\u6c17\u5206\u306e\u9ad8\u63da\u304c\u7e4a\u7d30\u306a\u8a69\u3092\u751f\u307f\u51fa\u3057\u305d\u3046\u306a\u4e88\u611f\u306f\u3059\u308b\u3002\u3051\u2026","rel":"","context":"\u30c6\u30af\u30ce\u30ed\u30b8\u30fc","block_context":{"text":"\u30c6\u30af\u30ce\u30ed\u30b8\u30fc","link":"https:\/\/it1.jp\/?cat=23"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2019\/09\/IMG_2738.jpg?fit=1200%2C900&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2019\/09\/IMG_2738.jpg?fit=1200%2C900&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2019\/09\/IMG_2738.jpg?fit=1200%2C900&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2019\/09\/IMG_2738.jpg?fit=1200%2C900&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2019\/09\/IMG_2738.jpg?fit=1200%2C900&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":961,"url":"https:\/\/it1.jp\/?p=961","url_meta":{"origin":1231,"position":1},"title":"\u9762\u767d\u3044\u6570\u5b57\u306e\u7279\u5fb4\u3084\u7f8e\u3057\u3044\u6570\u5b57\u306e\u7279\u5fb4\u306e\u898b\u3064\u3051\u65b9\u306b\u3064\u3044\u3066\u771f\u5263\u306b\u8003\u3048\u3066\u307f\u308b","author":"koji aomatsu","date":"2018\u5e745\u670811\u65e5","format":false,"excerpt":"\u300c1026\u306e\u6027\u8cea\u306f\uff1f\u300d\u305d\u306e\u8cea\u554f\u306b\u3001\u50d5\u306f\u300c\\(1026 = 32^2 + 2 = (5^2 + 2)(\u2026","rel":"","context":"\u6570\u5b66","block_context":{"text":"\u6570\u5b66","link":"https:\/\/it1.jp\/?cat=7"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2018\/05\/\u9762\u767d\u3044\u6570\u5b57\u306e\u7279\u5fb4\u3084\u7f8e\u3057\u3044\u6570\u5b57\u306e\u7279\u5fb4\u306e\u898b\u3064\u3051\u65b9\u306b\u3064\u3044\u3066\u771f\u5263\u306b\u8003\u3048\u3066\u307f\u308b-1.png?fit=1000%2C667&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2018\/05\/\u9762\u767d\u3044\u6570\u5b57\u306e\u7279\u5fb4\u3084\u7f8e\u3057\u3044\u6570\u5b57\u306e\u7279\u5fb4\u306e\u898b\u3064\u3051\u65b9\u306b\u3064\u3044\u3066\u771f\u5263\u306b\u8003\u3048\u3066\u307f\u308b-1.png?fit=1000%2C667&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2018\/05\/\u9762\u767d\u3044\u6570\u5b57\u306e\u7279\u5fb4\u3084\u7f8e\u3057\u3044\u6570\u5b57\u306e\u7279\u5fb4\u306e\u898b\u3064\u3051\u65b9\u306b\u3064\u3044\u3066\u771f\u5263\u306b\u8003\u3048\u3066\u307f\u308b-1.png?fit=1000%2C667&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2018\/05\/\u9762\u767d\u3044\u6570\u5b57\u306e\u7279\u5fb4\u3084\u7f8e\u3057\u3044\u6570\u5b57\u306e\u7279\u5fb4\u306e\u898b\u3064\u3051\u65b9\u306b\u3064\u3044\u3066\u771f\u5263\u306b\u8003\u3048\u3066\u307f\u308b-1.png?fit=1000%2C667&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1175,"url":"https:\/\/it1.jp\/?p=1175","url_meta":{"origin":1231,"position":2},"title":"UIStackView\u3067\u30d1\u30c7\u30a3\u30f3\u30b0\u304c\u601d\u3044\u901a\u308a\u306b\u306a\u3089\u306a\u3044\u6642\u306b\u8a66\u3057\u305f\u3053\u3068","author":"koji aomatsu","date":"2019\u5e7410\u670810\u65e5","format":false,"excerpt":"UIStackView \u306a\u308b\u3082\u306e\u304c\u3042\u308b\u3002\u6ca2\u5c71\u306eView\u3092\u307e\u3068\u3081\u305f\u308a\u3001\u52d5\u7684\u306b\u4e2d\u8eab\u304c\u5909\u308f\u308b\u3088\u3046\u306a\u3082\u306e\u3067\u3082\u2026","rel":"","context":"\u30c6\u30af\u30ce\u30ed\u30b8\u30fc","block_context":{"text":"\u30c6\u30af\u30ce\u30ed\u30b8\u30fc","link":"https:\/\/it1.jp\/?cat=23"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2019\/10\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2019-10-10-15.40.52-1.png?fit=448%2C234&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":229,"url":"https:\/\/it1.jp\/?p=229","url_meta":{"origin":1231,"position":3},"title":"\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u521d\u5fc3\u8005\u304cSwift\u306b\u51fa\u4f1a\u3063\u3066\u304b\u3089\u30a2\u30d7\u30ea\u3092\u30ea\u30ea\u30fc\u30b9\u3059\u308b\u307e\u3067","author":"koji aomatsu","date":"2016\u5e7412\u670815\u65e5","format":false,"excerpt":"\u3053\u306e\u8a18\u4e8b\u306f\u00a0CAMPHOR- Advent Calendar 2016\u00a0\u306e15\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002 &n\u2026","rel":"","context":"\u30c6\u30af\u30ce\u30ed\u30b8\u30fc","block_context":{"text":"\u30c6\u30af\u30ce\u30ed\u30b8\u30fc","link":"https:\/\/it1.jp\/?cat=23"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2016\/12\/iloveswift.jpg?fit=1000%2C600&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2016\/12\/iloveswift.jpg?fit=1000%2C600&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2016\/12\/iloveswift.jpg?fit=1000%2C600&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2016\/12\/iloveswift.jpg?fit=1000%2C600&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":265,"url":"https:\/\/it1.jp\/?p=265","url_meta":{"origin":1231,"position":4},"title":"\u300c\u624b\u4f5c\u308aRPG\u300d\u306e\u958b\u767a\u65b9\u6cd5\u3068\u30b2\u30fc\u30e0\u30d0\u30e9\u30f3\u30b9\u3068\u53ce\u76ca\u306e\u8a71","author":"koji aomatsu","date":"2016\u5e7412\u670822\u65e5","format":false,"excerpt":"\u3053\u306e\u8a18\u4e8b\u306f\u00a0CAMPHOR- Advent Calendar 2016\u00a0\u306e22\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002 \u300c\u81ea\u2026","rel":"","context":"\u30c6\u30af\u30ce\u30ed\u30b8\u30fc","block_context":{"text":"\u30c6\u30af\u30ce\u30ed\u30b8\u30fc","link":"https:\/\/it1.jp\/?cat=23"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2016\/12\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2016-12-22-6.29.47.png?fit=602%2C348&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2016\/12\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2016-12-22-6.29.47.png?fit=602%2C348&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2016\/12\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2016-12-22-6.29.47.png?fit=602%2C348&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":878,"url":"https:\/\/it1.jp\/?p=878","url_meta":{"origin":1231,"position":5},"title":"\u30cb\u30fc\u30c1\u30a7\u6700\u5f8c\u306e\u8457\u4f5c\u300e\u3053\u306e\u4eba\u3092\u898b\u3088\u300f\u304b\u3089\u89e3\u8aac\u3059\u308b\u30cb\u30fc\u30c1\u30a7\u306e\u601d\u60f3","author":"koji aomatsu","date":"2018\u5e744\u670810\u65e5","format":false,"excerpt":"\u5927\u5b661\u5e74\u306e\u6642\u306b\u54f2\u5b66\u306e\u8b1b\u7fa9\u3067\u30cb\u30fc\u30c1\u30a7\u3092\u6271\u3063\u305f\u306e\u304c\u3001\u50d5\u3068\u30cb\u30fc\u30c1\u30a7\u306e\u8457\u4f5c\u3068\u306e\u51fa\u4f1a\u3044\u3060\u3063\u305f\u3088\u3046\u306b\u601d\u3046\u3002 \u30cb\u30fc\u2026","rel":"","context":"\u5b66\u554f","block_context":{"text":"\u5b66\u554f","link":"https:\/\/it1.jp\/?cat=22"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2018\/04\/\u30cb\u30fc\u30c1\u30a7\u6700\u5f8c\u306e\u8457\u4f5c\u300e\u3053\u306e\u4eba\u3092\u898b\u3088\u300f\u304b\u3089\u89e3\u8aac\u3059\u308b\u30cb\u30fc\u30c1\u30a7\u306e\u601d\u60f3.png?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2018\/04\/\u30cb\u30fc\u30c1\u30a7\u6700\u5f8c\u306e\u8457\u4f5c\u300e\u3053\u306e\u4eba\u3092\u898b\u3088\u300f\u304b\u3089\u89e3\u8aac\u3059\u308b\u30cb\u30fc\u30c1\u30a7\u306e\u601d\u60f3.png?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2018\/04\/\u30cb\u30fc\u30c1\u30a7\u6700\u5f8c\u306e\u8457\u4f5c\u300e\u3053\u306e\u4eba\u3092\u898b\u3088\u300f\u304b\u3089\u89e3\u8aac\u3059\u308b\u30cb\u30fc\u30c1\u30a7\u306e\u601d\u60f3.png?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2018\/04\/\u30cb\u30fc\u30c1\u30a7\u6700\u5f8c\u306e\u8457\u4f5c\u300e\u3053\u306e\u4eba\u3092\u898b\u3088\u300f\u304b\u3089\u89e3\u8aac\u3059\u308b\u30cb\u30fc\u30c1\u30a7\u306e\u601d\u60f3.png?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/it1.jp\/wp-content\/uploads\/2018\/04\/\u30cb\u30fc\u30c1\u30a7\u6700\u5f8c\u306e\u8457\u4f5c\u300e\u3053\u306e\u4eba\u3092\u898b\u3088\u300f\u304b\u3089\u89e3\u8aac\u3059\u308b\u30cb\u30fc\u30c1\u30a7\u306e\u601d\u60f3.png?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/it1.jp\/index.php?rest_route=\/wp\/v2\/posts\/1231"}],"collection":[{"href":"https:\/\/it1.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it1.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it1.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/it1.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1231"}],"version-history":[{"count":27,"href":"https:\/\/it1.jp\/index.php?rest_route=\/wp\/v2\/posts\/1231\/revisions"}],"predecessor-version":[{"id":1259,"href":"https:\/\/it1.jp\/index.php?rest_route=\/wp\/v2\/posts\/1231\/revisions\/1259"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/it1.jp\/index.php?rest_route=\/wp\/v2\/media\/1239"}],"wp:attachment":[{"href":"https:\/\/it1.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it1.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it1.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}