Scala can correctly resolve tail recursive calls. But your method is not tail recursive. You can check it using annotation @annotaion.tailrec.
@annotation.tailrec
def foldTerm[F[+_], A, B](e: Free[F, A], pure: A โ B, imp: F[B] โ B)(implicit F: Functor[F]): B =
e.resume match {
case Right(a) โ pure(a)
case Left(x) โ imp(F.map(x)(foldTerm(_, pure, imp)))
}
<console>:19: error: could not optimize @tailrec annotated method foldTerm: it contains a recursive call not in tail position
case Left(x) โ imp(F.map(x)(foldTerm(_, pure, imp)))
imp, foldTerm.