Skip to content

Commit 6f2c9cb

Browse files
committed
[ASTGen] Handle back-ticked names as identifiers
1 parent 15dc2e9 commit 6f2c9cb

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

lib/AST/CASTBridging.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ void SwiftDiagnostic_finish(BridgedDiagnostic diagPtr) {
119119
BridgedIdentifier
120120
SwiftASTContext_getIdentifier(void *ctx, const unsigned char *_Nullable str,
121121
long len) {
122+
// If this was a back-ticked identifier, drop the back-ticks.
123+
if (len >= 2 && str[0] == '`' && str[len-1] == '`') {
124+
++str;
125+
len -= 2;
126+
}
127+
122128
return const_cast<void *>(
123129
static_cast<ASTContext *>(ctx)
124130
->getIdentifier(

test/ASTGen/types.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ASTGenTypes
2+
3+
// -enable-experimental-feature requires an asserts build
4+
// REQUIRES: asserts
5+
6+
7+
func test7(_ b: inout Bool) {
8+
b = true
9+
}
10+
11+
struct X { struct `Protocol` { } }
12+
13+
func test10(_: X.`Protocol`) { }

test/ASTGen/verify-parse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// REQUIRES: executable_test
55

6-
// -enable-experimental-feature requires and asserts build
6+
// -enable-experimental-feature requires an asserts build
77
// REQUIRES: asserts
88

99
func test1(x: Int, fn: (Int) -> Int) -> Int {

0 commit comments

Comments
 (0)