Avatar
swiftbot BOT 6/1/2018 11:24 AM
(edited)
Author icon
tarunon
import Foundation func foo<T: Any>(x: T) { print(x) } func bar<T: AnyObject>(x: T) { print(x) } foo(x: "") // bar(x: "") // 🙅 bar(x: "" as AnyObject)// 🙆
Version:
swift-4.1.1-RELEASE
Output:
Error:
/usercode/main.swift:13:11: error: 'String' is not convertible to 'AnyObject'; did you mean to use 'as!' to force downcast? bar(x: "" as AnyObject)// 🙆