Files
swift-mirror/test/SILGen/default_arguments_nil.swift
Slava Pestov c9f550c60f Parse: Parse an explicit 'nil' default argument as DefaultArgumentKind::NilLiteral
We support a special DefaultArgumentKind::NilLiteral, but it was only
used for synthesized and imported default arguments as well.

Let's also use it for parsed default arguments that are exactly 'nil',
so that rethrows checking can special-case them.
2021-04-02 23:56:59 -04:00

12 lines
492 B
Swift

// RUN: %target-swift-emit-silgen %s | %FileCheck %s
public func takesAnInt(_: Int? = nil) {}
// CHECK-LABEL: sil [ossa] @$s21default_arguments_nil15callsTakesAnIntyyF : $@convention(thin) () -> () {
// CHECK: [[NIL:%.*]] = enum $Optional<Int>, #Optional.none!enumelt
// CHECK: [[FN:%.*]] = function_ref @$s21default_arguments_nil10takesAnIntyySiSgF
// CHECK: apply [[FN]]([[NIL]]) : $@convention(thin) (Optional<Int>) -> ()
// CHECK: return
public func callsTakesAnInt() {
takesAnInt()
}