Skip to content

Commit bc8d673

Browse files
authored
Merge pull request #42575 from hamishknight/regex-availability-5.7
2 parents 308df90 + af2af52 commit bc8d673

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,6 +2958,13 @@ class ExprAvailabilityWalker : public ASTWalker {
29582958
maybeDiagStorageAccess(S->getDecl().getDecl(), S->getSourceRange(), DC);
29592959
}
29602960
}
2961+
if (auto *RLE = dyn_cast<RegexLiteralExpr>(E)) {
2962+
// Regex literals require both the Regex<Output> type to be available, as
2963+
// well as the initializer that is implicitly called.
2964+
auto Range = RLE->getSourceRange();
2965+
diagnoseDeclRefAvailability(Context.getRegexDecl(), Range);
2966+
diagnoseDeclRefAvailability(RLE->getInitializer(), Range);
2967+
}
29612968
if (auto KP = dyn_cast<KeyPathExpr>(E)) {
29622969
maybeDiagKeyPath(KP);
29632970
}

test/StringProcessing/Frontend/enable-flag.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -enable-experimental-string-processing
2-
// RUN: %target-typecheck-verify-swift -enable-experimental-string-processing -enable-bare-slash-regex
3-
// RUN: %target-typecheck-verify-swift -disable-experimental-string-processing -enable-experimental-string-processing -enable-bare-slash-regex
1+
// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-bare-slash-regex -enable-experimental-string-processing
2+
// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-string-processing -enable-bare-slash-regex
3+
// RUN: %target-typecheck-verify-swift -disable-availability-checking -disable-experimental-string-processing -enable-experimental-string-processing -enable-bare-slash-regex
44

55
// REQUIRES: swift_in_compiler
66

test/StringProcessing/SILGen/regex_literal_silgen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-silgen -enable-bare-slash-regex %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -emit-silgen -enable-bare-slash-regex -disable-availability-checking %s | %FileCheck %s
22
// REQUIRES: swift_in_compiler
33

44
var s = #/abc/#
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -target %target-cpu-apple-macosx12.0
2+
3+
// REQUIRES: swift_in_compiler
4+
// REQUIRES: OS=macosx
5+
6+
_ = /x/ // expected-error {{'Regex' is only available in}}
7+
// expected-note@-1 {{add 'if #available' version check}}
8+
9+
_ = #/x/# // expected-error {{'Regex' is only available in}}
10+
// expected-note@-1 {{add 'if #available' version check}}
11+
12+
if #available(SwiftStdlib 5.7, *) {
13+
_ = /x/
14+
_ = #/x/#
15+
}

0 commit comments

Comments
 (0)