Skip to content

Commit 704a33d

Browse files
author
Harlan Haskins
committed
Add tests for subscripts
1 parent 3e26b2d commit 704a33d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/ModuleInterface/inlinable-function.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,34 @@ public struct Foo: Hashable {
136136
print("Not inlinable")
137137
}
138138

139+
// CHECK: public subscript(i: [[INT]]) -> [[INT]] {
140+
// CHECK-NEXT: get{{$}}
141+
// CHECK-NEXT: @inlinable set[[NEWVALUE]] { print("set") }
142+
// CHECK-NEXT: }
143+
public subscript(i: Int) -> Int {
144+
get { return 0 }
145+
@inlinable set { print("set") }
146+
}
147+
148+
// CHECK: public subscript(j: [[INT]], k: [[INT]]) -> [[INT]] {
149+
// CHECK-NEXT: @inlinable get { return 0 }
150+
// CHECK-NEXT: set[[NEWVALUE]]{{$}}
151+
// CHECK-NEXT: }
152+
public subscript(j: Int, k: Int) -> Int {
153+
@inlinable get { return 0 }
154+
set { print("set") }
155+
}
156+
157+
// CHECK: @inlinable public subscript(l: [[INT]], m: [[INT]], n: [[INT]]) -> [[INT]] {
158+
// CHECK-NEXT: get { return 0 }
159+
// CHECK-NEXT: set[[NEWVALUE]] { print("set") }
160+
// CHECK-NEXT: }
161+
@inlinable
162+
public subscript(l: Int, m: Int, n: Int) -> Int {
163+
get { return 0 }
164+
set { print("set") }
165+
}
166+
139167
// CHECK: public init(value: [[INT]]) {
140168
// CHECK-NEXT: topLevelUsableFromInline()
141169
// CHECK-NEXT: noAccessors = value

0 commit comments

Comments
 (0)