diff --git a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift index 745f9e8a545..0d1335fd36e 100644 --- a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift +++ b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift @@ -249,7 +249,7 @@ extension StringLiteralExprSyntax { continue // Special mode: counting a sequence of pounds until we reach its end. - case (true, "#"): + case (true, _) where c.unicodeScalars.contains("#"): consecutivePounds += 1 maxPounds = max(maxPounds, consecutivePounds) case (true, _): diff --git a/Tests/SwiftSyntaxBuilderTest/StringLiteralTests.swift b/Tests/SwiftSyntaxBuilderTest/StringLiteralTests.swift index 2311fbcd50a..76da43a3cf3 100644 --- a/Tests/SwiftSyntaxBuilderTest/StringLiteralTests.swift +++ b/Tests/SwiftSyntaxBuilderTest/StringLiteralTests.swift @@ -71,6 +71,15 @@ final class StringLiteralTests: XCTestCase { ) } + func testEscapePoundEmojis() { + assertBuildResult( + StringLiteralExprSyntax(content: ##"foo"#️⃣"bar"##), + """ + ##"foo"#️⃣"bar"## + """ + ) + } + func testEscapeInteropolation() { assertBuildResult( StringLiteralExprSyntax(content: ###"\##(foobar)\#(foobar)"###),