// RUN: %target-swift-emit-silgen -module-name implicit_property_initializers -Xllvm -sil-full-demangle -enable-testing %s | %FileCheck %s // CHECK: struct HasDefaultTupleOfNils { // CHECK: @_hasStorage @_hasInitialValue var x: (Int?, Int?) // CHECK: @_hasStorage @_hasInitialValue var y: Int? // CHECK: @_hasStorage var z: Int // CHECK: @_hasStorage @_hasInitialValue var w: ((Int?, (), Int?), (Int?, Int?)) // CHECK: init(x: (Int?, Int?) = (nil, nil), // CHECK-SAME: y: Int? = nil, // CHECK-SAME: z: Int, // CHECK-SAME: w: ((Int?, (), Int?), (Int?, Int?)) = ((nil, (), nil), (nil, nil))) // CHECK: } struct HasDefaultTupleOfNils { var x: (Int?, Int?) var y: Int? var z: Int var w: ((Int?, (), Int?), (Int?, Int?)) } // The default value initializer for 'x' should have type (Optional, Optional) // CHECK: sil [transparent] [ossa] @$[[X_VALUE_INIT:s30implicit_property_initializers21HasDefaultTupleOfNilsV1xSiSg_AEtvpfi]] : $@convention(thin) () -> (Optional, Optional) { // CHECK: bb0: // CHECK: %0 = enum $Optional, #Optional.none!enumelt // CHECK: %1 = enum $Optional, #Optional.none!enumelt // CHECK: %2 = tuple (%0 : $Optional, %1 : $Optional) // CHECK: return %2 : $(Optional, Optional) // CHECK: } // The default value initializer for 'y' should have type Optional //CHECK: sil [transparent] [ossa] @$s30implicit_property_initializers21HasDefaultTupleOfNilsV1ySiSgvpfi : $@convention(thin) () -> Optional { //CHECK: bb0: //CHECK: %0 = enum $Optional, #Optional.none!enumelt // user: %1 //CHECK: return %0 : $Optional // id: %1 //CHECK: } // There should not be a default value initializer for 'z'. // CHECK-NOT: @$s30implicit_property_initializers21HasDefaultTupleOfNilsV1zSivpfi // The default value initializer for 'w' should flatten to type (Optional, Optional, Optional, Optional) //CHECK: sil [transparent] [ossa] @$[[W_VALUE_INIT:s30implicit_property_initializers21HasDefaultTupleOfNilsV1wSiSg_ytAEt_AE_AEttvpfi]] : $@convention(thin) () -> (Optional, Optional, Optional, Optional) { //CHECK: bb0: //CHECK: %0 = enum $Optional, #Optional.none!enumelt // user: %4 //CHECK: %1 = enum $Optional, #Optional.none!enumelt // user: %4 //CHECK: %2 = enum $Optional, #Optional.none!enumelt // user: %4 //CHECK: %3 = enum $Optional, #Optional.none!enumelt // user: %4 //CHECK: %4 = tuple (%0 : $Optional, %1 : $Optional, %2 : $Optional, %3 : $Optional) // user: %5 //CHECK: return %4 : $(Optional, Optional, Optional, Optional) // id: %5 //CHECK: } // The default arg generator for 'x' inside the memberwise init should have type (Optional, Optional) // CHECK: sil [ossa] @$s30implicit_property_initializers21HasDefaultTupleOfNilsV1x1y1z1wACSiSg_AHt_AHSiAH_ytAHt_AH_AHtttcfcfA_ : $@convention(thin) () -> (Optional, Optional) { // CHECK: bb0: // CHECK: %0 = function_ref @$[[X_VALUE_INIT]] : $@convention(thin) () -> (Optional, Optional) // user: %1 // CHECK: %1 = apply %0() : $@convention(thin) () -> (Optional, Optional) // CHECK: (%2, %3) = destructure_tuple %1 : $(Optional, Optional) // CHECK: %4 = tuple (%2 : $Optional, %3 : $Optional) // CHECK: return %4 : $(Optional, Optional) // CHECK: } // There should not be a default arg generator for 'y' because it's just a nil literal and clients construct it directly. // CHECK-NOT: @$s30implicit_property_initializers21HasDefaultTupleOfNilsV1x1y1z1wACSiSg_AHt_AHSiAH_ytAHt_AH_AHtttcfcfA0_ // There should not be a default arg generator for 'z' // CHECK-NOT: @$s30implicit_property_initializers21HasDefaultTupleOfNilsV1x1y1z1wACSiSg_AHt_AHSiAH_ytAHt_AH_AHtttcfcfA1_ // The default arg generator for 'w' should flatten to type (Optional, Optional, Optional, Optional) // CHECK: sil [ossa] @$s30implicit_property_initializers21HasDefaultTupleOfNilsV1x1y1z1wACSiSg_AHt_AHSiAH_ytAHt_AH_AHtttcfcfA2_ : $@convention(thin) () -> (Optional, Optional, Optional, Optional) { // CHECK: bb0: // CHECK: %0 = function_ref @$[[W_VALUE_INIT]] : $@convention(thin) () -> (Optional, Optional, Optional, Optional) // CHECK: %1 = apply %0() : $@convention(thin) () -> (Optional, Optional, Optional, Optional) // CHECK: (%2, %3, %4, %5) = destructure_tuple %1 : $(Optional, Optional, Optional, Optional) // CHECK: %6 = tuple (%2 : $Optional, %3 : $Optional, %4 : $Optional, %5 : $Optional) // CHECK: return %6 : $(Optional, Optional, Optional, Optional) // CHECK: }