Understanding the interaction in Scala between self-types and type bounds?

Your first error is the simpler one, and easily solved by your final solution. The self type R in the declaration RecordPK, R Your final solution states the constraint again and that's the end of it Your second version is more complicated. I'll start with the second error first, some elements from the Circumflex API not stated above Record has an abstract def relation: RelationPK, R TableK,R extends RelationK,R You define relation in the class User as the object User which is a TableInt, User hence a RelationInt, User However, your class User is a MyRecordInt, User but that means it is a RecordInt, MyRecordInt, User not a RecordInt, User The R of Record (the one that matters here) is MyRecordInt, User not User relation must thus be RelationInt, MyRecordInt, User A RelationInt, User is not a RelationInt, MyRecordInt, User even when User is a MyRecordInt, User In general, if B is an A CB is not a CA except if class C states so by being declared C+X rather than CX (hence the message about Relation being invariant (no +), and suggesting a R so that it would be covariant in R ) I'm really less sure about the error in DefinitionHelper.It seems related to the R being MyRecordInt, User  again.

If you explicitly state that as the generic parameter R doing new DefinitionHelperMyRecordInt, User("", this) it should work (I did it on an example quite close to your code, but not actually using circumflex). Why the compiler does not infer that, I do not know. Anyway, the fact that your User is not a RecordInt, User but RecordInt, MyRecordInt, User is bound to cause problems.

The actual solution is much simpler.

Your first error is the simpler one, and easily solved by your final solution. The self type R=> in the declaration RecordPK, R forces every descendant of Record to ensure that it will be an R too (it does not make it an R, the descendant will have to do something to be an R). In practice, that means that in class X extends RecordPK, R, R must be an ancestor of X (and as there is also R This constraint disappears in MyRecord, hence your first error.

Your final solution states the constraint again and that's the end of it. Your second version is more complicated. I'll start with the second error.

First, some elements from the Circumflex API not stated above. Record has an abstract def relation: RelationPK, R TableK,R extends RelationK,R You define relation in the class User as the object User, which is a TableInt, User, hence a RelationInt, User. However, your class User is a MyRecordInt, User, but that means it is a RecordInt, MyRecordInt, User, not a RecordInt, User.

The R of Record (the one that matters here) is MyRecordInt, User, not User. Relation must thus be RelationInt, MyRecordInt, User. A RelationInt, User is not a RelationInt, MyRecordInt, User, even when User is a MyRecordInt, User.In general, if B is an A, CB is not a CA, except if class C states so by being declared C+X rather than CX.

(hence the message about Relation being invariant (no +), and suggesting a +R so that it would be covariant in R). I'm really less sure about the error in DefinitionHelper.It seems related to the R being MyRecordInt, User again. If you explicitly state that as the generic parameter R, doing new DefinitionHelperMyRecordInt, User("", this) it should work (I did it on an example quite close to your code, but not actually using circumflex).

Why the compiler does not infer that, I do not know. Anyway, the fact that your User is not a RecordInt, User but RecordInt, MyRecordInt, User is bound to cause problems. The actual solution is much simpler.

In scala 2.9.0. And it produces false, as expected. Unfortunately, it gets downhill from here.

Oh, well, I'd expect the type variable P in CustomisableComparator to be bound to IdParser, so I'm not quite sure why scala thinks it's Parser in the default value. This is well confusing. If I don't provide a value, the compiler expects (this.

IdParser#Result) => Boolean; once I do provide a value of this type, it expects (?#Result,? #Result) => Boolean. Can anyone explain what is going on here?

Your first error is the simpler one, and easily solved by your final solution. The self type R in the declaration.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions