Skip to content

Commit 1e6e6e9

Browse files
committed
[BuilderTransform] NFC: Adjust variable declaration tests
With AST transform enabled by default most of the previously invalid declarations became valid (due to SE-0373 being implemented only for AST transform).
1 parent b01d21b commit 1e6e6e9

File tree

3 files changed

+57
-56
lines changed

3 files changed

+57
-56
lines changed

test/Constraints/result_builder_diags.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ enum Either<T,U> {
66
}
77

88
@resultBuilder
9-
struct TupleBuilder { // expected-note 3 {{struct 'TupleBuilder' declared here}}
9+
struct TupleBuilder { // expected-note {{struct 'TupleBuilder' declared here}}
1010
static func buildBlock() -> () { }
1111

1212
static func buildBlock<T1>(_ t1: T1) -> T1 {
@@ -99,15 +99,13 @@ func testDiags() {
9999
tuplify(true) { _ in
100100
17
101101
let x = 17
102-
let y: Int // expected-error{{local variable 'y' requires explicit initializer to be used with result builder 'TupleBuilder'}} {{15-15= = <#value#>}}
102+
let y: Int // Ok
103103
x + 25
104104
}
105105

106106
tuplify(true) { _ in
107107
17
108-
let y: Int, z: String
109-
// expected-error@-1 {{local variable 'y' requires explicit initializer to be used with result builder 'TupleBuilder'}} {{15-15= = <#value#>}}
110-
// expected-error@-2 {{local variable 'z' requires explicit initializer to be used with result builder 'TupleBuilder'}} {{26-26= = <#value#>}}
108+
let y: Int, z: String // Ok
111109
y + 25
112110
}
113111

test/Constraints/result_builder_invalid_vars.swift

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
@resultBuilder
4+
struct DummyBuilder {
5+
static func buildBlock<T>(_ t: T) -> T {
6+
return t
7+
}
8+
}
9+
10+
func dummy<T>(@DummyBuilder _: () -> T) {}
11+
12+
dummy {
13+
var computedVar: Int { return 123 }
14+
()
15+
}
16+
17+
dummy {
18+
lazy var lazyVar: Int = 123
19+
()
20+
}
21+
22+
dummy {
23+
var observedVar: Int = 123 {
24+
// expected-warning@-1 {{variable 'observedVar' was never used; consider replacing with '_' or removing it}}
25+
didSet {}
26+
}
27+
28+
()
29+
}
30+
31+
dummy {
32+
var observedVar: Int = 123 {
33+
// expected-warning@-1 {{variable 'observedVar' was never used; consider replacing with '_' or removing it}}
34+
willSet {}
35+
}
36+
37+
()
38+
}
39+
40+
@propertyWrapper struct Wrapper {
41+
var wrappedValue: Int
42+
}
43+
44+
dummy {
45+
@Wrapper var wrappedVar: Int = 123
46+
()
47+
}
48+
49+
dummy {
50+
@resultBuilder var attributedVar: Int = 123
51+
// expected-error@-1 {{'@resultBuilder' attribute cannot be applied to this declaration}}
52+
// expected-warning@-2 {{variable 'attributedVar' was never used; consider replacing with '_' or removing it}}
53+
()
54+
}

0 commit comments

Comments
 (0)