It’s understandable if the answer is no. But if yes, please tell how that works.
I am asking because the following code does not give compile time errors:
// This is an internal type.
struct InternalType: CustomStringConvertible {
var description: String = "Hi, there"
var value: Int
}
// This function is public and returns an opaque type.
public func createOpaqueType() -> some CustomStringConvertible {
return InternalType(value: 42)
}
As far as outside is concerned, it can use the return only as a CustomStringConvertible. But does not the compiler needs to have access to the underlying type?