Skip to content

Instantly share code, notes, and snippets.

@tarunon
Last active March 29, 2017 05:06
Show Gist options
  • Save tarunon/f211f246d126d6ffdbdb931a2b95e084 to your computer and use it in GitHub Desktop.
Save tarunon/f211f246d126d6ffdbdb931a2b95e084 to your computer and use it in GitHub Desktop.
Cannot compile code on Swift 3.1
protocol X {}
extension String: X {}
enum A {
case hoge(Any)
case fuga(X)
}
let a = A.fuga("hello")
switch a {
case .hoge(let x as X),
.fuga(let x):
print(x)
default:
break
}
@tarunon
Copy link
Author

tarunon commented Mar 29, 2017

enumのcaseの変数をprotocol型で取り出そうとするとコンパイルが通らなくなるようだ。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment