File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,7 @@ bool Expr::isSemanticallyConstExpr() const {
209
209
case ExprKind::BooleanLiteral:
210
210
case ExprKind::FloatLiteral:
211
211
case ExprKind::StringLiteral:
212
+ case ExprKind::KeyPath:
212
213
return true ;
213
214
case ExprKind::Array:
214
215
case ExprKind::Dictionary: {
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
2
+
3
+ struct Article {
4
+ let id : String
5
+ }
6
+
7
+ let keypath = \Article . id
8
+ func keypath_generator( ) -> KeyPath < Article , String > { return \. id }
9
+ func const_map( _const _ map: KeyPath < Article , String > ) { }
10
+
11
+ const_map ( \. id)
12
+ const_map ( \Article . id)
13
+
14
+ const_map ( keypath_generator ( ) ) // expected-error {{expect a compile-time constant literal}}
15
+ const_map ( keypath) // expected-error {{expect a compile-time constant literal}}
You can’t perform that action at this time.
0 commit comments