Skip to content

Commit 72b1885

Browse files
committed
1 parent f6eeb3a commit 72b1885

File tree

2 files changed

+56
-55
lines changed

2 files changed

+56
-55
lines changed

test/SILGen/subscripts.swift

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ do {
5151
v[] = 0
5252
inoutFunc(&v[])
5353

54+
_ = v[1]
55+
v[1] = 0
56+
inoutFunc(&v[1])
57+
5458
_ = v[0, 1, 2]
5559
v[0, 1, 2] = 3
5660
inoutFunc(&v[0, 1, 2])
@@ -77,3 +81,55 @@ do {
7781
inoutFunc(&v["", 0, 1, 2])
7882
}
7983

84+
struct VariadicSubscript3 {
85+
subscript(indices: (Int, Int)...) -> Int {
86+
get { return 0 }
87+
set {}
88+
}
89+
}
90+
91+
do {
92+
var b = VariadicSubscript3()
93+
_ = b[]
94+
b[] = 1
95+
inoutFunc(&b[])
96+
97+
_ = b[(1, 2)]
98+
b[(1,2)] = 1
99+
inoutFunc(&b[(1,2)])
100+
101+
_ = b[(1, 2),(2,3)]
102+
b[(1,2),(2,3)] = 1
103+
inoutFunc(&b[(1,2),(2,3)])
104+
}
105+
106+
// https://bugs.swift.org/browse/SR-1816
107+
public struct Flags: OptionSet {
108+
public var rawValue: Int
109+
public init(rawValue: Int) { self.rawValue = rawValue }
110+
111+
public static let flag = Flags(rawValue: 1 << 0)
112+
}
113+
114+
class VariadicSubscript4 {
115+
subscript(_ values: Int..., flags flags: Flags) -> Int {
116+
get { return 0 }
117+
set { }
118+
}
119+
}
120+
121+
do {
122+
let t = VariadicSubscript4()
123+
124+
_ = t[flags: .flag]
125+
t[flags: .flag] = 0
126+
inoutFunc(&t[flags: .flag])
127+
128+
_ = t[1, flags: .flag]
129+
t[1, flags: .flag] = 0
130+
inoutFunc(&t[1, flags: .flag])
131+
132+
_ = t[1, 2, 3, flags: .flag]
133+
t[1, 2, 3, flags: .flag] = 0
134+
inoutFunc(&t[1, 2, 3, flags: .flag])
135+
}

test/SILGen/variadic-subscript-single-arg.swift

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)