mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
If the enum has a raw value, `E` passed in to `BinaryExpr` is a `DeclRefExpr`, not a `DotSyntaxCallExpr`, so we crashed on `dyn_cast<DotSyntaxCallExpr>(E->getFn())->getFn()`. Only look through `DotSyntaxCallExpr` if `E` is indeed a `DotSyntaxCallExpr`. While at it, fix a few other potential sources of nullptr crashes. rdar://84707973
23 lines
558 B
Swift
23 lines
558 B
Swift
enum EnumWithUnderlyingValue: String {
|
|
case north, south, east, west
|
|
}
|
|
|
|
|
|
|
|
func foo(test: EnumWithUnderlyingValue) {
|
|
if test == .north {
|
|
print("north")
|
|
} else if test == .south {
|
|
print("south")
|
|
} else if test == .east {
|
|
print("east")
|
|
}
|
|
}
|
|
|
|
|
|
// RUN: %empty-directory(%t.result)
|
|
|
|
// RUN: %refactor -convert-to-switch-stmt -source-filename %s -pos=8:3 -end-pos=14:4 > %t.result/L8-3.swift
|
|
// RUN: %target-swift-frontend-typecheck %t.result/L8-3.swift
|
|
// RUN: diff -u %S/Outputs/enum_with_raw_value/L8-3.swift.expected %t.result/L8-3.swift
|