Open vkuncak opened 1 month ago
Same error message if I define test
as
def test: Unit = {
def w: Spec = Wrapper(new Wrapper(w) { })
()
}
An explicit asInstanceOf
test works and this passes entirely (there are no methods to cause infinite recursion):
object WrapperTest:
trait Spec { }
case class Wrapper(underlying: Spec) extends Spec { }
def test: Unit = {
def w: Wrapper = Wrapper((new Wrapper(w) { }).asInstanceOf[Wrapper])
()
}
end WrapperTest
So it looks like there's some limitation in how our type checker or extractor uses expected type in the presence of subtyping with anonymous classes
This code:
gives the error message below. It seems fine to reject such wrapper as it causes non-termination etc., but we seem to reject by way of an internal error and possibly by accident, so we should at least report a meaningful error to the user.