Better type inference for Scala: send us your problematic cases!

I maintain a project (https://chisel.eecs.berkeley.edu/) where our users commonly use anonymous classes as in the following pattern:

Example 1

Implementing trait field with anonymous subclass:

abstract class Foo
trait Bar {
  def foo: Foo
}
object Test extends App with Bar {
  val foo = new Foo {
    val x = 3
  }
  println(foo.x)
}

This is my main use case but there is a similar one:

Example 2

Merely having a field that is an anonymous subclass:

abstract class Foo
object Test extends App {
  val foo = new Foo {
    val x = 3
  }
  println(foo.x)
}

The above examples can also be found on my Github repo: https://github.com/jackkoenig/scala-anon-class-type-inference