I'm playing around with the compiler and I have a ValueDecl whose Type that evaluates to (Square) -> () -> Double when using getInterfaceType(). How do I get Double from that example?
You could try this
if(auto fnTy = declVar->getInterfaceType()->getAs<AnyFunctionType>()) {
if (auto resultFnTy = fnTy->getResult()->getAs<AnyFunctionType>()) { // Get result () -> Double as FunctionType
auto result = resultFnTy->getResult() // Double
}
}
1 Like
If the valueDecl is a FuncDecl, you can also call getResultInterfaceType() to directly get Double there.
1 Like
danielfalbo
(Daniel Falbo)
4
Thank you! It's perfect :)