Classic
way.
Classic
way. Original idea: Miles Sabin
Lift ( Adopted and simplified from: https://github.com/softwaremill/scala-common/blob/master/tagging/src/main/scala/com/softwaremill/tagging/TypeclassTaggingCompat.scala) *
New name: Overtagged
For pretty coding value @@ MyTag
Making universal trait for overcoming feature bug
(knowing as [I cannot be cast to [Ljava.lang.Object;
- see at TestScalacBug).
Making universal trait for overcoming feature bug
(knowing as [I cannot be cast to [Ljava.lang.Object;
- see at TestScalacBug).
Everything seems ok for now. There is no runtime overhead(after jit). Casting doesn't change memory model, boxing for primitive types appears only at specific corner cases and JIT cleans generated rubbish bytecode very well
Example:
def method(v:Width)
object Width extends TaggedType[Int]
type Width = Width.Type // this for pretty coding:
Need one more trait in chain.
Need one more trait in chain. Do not cut and optimize it!
Magic starts here *
Original idea (using base trait
TaggedType
&type Companion = Companion.Type
from: Alexander Semenov (https://github.com/Treev-io/tagged-types)Enhanced with unified syntax, recursive(on type level) tagging and overcoming some compiler bugs