func toAH<X>(_ x: X) -> AnyHashable { x as! AnyHashable } let s = "foo" let os = Optional(s) print(type(of: toAH(s)), type(of: toAH(os)), type(of: toAH(s) as Any), type(of: toAH(os) as Any))