Files
swift-mirror/test/IDE/complete_with_closure_param.swift
T
Aviva Ruben 2f58b7c57a [Sema] Preserve type alias sugar when removing escaping
This change fixes rdar://172417385 and #45125 by using transformRec
to set no escape, instead of casting which drops sugar. This affects
how interfaces are printed, and could theoretically cause issues with
printing private aliases into public interfaces. Motivated by needing
to be able to diagnose issues with attributes on aliases; without this
change, the alias sugar is sometimes lost.
2026-03-17 11:33:58 -07:00

27 lines
1.8 KiB
Swift

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=COMPLETE | %FileCheck %s
typealias FunctionTypealias = (Int, Int) -> Bool
typealias OptionalFunctionTypealias = ((Int, Int) -> Bool)?
struct FooStruct {
func instanceMethod1(_ callback: (Int, Int) -> Void) {}
func instanceMethod2(_ callback: ((Int, Int) -> Void)?) {}
func instanceMethod3(_ callback: ((Int, Int) -> Void)??) {}
func instanceMethod4(_ callback: ((Int, Int) -> Void)!) {}
func instanceMethod5(_ callback: FunctionTypealias) {}
func instanceMethod6(_ callback: FunctionTypealias?) {}
func instanceMethod7(_ callback: OptionalFunctionTypealias) {}
}
FooStruct().#^COMPLETE^#
// CHECK: Begin completions, 8 items
// CHECK-DAG: Decl[InstanceMethod]/CurrNominal: instanceMethod1({#(callback): (Int, Int) -> Void##(Int, Int) -> Void#})[#Void#]; name=instanceMethod1(:){{$}}
// CHECK-DAG: Decl[InstanceMethod]/CurrNominal: instanceMethod2({#(callback): ((Int, Int) -> Void)?##(Int, Int) -> Void#})[#Void#]{{; name=.+$}}
// CHECK-DAG: Decl[InstanceMethod]/CurrNominal: instanceMethod3({#(callback): ((Int, Int) -> Void)??##(Int, Int) -> Void#})[#Void#]{{; name=.+$}}
// CHECK-DAG: Decl[InstanceMethod]/CurrNominal: instanceMethod4({#(callback): ((Int, Int) -> Void)!##(Int, Int) -> Void#})[#Void#]{{; name=.+$}}
// CHECK-DAG: Decl[InstanceMethod]/CurrNominal: instanceMethod5({#(callback): FunctionTypealias##(Int, Int) -> Bool#})[#Void#]{{; name=.+$}}
// CHECK-DAG: Decl[InstanceMethod]/CurrNominal: instanceMethod6({#(callback): FunctionTypealias?##(Int, Int) -> Bool#})[#Void#]{{; name=.+$}}
// CHECK-DAG: Decl[InstanceMethod]/CurrNominal: instanceMethod7({#(callback): OptionalFunctionTypealias##(Int, Int) -> Bool#})[#Void#]{{; name=.+$}}
// CHECK-DAG: Keyword[self]/CurrNominal: self[#FooStruct#]; name=self