Files
swift-mirror/test/Constraints/issue-60806.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

32 lines
701 B
Swift

// RUN: %target-swift-frontend -dump-ast %s | %FileCheck %s
// https://github.com/apple/swift/issues/60806
struct Foo<T> {
init(_: (T) -> Void) {}
}
protocol Bar {}
enum Baz: Bar {
case someCase(Int)
}
enum NonBarBaz {
case someCase(Int)
}
let _: Foo<Bar> = Foo<Bar> { (a: Bar) -> Void in
switch a {
// CHECK: (pattern_is type="any Bar" cast_kind=value_cast cast_to="Baz"
// CHECK-NEXT: (pattern_enum_element type="Baz" {{.*}} element="Baz.someCase"
case let .someCase(value) as Baz:
print(value)
// expected-warning@-1 {{cast from 'any Bar' to unrelated type 'NonBarBaz' always fails}}
case let .someCase(value) as NonBarBaz:
print(value)
default:
break
}
}