Skip to content

Commit 6f76c0a

Browse files
committed
(Swift 5.2) - Fixing implicit tuple capture from multi associated cases
1 parent 8540b0a commit 6f76c0a

11 files changed

+103
-101
lines changed

SwiftDraw.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,7 @@
15091509
DYLIB_COMPATIBILITY_VERSION = 1;
15101510
DYLIB_CURRENT_VERSION = 1;
15111511
DYLIB_INSTALL_NAME_BASE = "@rpath";
1512+
ENABLE_BITCODE = NO;
15121513
INFOPLIST_FILE = SwiftDraw/Info.plist;
15131514
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
15141515
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";

SwiftDraw/LayerTree.Builder.Path.swift

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -97,42 +97,42 @@ extension LayerTree.Builder {
9797
}
9898

9999
static func createLine(from segment: DOM.Path.Segment, last point: Point) -> Path.Segment? {
100-
guard case .line(let l) = segment else { return nil }
100+
guard case let .line(x, y, space) = segment else { return nil }
101101

102-
let p = Point(l.x, l.y)
102+
let p = Point(x, y)
103103

104-
switch l.space {
104+
switch space {
105105
case .relative: return .line(to: p.absolute(from: point))
106106
case .absolute: return .line(to: p)
107107
}
108108
}
109109

110110
static func createHorizontal(from segment: DOM.Path.Segment, last point: Point) -> Path.Segment? {
111-
guard case .horizontal(let h) = segment else { return nil }
111+
guard case let .horizontal(x, space) = segment else { return nil }
112112

113-
switch h.space {
114-
case .relative: return .line(to: Point(h.x + point.x , point.y))
115-
case .absolute: return .line(to: Point(h.x, point.y))
113+
switch space {
114+
case .relative: return .line(to: Point(x + point.x , point.y))
115+
case .absolute: return .line(to: Point(x, point.y))
116116
}
117117
}
118118

119119
static func createVertical(from segment: DOM.Path.Segment, last point: Point) -> Path.Segment? {
120-
guard case .vertical(let v) = segment else { return nil }
120+
guard case let .vertical(y, space) = segment else { return nil }
121121

122-
switch v.space {
123-
case .relative: return .line(to: Point(point.x , v.y + point.y))
124-
case .absolute: return .line(to: Point(point.x, v.y))
122+
switch space {
123+
case .relative: return .line(to: Point(point.x , y + point.y))
124+
case .absolute: return .line(to: Point(point.x, y))
125125
}
126126
}
127127

128128
static func createCubic(from segment: DOM.Path.Segment, last point: Point) -> Path.Segment? {
129-
guard case .cubic(let c) = segment else { return nil }
129+
guard case let .cubic(x1, y1, x2, y2, x, y, space) = segment else { return nil }
130130

131-
let p = Point(c.x, c.y)
132-
let cp1 = Point(c.x1, c.y1)
133-
let cp2 = Point(c.x2, c.y2)
131+
let p = Point(x, y)
132+
let cp1 = Point(x1, y1)
133+
let cp2 = Point(x2, y2)
134134

135-
switch c.space {
135+
switch space {
136136
case .relative: return .cubic(to: p.absolute(from: point),
137137
control1: cp1.absolute(from: point),
138138
control2: cp2.absolute(from: point))
@@ -141,17 +141,17 @@ extension LayerTree.Builder {
141141
}
142142

143143
static func createCubicSmooth(from segment: DOM.Path.Segment, last point: Point, previous control: Point) -> Path.Segment? {
144-
guard case .cubicSmooth(let c) = segment else { return nil }
144+
guard case let .cubicSmooth(x2, y2, x, y, space) = segment else { return nil }
145145

146146
let delta = Point(point.x - control.x,
147147
point.y - control.y)
148148

149-
let p = Point(c.x, c.y)
149+
let p = Point(x, y)
150150
let cp1 = Point(point.x + delta.x,
151151
point.y + delta.y)
152-
let cp2 = Point(c.x2, c.y2)
152+
let cp2 = Point(x2, y2)
153153

154-
switch c.space {
154+
switch space {
155155
case .relative: return .cubic(to: p.absolute(from: point),
156156
control1: cp1,
157157
control2: cp2.absolute(from: point))
@@ -160,12 +160,12 @@ extension LayerTree.Builder {
160160
}
161161

162162
static func createQuadratic(from segment: DOM.Path.Segment, last point: Point) -> Path.Segment? {
163-
guard case .quadratic(let q) = segment else { return nil }
163+
guard case let .quadratic(x1, y1, x, y, space) = segment else { return nil }
164164

165-
var p = Point(q.x, q.y)
166-
var cp1 = Point(q.x1, q.y1)
165+
var p = Point(x, y)
166+
var cp1 = Point(x1, y1)
167167

168-
if q.space == .relative {
168+
if space == .relative {
169169
p = p.absolute(from: point)
170170
cp1 = cp1.absolute(from: point)
171171
}
@@ -191,15 +191,15 @@ extension LayerTree.Builder {
191191
}
192192

193193
static func createQuadraticSmooth(from segment: DOM.Path.Segment, last point: Point, previous control: Point) -> Path.Segment? {
194-
guard case .quadraticSmooth(let q) = segment else { return nil }
194+
guard case let .quadraticSmooth(x, y, space) = segment else { return nil }
195195

196196
let delta = Point(point.x - control.x,
197197
point.y - control.y)
198198

199199
let cp1 = Point(point.x + delta.x,
200200
point.y + delta.y)
201-
202-
let final = q.space == .absolute ? Point(q.x, q.y) : Point(q.x, q.y).absolute(from: point)
201+
202+
let final = space == .absolute ? Point(x, y) : Point(x, y).absolute(from: point)
203203
let cpX = (final.x - point.x)*Float(1.0/3.0)
204204
let cp2 = Point(cp1.x + cpX,
205205
cp1.y)
@@ -208,24 +208,24 @@ extension LayerTree.Builder {
208208
}
209209

210210
static func createArc(from segment: DOM.Path.Segment, last point: Point) -> [Path.Segment]? {
211-
guard case .arc(let a) = segment else { return nil }
211+
guard case let .arc(rx, ry, rotate, large, sweep, x, y, space) = segment else { return nil }
212212

213213
let p: Point
214214

215-
switch a.space {
216-
case .relative: p = Point(a.x, a.y).absolute(from: point)
217-
case .absolute: p = Point(a.x, a.y)
215+
switch space {
216+
case .relative: p = Point(x, y).absolute(from: point)
217+
case .absolute: p = Point(x, y)
218218
}
219219

220220
let curves = makeCubic(from: point, to: p,
221-
large: a.large, sweep: a.sweep,
222-
rx: LayerTree.Float(a.rx),
223-
ry: LayerTree.Float(a.ry),
224-
rotation: LayerTree.Float(a.rotate))
221+
large: large, sweep: sweep,
222+
rx: LayerTree.Float(rx),
223+
ry: LayerTree.Float(ry),
224+
rotation: LayerTree.Float(rotate))
225225

226226
return curves.map { .cubic(to: $0.p, control1: $0.cp1, control2: $0.cp2) }
227227
}
228-
228+
229229
static func createClose(from segment: DOM.Path.Segment) -> Path.Segment? {
230230
guard case .close = segment else { return nil }
231231
return .close

SwiftDraw/LayerTree.Builder.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,36 +274,36 @@ extension LayerTree.Builder {
274274
extension LayerTree.Builder {
275275
static func createTransform(for dom: DOM.Transform) -> [LayerTree.Transform] {
276276
switch dom {
277-
case .matrix(let m):
278-
let matrix = LayerTree.Transform.Matrix(a: Float(m.a),
279-
b: Float(m.b),
280-
c: Float(m.c),
281-
d: Float(m.d),
282-
tx: Float(m.e),
283-
ty: Float(m.f))
277+
case let .matrix(a, b, c, d, e, f):
278+
let matrix = LayerTree.Transform.Matrix(a: Float(a),
279+
b: Float(b),
280+
c: Float(c),
281+
d: Float(d),
282+
tx: Float(e),
283+
ty: Float(f))
284284
return [.matrix(matrix)]
285285

286-
case .translate(let t):
287-
return [.translate(tx: Float(t.tx), ty: Float(t.ty))]
286+
case let .translate(tx, ty):
287+
return [.translate(tx: Float(tx), ty: Float(ty))]
288288

289-
case .scale(let s):
290-
return [.scale(sx: Float(s.sx), sy: Float(s.sy))]
289+
case let .scale(sx, sy):
290+
return [.scale(sx: Float(sx), sy: Float(sy))]
291291

292292
case .rotate(let angle):
293293
let radians = Float(angle)*Float.pi/180.0
294294
return [.rotate(radians: radians)]
295295

296-
case .rotatePoint(let r):
297-
let radians = Float(r.angle)*Float.pi/180.0
298-
let t1 = LayerTree.Transform.translate(tx: r.cx, ty: r.cy)
296+
case let .rotatePoint(angle, cx, cy):
297+
let radians = Float(angle)*Float.pi/180.0
298+
let t1 = LayerTree.Transform.translate(tx: cx, ty: cy)
299299
let t2 = LayerTree.Transform.rotate(radians: radians)
300-
let t3 = LayerTree.Transform.translate(tx: -r.cx, ty: -r.cy)
300+
let t3 = LayerTree.Transform.translate(tx: -cx, ty: -cy)
301301
return [t1, t2, t3]
302302

303-
case .skewX(let angle):
303+
case let .skewX(angle):
304304
let radians = Float(angle)*Float.pi/180.0
305305
return [.skewX(angle: radians)]
306-
case .skewY(let angle):
306+
case let .skewY(angle):
307307
let radians = Float(angle)*Float.pi/180.0
308308
return [.skewY(angle: radians)]
309309
}

SwiftDraw/LayerTree.Color.swift

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,28 @@ extension LayerTree.Color {
5252
switch(color){
5353
case .none:
5454
return .none
55-
case .keyword(let c):
56-
return LayerTree.Color(c.rgbi)
57-
case .rgbi(let c):
58-
return LayerTree.Color(c)
59-
case .hex(let c):
60-
return LayerTree.Color(c)
61-
case .rgbf(let c):
62-
return .rgba(r: Float(c.0),
63-
g: Float(c.1),
64-
b: Float(c.2),
55+
case let .keyword(c):
56+
let rgbi = c.rgbi
57+
return LayerTree.Color(rgbi.0, rgbi.1, rgbi.2)
58+
case let .rgbi(r, g, b):
59+
return LayerTree.Color(r, g, b)
60+
case let .hex(r, g, b):
61+
return LayerTree.Color(r, g, b)
62+
case let .rgbf(r, g, b):
63+
return .rgba(r: Float(r),
64+
g: Float(g),
65+
b: Float(b),
6566
a: 1.0)
6667
}
6768
}
68-
69-
init(_ rgbi: (UInt8, UInt8, UInt8)) {
70-
self = .rgba(r: Float(rgbi.0)/255.0,
71-
g: Float(rgbi.1)/255.0,
72-
b: Float(rgbi.2)/255.0,
69+
70+
init(_ r: UInt8, _ g: UInt8, _ b: UInt8) {
71+
self = .rgba(r: Float(r)/255.0,
72+
g: Float(g)/255.0,
73+
b: Float(b)/255.0,
7374
a: 1.0)
7475
}
75-
76+
7677
var isOpaque: Bool {
7778
switch self {
7879
case .none:

SwiftDraw/LayerTree.CommandGenerator.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ extension LayerTree {
266266
case .matrix(let m):
267267
let t = provider.createTransform(from: m)
268268
return .concatenate(transform: t)
269-
case .translate(let t):
270-
let tx = provider.createFloat(from: t.tx)
271-
let ty = provider.createFloat(from: t.ty)
269+
case let .translate(tx, ty):
270+
let tx = provider.createFloat(from: tx)
271+
let ty = provider.createFloat(from: ty)
272272
return .translate(tx: tx, ty: ty)
273-
case .scale(let s):
274-
let sx = provider.createFloat(from: s.sx)
275-
let sy = provider.createFloat(from: s.sy)
273+
case let .scale(sx, sy):
274+
let sx = provider.createFloat(from: sx)
275+
let sy = provider.createFloat(from: sy)
276276
return .scale(sx: sx, sy: sy)
277277
case .rotate(let r):
278278
let radians = provider.createFloat(from: r)

SwiftDraw/Parser.XML.Element.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ extension XMLParser {
140140
}
141141

142142
switch error {
143-
case XMLParser.Error.invalidElement(let v):
144-
return .invalidElement(name: v.name,
145-
error: v.error,
146-
line: v.line,
147-
column: v.column)
143+
case let XMLParser.Error.invalidElement(name, error, line, column):
144+
return .invalidElement(name: name,
145+
error: error,
146+
line: line,
147+
column: column)
148148
default:
149149
return .invalidElement(name: element.name,
150150
error: error,

SwiftDraw/Renderer.CoreGraphics.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ struct CGProvider: RendererTypeProvider {
8787
func createColor(from color: LayerTree.Color) -> CGColor {
8888
switch color {
8989
case .none: return createColor(r: 0, g: 0, b: 0, a: 0)
90-
case .rgba(let c): return createColor(r: CGFloat(c.r),
91-
g: CGFloat(c.g),
92-
b: CGFloat(c.b),
93-
a: CGFloat(c.a))
90+
case let .rgba(r, g, b, a): return createColor(r: CGFloat(r),
91+
g: CGFloat(g),
92+
b: CGFloat(b),
93+
a: CGFloat(a))
9494
case .gray(white: let w, a: let a):
9595
return createColor(w: CGFloat(w), a: CGFloat(a))
9696
}

SwiftDrawTests/LayerTree.Builder.LayerTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ final class LayerTreeBuilderLayerTests: XCTestCase {
3838
let text = DOM.Text(value: "Hello")
3939
let contents = LayerTree.Builder.makeTextContents(from: text, with: .init())
4040

41-
guard case .text(let t) = contents else { XCTFail(); return }
42-
XCTAssertEqual(t.0, "Hello")
41+
guard case .text(let t, _, _) = contents else { XCTFail(); return }
42+
XCTAssertEqual(t, "Hello")
4343
}
4444

4545
func testMakeImageContentsFromDOM() throws {

SwiftDrawTests/LayerTree.ColorTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ final class LayerTreeColorTests: XCTestCase {
8686

8787
func testRGBi() {
8888
//a color can be created from (UInt8, UInt8, UInt8)
89-
90-
XCTAssertEqual(Color((UInt8(102), UInt8(102), UInt8(102))), .rgba(r: 0.4, g: 0.4, b: 0.4, a: 1.0))
91-
XCTAssertEqual(Color((UInt8(102), UInt8(0), UInt8(102))), .rgba(r: 0.4, g: 0.0, b: 0.4, a: 1.0))
92-
XCTAssertEqual(Color((UInt8(102), UInt8(102), UInt8(0))), .rgba(r: 0.4, g: 0.4, b: 0.0, a: 1.0))
93-
94-
XCTAssertEqual(Color((UInt8(204), UInt8(204), UInt8(204))), .rgba(r: 0.8, g: 0.8, b: 0.8, a: 1.0))
95-
XCTAssertEqual(Color((UInt8(204), UInt8(0), UInt8(204))), .rgba(r: 0.8, g: 0.0, b: 0.8, a: 1.0))
96-
XCTAssertEqual(Color((UInt8(204), UInt8(204), UInt8(0))), .rgba(r: 0.8, g: 0.8, b: 0.0, a: 1.0))
89+
90+
XCTAssertEqual(Color(UInt8(102), UInt8(102), UInt8(102)), .rgba(r: 0.4, g: 0.4, b: 0.4, a: 1.0))
91+
XCTAssertEqual(Color(UInt8(102), UInt8(0), UInt8(102)), .rgba(r: 0.4, g: 0.0, b: 0.4, a: 1.0))
92+
XCTAssertEqual(Color(UInt8(102), UInt8(102), UInt8(0)), .rgba(r: 0.4, g: 0.4, b: 0.0, a: 1.0))
93+
94+
XCTAssertEqual(Color(UInt8(204), UInt8(204), UInt8(204)), .rgba(r: 0.8, g: 0.8, b: 0.8, a: 1.0))
95+
XCTAssertEqual(Color(UInt8(204), UInt8(0), UInt8(204)), .rgba(r: 0.8, g: 0.0, b: 0.8, a: 1.0))
96+
XCTAssertEqual(Color(UInt8(204), UInt8(204), UInt8(0)), .rgba(r: 0.8, g: 0.8, b: 0.0, a: 1.0))
9797
}
9898

9999
func testLuminanceConverter() {

SwiftDrawTests/Parser.XML.ElementTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ final class XMLParserElementTests: XCTestCase {
128128
with: [])
129129

130130
switch parseError! {
131-
case .invalidElement(let val):
132-
XCTAssertEqual(val.line, 100)
133-
XCTAssertEqual(val.column, 50)
131+
case let .invalidElement(_, _, line, column):
132+
XCTAssertEqual(line, 100)
133+
XCTAssertEqual(column, 50)
134134
default:
135135
XCTFail("not forwarderd")
136136
}
@@ -145,9 +145,9 @@ final class XMLParserElementTests: XCTestCase {
145145
with: [])
146146

147147
switch parseError! {
148-
case .invalidElement(let val):
149-
XCTAssertEqual(val.line, 100)
150-
XCTAssertEqual(val.column, 50)
148+
case let .invalidElement(_, _, line, column):
149+
XCTAssertEqual(line, 100)
150+
XCTAssertEqual(column, 50)
151151
default:
152152
XCTFail("not forwarderd")
153153
}

0 commit comments

Comments
 (0)