I could come up with encodings (removed type parameters for simplification):
scala> :paste // Entering paste mode (ctrl-D to finish) def test0(a: A)(t : aT) = a.test(t) abstract class B{ val a: A val t: aT def test = a.test(t) } // Exiting paste mode, now interpreting. test0: (a: A)(t: aT)Unit defined class B
This, on the other hand, did not work with class class arguments (and not classes).
One of the reasons your encoding is not working:
scala> def test1(a: A)(t : A#T) = a.test(t) <console>:12: error: type mismatch; found : t.type (with underlying type A#T) required: aT def test1(a: A)(t : A#T) = a.test(t)
The important part required: aT (compared to A#T ). The validation method in A does not accept any T, it takes T this.T , or, in other words, T belonging to one particular instance of A.
pedrofurla
source share