Skip to content

Commit c58a096

Browse files
committed
unified: Fix translation of callee in constructor pattern
1 parent a658c77 commit c58a096

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

unified/extractor/src/languages/swift/swift.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,14 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
655655
(call_expr callee: {callee} argument: {args} argument: (argument value: {tc}))
656656
),
657657
rule!(
658-
(functionCallExpr calledExpression: @callee arguments: _* @args)
658+
(functionCallExpr calledExpression: @@rawCallee arguments: _* @args)
659659
=>
660660
expr {
661+
// Always translate the callee in non-pattern context.
662+
let callee = ctx.scoped(|ctx| {
663+
ctx.in_pattern = false;
664+
ctx.translate(rawCallee)
665+
})?;
661666
if ctx.in_pattern {
662667
tree!((constructor_pattern constructor: {callee} element: {args}))
663668
} else {

unified/extractor/tests/corpus/swift/control-flow/nested-enum-case-pattern.output

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,8 @@ top_level
210210
constructor:
211211
member_access_expr
212212
base:
213-
expr_equality_pattern <-- ERROR: The field member_access_expr.base should contain expr_or_type, but got expr_equality_pattern
214-
expr:
215-
name_expr
216-
identifier: identifier "Type"
213+
name_expr
214+
identifier: identifier "Type"
217215
member: identifier "some"
218216
element:
219217
pattern_element

0 commit comments

Comments
 (0)