File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -3256,13 +3256,15 @@ class ExprAvailabilityWalker : public ASTWalker {
3256
3256
}
3257
3257
3258
3258
if (auto *LE = dyn_cast<LiteralExpr>(E)) {
3259
- auto Range = LE->getSourceRange ();
3260
- if (auto *RLE = dyn_cast<RegexLiteralExpr>(LE)) {
3261
- // Regex literals require both the Regex<Output> type to be available,
3262
- // as well as the initializer that is implicitly called.
3263
- diagnoseDeclRefAvailability (Context.getRegexDecl (), Range);
3259
+ if (auto literalType = LE->getType ()) {
3260
+ // Check availability of the type produced by implicit literal
3261
+ // initializer.
3262
+ if (auto *nominalDecl = literalType->getAnyNominal ()) {
3263
+ diagnoseDeclAvailability (nominalDecl, LE->getSourceRange (),
3264
+ /* call=*/ nullptr , Where);
3265
+ }
3264
3266
}
3265
- diagnoseDeclRefAvailability (LE->getInitializer (), Range );
3267
+ diagnoseDeclRefAvailability (LE->getInitializer (), LE-> getSourceRange () );
3266
3268
}
3267
3269
3268
3270
if (auto *CE = dyn_cast<CollectionExpr>(E)) {
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift -swift-version 5
2
+
3
+ // https://github.com/apple/swift/issues/61890
4
+
5
+ @available ( * , unavailable)
6
+ struct S : ExpressibleByStringLiteral { // expected-note{{'S' has been explicitly marked unavailable here}}
7
+ init ( stringLiteral value: String ) { }
8
+ }
9
+ @available ( * , unavailable)
10
+ typealias StringLiteralType = S
11
+
12
+ let i = " " // expected-error{{'S' is unavailable}}
13
+
14
+ @available ( * , unavailable)
15
+ struct S1 < T> : ExpressibleByIntegerLiteral { // expected-note{{'S1' has been explicitly marked unavailable here}}
16
+ init ( integerLiteral value: Int ) { }
17
+ }
18
+ @available ( * , unavailable)
19
+ typealias IntegerLiteralType = S1 < Int >
20
+
21
+ let a = 0 // expected-error{{'S1' is unavailable}}
You can’t perform that action at this time.
0 commit comments