I think we might be able to accommodate your usecase with only minimal changes on your side. In Dotty, structural types need to be converted to Selectable
to access the structural members (see Proposal for programmatic structural types for the details), so maybe we could just tweak type inference to make new Foo { val x = 3 }
infer Foo { val x: Int }
if the expected type is a subtype of Structural
, which would be the case if you write def func[T <: Structural](in: T): T
.
2 Likes