// RUN: %target-swift-frontend -dump-ast %s | %FileCheck %s func doSomething(_ t: T) {} // CHECK: func_decl{{.*}}"outerGeneric(t:x:)" interface type=' (t: T, x: AnyObject) -> ()' func outerGeneric(t: T, x: AnyObject) { // Simple case -- closure captures outer generic parameter // CHECK: closure_expr type='() -> ()' {{.*}} discriminator=0 captures=( t) escaping single-expression _ = { doSomething(t) } // Special case -- closure does not capture outer generic parameters // CHECK: closure_expr type='() -> ()' {{.*}} discriminator=1 captures=(x) escaping single-expression _ = { doSomething(x) } // Special case -- closure captures outer generic parameter, but it does not // appear as the type of any expression // CHECK: closure_expr type='() -> ()' {{.*}} discriminator=2 captures=( x) _ = { if x is T {} } // Nested generic functions always capture outer generic parameters, even if // they're not mentioned in the function body // CHECK: func_decl{{.*}}"innerGeneric(u:)" interface type=' (u: U) -> ()' {{.*}} captures=( ) func innerGeneric(u: U) {} // Make sure we look through typealiases typealias TT = (a: T, b: T) // CHECK: func_decl{{.*}}"localFunction(tt:)" interface type=' (tt: TT) -> ()' {{.*}} captures=( ) func localFunction(tt: TT) {} // CHECK: closure_expr type='(TT) -> ()' {{.*}} captures=( ) let _: (TT) -> () = { _ in } }