Skip to content

Commit c446253

Browse files
committed
Use underscored syntax for versioned canImport condition
1 parent 1698d25 commit c446253

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,7 @@ WARNING(likely_simulator_platform_condition,none,
17741774

17751775
ERROR(canimport_two_parameters, none, "canImport can take only two parameters", ())
17761776

1777-
ERROR(canimport_label, none, "2nd parameter of canImport should be labeled as version or underlyingVersion", ())
1777+
ERROR(canimport_label, none, "2nd parameter of canImport should be labeled as _version or _underlyingVersion", ())
17781778

17791779
ERROR(canimport_version, none, "cannot parse module version: %0", (StringRef))
17801780

lib/Parse/ParseIfConfig.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ static llvm::VersionTuple getCanImportVersion(TupleExpr *te,
8888
}
8989
auto label = te->getElementName(1);
9090
auto subE = te->getElement(1);
91-
if (label.str() == "version") {
91+
if (label.str() == "_version") {
9292
underlyingVersion = false;
93-
} else if (label.str() == "underlyingVersion") {
93+
} else if (label.str() == "_underlyingVersion") {
9494
underlyingVersion = true;
9595
} else {
9696
if (D) {

test/ClangImporter/versioned_canimport.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@
1515
import Simple
1616

1717
func canImportVersioned() {
18-
#if canImport(Simple, underlyingVersion: 3.3)
18+
#if canImport(Simple, _underlyingVersion: 3.3)
1919
let a = 1 // expected-warning {{initialization of immutable value 'a' was never used; consider replacing with assignment to '_' or removing it}}
2020
#endif
2121

22-
#if canImport(Simple, underlyingVersion: 1830.100)
22+
#if canImport(Simple, _underlyingVersion: 1830.100)
2323
let b = 1 // expected-warning {{initialization of immutable value 'b' was never used; consider replacing with assignment to '_' or removing it}}
2424
#endif
2525

26-
#if canImport(Simple, underlyingVersion: 1830.11)
26+
#if canImport(Simple, _underlyingVersion: 1830.11)
2727
let c = 1 // expected-warning {{initialization of immutable value 'c' was never used; consider replacing with assignment to '_' or removing it}}
2828
#endif
2929
}
3030

3131
func canNotImportVersioned() {
32-
#if canImport(Simple, underlyingVersion: 1831)
32+
#if canImport(Simple, _underlyingVersion: 1831)
3333
let a = 1
3434
#endif
3535

36-
#if canImport(Simple, underlyingVersion: 1830.101)
36+
#if canImport(Simple, _underlyingVersion: 1830.101)
3737
let b = 1
3838
#endif
3939
}

test/ClangImporter/versioned_canimport_no_version.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
import Simple
1616

1717
func canImportVersioned() {
18-
#if canImport(Simple, underlyingVersion: 3.3) // expected-warning {{cannot find user version number for Clang module 'Simple'; version number ignored}}
18+
#if canImport(Simple, _underlyingVersion: 3.3) // expected-warning {{cannot find user version number for Clang module 'Simple'; version number ignored}}
1919
#endif
2020
}

test/Parse/ifconfig_expr.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,27 @@ func ifconfigExprInExpr(baseExpr: MyStruct) {
127127
}
128128

129129
func canImportVersioned() {
130-
#if canImport(A, version: 2)
130+
#if canImport(A, _version: 2)
131131
let a = 1
132132
#endif
133133

134-
#if canImport(A, version: 2.2)
134+
#if canImport(A, _version: 2.2)
135135
let a = 1
136136
#endif
137137

138-
#if canImport(A, underlyingVersion: 4)
138+
#if canImport(A, _underlyingVersion: 4)
139139
let a = 1
140140
#endif
141141

142-
#if canImport(A, underlyingVersion: 2.200)
142+
#if canImport(A, _underlyingVersion: 2.200)
143143
let a = 1
144144
#endif
145145

146-
#if canImport(A, unknown: 2.2) // expected-error {{2nd parameter of canImport should be labeled as version or underlyingVersion}}
146+
#if canImport(A, unknown: 2.2) // expected-error {{2nd parameter of canImport should be labeled as _version or _underlyingVersion}}
147147
let a = 1
148148
#endif
149149

150-
#if canImport(A, 2.2) // expected-error {{2nd parameter of canImport should be labeled as version or underlyingVersion}}
150+
#if canImport(A, 2.2) // expected-error {{2nd parameter of canImport should be labeled as _version or _underlyingVersion}}
151151
let a = 1
152152
#endif
153153

test/Parse/versioned_canimport.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,42 @@
1313
import Foo
1414
import Bar
1515

16-
#if canImport(Bar, version: 113.331) // expected-warning {{cannot find user version number for Swift module 'Bar'; version number ignored}}
16+
#if canImport(Bar, _version: 113.331) // expected-warning {{cannot find user version number for Swift module 'Bar'; version number ignored}}
1717
#endif
1818

19-
#if canImport(Bar, version: 2) // expected-warning {{cannot find user version number for Swift module 'Bar'; version number ignored}}
19+
#if canImport(Bar, _version: 2) // expected-warning {{cannot find user version number for Swift module 'Bar'; version number ignored}}
2020
#endif
2121

2222
func canImportVersioned() {
23-
#if canImport(Foo, version: 113.331)
23+
#if canImport(Foo, _version: 113.331)
2424
let a = 1
2525
#endif
2626

27-
#if canImport(Foo, version: 113.3000)
27+
#if canImport(Foo, _version: 113.3000)
2828
let b = 1
2929
#endif
3030

31-
#if canImport(Foo, version: 114)
31+
#if canImport(Foo, _version: 114)
3232
let c = 1
3333
#endif
3434

35-
#if canImport(Foo, version: 4)
35+
#if canImport(Foo, _version: 4)
3636
let d = 1 // expected-warning {{initialization of immutable value 'd' was never used; consider replacing with assignment to '_' or removing it}}
3737
#endif
3838

39-
#if canImport(Foo, version: 113.33)
39+
#if canImport(Foo, _version: 113.33)
4040
let e = 1 // expected-warning {{initialization of immutable value 'e' was never used; consider replacing with assignment to '_' or removing it}}
4141
#endif
4242

43-
#if canImport(Foo, underlyingVersion: 113.33)
43+
#if canImport(Foo, _underlyingVersion: 113.33)
4444
let ee = 1
4545
#endif
4646

47-
#if canImport(Foo, version: 113.329)
47+
#if canImport(Foo, _version: 113.329)
4848
let f = 1 // expected-warning {{initialization of immutable value 'f' was never used; consider replacing with assignment to '_' or removing it}}
4949
#endif
5050

51-
#if canImport(Foo, version: 113.330)
51+
#if canImport(Foo, _version: 113.330)
5252
let g = 1 // expected-warning {{initialization of immutable value 'g' was never used; consider replacing with assignment to '_' or removing it}}
5353
#endif
5454

0 commit comments

Comments
 (0)