Monto Type Hierarchy Question

34 views
Skip to first unread message

AGYNAMIX Torsten Uhlmann

unread,
Oct 16, 2012, 12:52:47 PM10/16/12
to lif...@googlegroups.com
Hi,

I have a question on extending MongoMetaRecord or more specifically, an error I get while doing so and I can not figure out what's the problem.

I try to create a trait:

trait StructuredDbObject[BaseRecord <: MongoRecord[BaseRecord]] 
      extends MongoMetaRecord[BaseRecord]

This gives me the compiler error:

illegal inheritance;  self-type StructuredDbObject[BaseRecord] does not conform to net.liftweb.mongodb.record.MongoMetaRecord[BaseRecord]'s selftype net.liftweb.mongodb.record.MongoMetaRecord[BaseRecord] with BaseRecord

Looking at the MongoMetaRecord definition it has the same type definition as above:

trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]

Can you point me to the mistake I'm making, please?

Thanks,
Torsten.




Tobias Pfeiffer

unread,
Oct 16, 2012, 4:40:56 PM10/16/12
to lif...@googlegroups.com
Hi Torsten,

Am Dienstag, 16. Oktober 2012, 18:52 schrieb AGYNAMIX Torsten Uhlmann:
> I try to create a trait:
>
> trait StructuredDbObject[BaseRecord <: MongoRecord[BaseRecord]]
> extends MongoMetaRecord[BaseRecord]
>
> This gives me the compiler error:
>
> illegal inheritance; self-type StructuredDbObject[BaseRecord] does
> not conform to
> net.liftweb.mongodb.record.MongoMetaRecord[BaseRecord]'s selftype
> net.liftweb.mongodb.record.MongoMetaRecord[BaseRecord] with
> BaseRecord
>
> Looking at the MongoMetaRecord definition it has the same type
> definition as above:
>
> trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]

However, MongoMetaRecord's Self type is
MongoMetaRecord[BaseRecord] with BaseRecord
see <http://scala-
tools.org/mvnsites/liftweb-2.4/#net.liftweb.mongodb.record.MongoMetaRecord>
and <http://www.scala-lang.org/node/124>

So maybe try to add a self type as well or write
trait StructuredDbObject[BaseRecord <: MongoRecord[BaseRecord]]
extends BaseRecord with MongoMetaRecord[BaseRecord]
or something?

Tobias
signature.asc

AGYNAMIX Torsten Uhlmann

unread,
Oct 17, 2012, 3:23:51 AM10/17/12
to lif...@googlegroups.com
Thanks, Tobias, for your help!

It turns out I really just missed declaring the self type:

trait StructuredDbObject[BaseRecord <: MongoRecord[BaseRecord]] 
      extends MongoMetaRecord[BaseRecord] {

  self: BaseRecord =>
  ...
}

Adding that "self" declaration does miracles to the compiler :)

Thanks,
Torsten.

-- 
AGYNAMIX(R). Passionate Software.
Inh. Torsten Uhlmann | Buchenweg 5 | 09380 Thalheim
Phone:       +49 3721 273445
Fax:             +49 3721 273446
Mobile:       +49 151 12412427
Web:           http://www.agynamix.de
Reply all
Reply to author
Forward
0 new messages