Why do I get 'A function is marked as tail-recursive but no tail calls are found' and 'Recursive call is not a tail call'? Is there a way to make this function work with tailrec?
Copy code
class Container(
val name: String,
val parent: Container?
)
// WARNING A function is marked as tail-recursive but no tail calls are found
tailrec fun Container.rootParent() : Container {
return parent?.rootParent() // WARNING Recursive call is not a tail call
?: this
}