jon suggested to me the way to avoid both explicit type parameter and
asinstance of:
trait Timestamp[MapperType <: TimeStamp[MapperType]] extends Mapper
[MapperType] {
self:MapperType =>
object xdatetime extends MappedDateTime(this)

  // all sorts of utility functions for dealing with timestamps

}
Thanks jon I have improved model in my application with this approach.

Giuseppe

On 3 Set, 16:16, Giuseppe Fogliazza <g.foglia...@mcmspa.it> wrote:
> As an alternative to asInstanceOf you could use explicit type
> parameter in MappedField creation:
> self:MapperType =>
> object xdatetime extends MappedDateTime[MapperType](this)
>
> On 3 Set, 09:19, Giuseppe Fogliazza <g.foglia...@mcmspa.it> wrote:
>
> > Unfortunately you cannot escape from asInstanceOf . Forcing
> > self:MapperType the type of "this" will be TimeStamp with MapperType
> > violating the constraint for the type of the first parameter of
> > MappedDateTime :T <: Mapper[T].
>
> > Regards
> > Giuseppe
>
> > On 3 Set, 07:08, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
>
> > > So I guess you can't escape the asInstanceOf. Can you successfully give 
> > > the trait a self-type of this: MapperType =>, or declare it to extend 
> > > Mapper[MapperType], without running into problems elsewhere?
>
> > > -------------------------------------
>
> > > harryh<har...@gmail.com> wrote:
>
> > > I've been handling this with traits, for example I have something like
> > > so:
>
> > > trait Timestamp[MapperType <: Mapper[MapperType]] {
> > >   object xdatetime extends MappedDateTime[MapperType](this.asInstanceOf
> > > [MapperType])
>
> > >   // all sorts of utility functions for dealing with timestamps
>
> > > }
>
> > > Then I can do
>
> > > class Foo extends LongKeyedMapper[Foo] with IdPK with Timestamp[Foo] {
> > >   // additional fields that are Foo specific
>
> > > }
>
> > > I have quite a few traits similar to Timestamp at this point
> > > corresponding to various fields that appear in lots of different
> > > tables in my application.
>
> > > -harryh

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to