We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type(of:)
Any
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5) Target: x86_64-apple-darwin18.6.0
md5: 28e4c63a4392471a79a2bbe4ebaf35e0
Issue Description:
fileprivate protocol Wrapper { static func baseType(level: inout Int) -> Any.Type func baseType(level: inout Int) -> Any.Type } extension Optional: Wrapper { fileprivate static func baseType(level: inout Int) -> Any.Type { level += 1 switch Wrapped.self { case let wrapper as Wrapper.Type: return wrapper.baseType(level: &level) default: return Wrapped.self } } func baseType(level: inout Int) -> Any.Type { level += 1 switch self { case .some(let wrapper as Wrapper): return wrapper.baseType(level: &level) case .some(let wrapped): return type(of: wrapped) case .none: return Optional.baseType(level: &level) } } } let wrappedValue: String? = "Swift" let test_1: Any?? = wrappedValue let test_2: Any?? = Optional(wrappedValue as Any) var level = 0 // THIS SHOULD BE `String 2` not `Any 2` print(test_1.baseType(level: &level), level) // prints `Any 2` level = 0 print(test_2.baseType(level: &level), level) // prints `String 3`
Discussion on the forums where the bug first appeared: https://forums.swift.org/t/challenge-finding-base-type-of-nested-optionals/25096
The text was updated successfully, but these errors were encountered:
@jckarter, there's a dup of this that explains the behavior, right?
Sorry, something went wrong.
No branches or pull requests
Environment
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Target: x86_64-apple-darwin18.6.0
Additional Detail from JIRA
md5: 28e4c63a4392471a79a2bbe4ebaf35e0
Issue Description:
Discussion on the forums where the bug first appeared: https://forums.swift.org/t/challenge-finding-base-type-of-nested-optionals/25096
The text was updated successfully, but these errors were encountered: