Files
swift-mirror/test/Sema/switch-ownership.swift
Rintaro Ishizaki 71b24665fa [ASTDumper] Dump DeclContext
* Include `DeclContext` of the node where possible
* Add 'default-with-decl-contexts' dump style that dumps the dect context
  hierarchy in addition to the AST
* Support `-dump-parse` with `-dump-ast-format json`
2025-02-12 10:53:33 -08:00

59 lines
1.8 KiB
Swift

// RUN: %target-swift-frontend -typecheck -dump-ast %s | %FileCheck %s
struct A {
static func ~=(pattern: B, subject: A) -> Bool { return true }
static func ~=(pattern: C, subject: borrowing A) -> Bool { return true }
static func ~=(pattern: D, subject: consuming A) -> Bool { return true }
}
struct B { }
struct C { }
struct D { }
struct E { }
struct F { }
struct G { }
func ~=(pattern: E, subject: A) -> Bool { return true }
func ~=(pattern: F, subject: borrowing A) -> Bool { return true }
func ~=(pattern: G, subject: consuming A) -> Bool { return true }
// CHECK-LABEL: (func_decl{{.*}} "test(value:)"
func test(value: A) {
// CHECK: (switch_stmt
switch value {
// CHECK: (case_stmt
// CHECK: (case_label_item ownership=borrowing
// CHECK: (pattern_expr type="A" {{.*}} ownership=borrowing
case B():
break
// CHECK: (case_stmt
// CHECK: (case_label_item ownership=borrowing
// CHECK: (pattern_expr type="A" {{.*}} ownership=borrowing
case C():
break
// CHECK: (case_stmt
// CHECK: (case_label_item ownership=borrowing
// CHECK: (pattern_expr type="A" {{.*}} ownership=consuming
case D():
break
// CHECK: (case_stmt
// CHECK: (case_label_item ownership=borrowing
// CHECK: (pattern_expr type="A" {{.*}} ownership=borrowing
case E():
break
// CHECK: (case_stmt
// CHECK: (case_label_item ownership=borrowing
// CHECK: (pattern_expr type="A" {{.*}} ownership=borrowing
case F():
break
// CHECK: (case_stmt
// CHECK: (case_label_item ownership=borrowing
// CHECK: (pattern_expr type="A" {{.*}} ownership=consuming
case G():
break
// CHECK: (case_stmt
// CHECK: (case_label_item default ownership=borrowing
default:
break
}
}