mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* 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`
32 lines
701 B
Swift
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
|
|
}
|
|
}
|