IDE: Fire
Version: 8.4.96.2043
Target (If relevant): Java
Description:
The compiler cannot infer the return type inside a trinary operator when the return type is same common protocol.
Example:
public func FileOrDirectory(with path: String) -> AnyFileOrDirectory {
let file = File(path: path)
return (file.isDirectory) ? Directory(path: path) : file
}
However this works fine:
public func FileOrDirectory(with path: String) -> AnyFileOrDirectory {
let file = File(path: path)
if (file.isDirectory) {
return Directory(path: path)
} else {
return file
}
}