mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Adds support for renaming subscripts with external names, e.g. subscript(x y: Int), and introduces a noncollapsible parameter name range for subscript parameters, since these shouldn't be collapsed with an argument label of the same name as function parameter names are.
86 lines
2.4 KiB
Plaintext
86 lines
2.4 KiB
Plaintext
import func SomeModule . /*import*/someFunc
|
|
|
|
func /*no-args:def*/anotherFunc() -> Int {
|
|
return 1
|
|
}
|
|
|
|
func /*param-label:def*/aFunc(a: Int) {}
|
|
|
|
func /*arg-label:def*/aFunc(b a:Int) {}
|
|
|
|
func /*no-label:def*/aFunc(_ b:Int) -> Int {
|
|
return /*no-args:call*/anotherFunc()
|
|
}
|
|
|
|
func /*whitespace-labels:def*/aFunc( a b: Int ,_ a: Int, c c : Int) {}
|
|
|
|
func /*referenced:def*/bar(a: Int) {}
|
|
|
|
func /*varargs:def*/aFunc(c: Int...) {}
|
|
/*varargs:call*/aFunc(c: 1, 2, 3, 4)
|
|
|
|
class AStruct {
|
|
func /*method:def*/foo(a: Int, b: Int, _ c: Int) -> Int {
|
|
return a + b + c
|
|
}
|
|
|
|
func /*bar:def*/bar(_ a: Int) -> (Int) -> Int {
|
|
return {a in a};
|
|
}
|
|
|
|
static func /*infix-operator:def*/+ (left: AStruct, right: AStruct) -> AStruct {
|
|
return AStruct()
|
|
}
|
|
|
|
static prefix func /*prefix-operator:def*/- (struct: AStruct) -> AStruct {
|
|
return AStruct()
|
|
}
|
|
}
|
|
|
|
let aStruct = /*prefix-operator:call*/-AStruct() /*infix-operator:call*/+ AStruct()
|
|
/*no-args:call*/anotherFunc()
|
|
/*param-label:call*/aFunc(a: 2)
|
|
/*arg-label:call*/aFunc(b: /*no-args:call*/anotherFunc() * /*no-args:call*/anotherFunc())
|
|
let _ = /*no-label:call*/aFunc(3)
|
|
/*whitespace-labels:call*/aFunc( a : 2 ,2, c: 4 )
|
|
|
|
let _ = aStruct . /*method:call*/foo(a: 2, b: 3, 1)
|
|
let _ = AStruct . /*method*/foo(aStruct)(a: 1, b: 8, 10)
|
|
let _ = aStruct . /*bar:call*/bar(/*no-args:call*/anotherFunc())(/*no-label:call*/aFunc(2))
|
|
|
|
var a = /*referenced*/bar
|
|
var b = /*referenced*/bar(a:)
|
|
let _ = "Some text \(/*param-label:call*/aFunc(a:1)) around"
|
|
|
|
class SomeClass {
|
|
init() {}
|
|
/*init:def*/init(a: Int, b:Int, c:Int) {}
|
|
/*sub:def*/subscript(x: Int, y j: Int) -> Int {
|
|
get { return 1 }
|
|
set {}
|
|
}
|
|
}
|
|
|
|
let someClass = SomeClass();
|
|
let _ = /*init:call*/SomeClass(a:1, b:1, c:1)
|
|
let _ = SomeClass . /*init*/init(a:b:c:)
|
|
_ = someClass/*sub:ref*/[1, y: 2]
|
|
someClass/*sub:ref*/[1, y: 2] = 2
|
|
|
|
class AnotherClass {
|
|
let bar = AnotherClass()
|
|
func /*nested:def*/foo(a: Int) -> AnotherClass {}
|
|
}
|
|
|
|
AnotherClass() . /*nested:call*/foo(a: 1) . /*nested2*/bar . /*nested2*/bar . /*nested:call*/foo(a: 2) . /*nested:call*/foo(a: 3) . /*nested:unknown*/foo . foo(a: 4)
|
|
|
|
struct Memberwise {
|
|
let /*memberwise-x:def*/x: Int
|
|
let y: Int = 0
|
|
var z: Int = 2
|
|
}
|
|
_ = Memberwise(/*memberwise-x:ref*/x: 1, z: 3)
|
|
let memberwise = Memberwise.init(/*memberwise-x:ref*/x:z:)
|
|
_ = memberwise . /*memberwise-x:ref*/x
|
|
|