// RUN: %target-swift-frontend -emit-silgen %s | FileCheck %s

class C {
  required init() { }
}

// CHECK-LABEL: sil hidden @_TF12dynamic_init15testDynamicInit
func testDynamicInit(cm: C.Type) {
  // CHECK: bb0([[CM:%[0-9]+]] : $@thick C.Type):
  // CHECK:   [[METHOD:%[0-9]+]] = class_method [[CM]] : $@thick C.Type, #C.init!allocator.1 : C.Type -> () -> C , $@convention(thin) (@thick C.Type) -> @owned C
  // CHECK:   [[C_OBJ:%[0-9]+]] = apply [[METHOD]]([[CM]]) : $@convention(thin) (@thick C.Type) -> @owned C
  // CHECK:   strong_release [[C_OBJ]] : $C
  // CHECK:   [[RESULT:%[0-9]+]] = tuple ()
  // CHECK:   return [[RESULT]] : $()
  cm.init()
}

// CHECK-LABEL: sil hidden @_TF12dynamic_init14testStaticInit
func testStaticInit() {
  // CHECK-NOT: class_method
  // CHECK: function_ref @_TFC12dynamic_init1CC{{.*}} : $@convention(thin) (@thick C.Type) -> @owned C
  C()
  // CHECK-NOT: class_method
  // CHECK: return
}
