trait SelfType[A] extends AnyRef
A type class that extracts the self-type of A
.
- Source
- SelfType.scala
Given a compound type,
trait MySelfType1 trait MyTrait1 { this: MySelfType1 => } trait MyTrait2 trait MySelfType3 trait MyTrait3 { this: MySelfType3 => } type MyCompoundType = MyTrait1 with MyTrait2 with MyTrait3 { type MyRefinement = Int }
then the self type should be a compound type of each mix-in part,
val selfType = SelfType[MyCompoundType] "implicitly[selfType.Out =:= (MySelfType1 with MySelfType3 with MyTrait1 with MyTrait2 with MyTrait3)]" should compile
and the self type should not contain the refinement statements
"implicitly[selfType.Out <:< { type MyRefinement = Int }]" shouldNot typeCheck
, Given a trait with an explicit self-type declaration,
trait MySelfType trait MyTrait { this: MySelfType => }
then the self type should be itself with the type of
this
.val selfType = SelfType[MyTrait] "implicitly[selfType.Out =:= (MySelfType with MyTrait)]" should compile
, Given a trait without an explicit self-type declaration
trait MyTrait
Then the self type should be itself
val selfType = SelfType[MyTrait] "implicitly[selfType.Out =:= MyTrait]" should compile
Examples:
Linear Supertypes
Type Hierarchy
Ordering
- Alphabetic
- By Inheritance
Inherited
- SelfType
- AnyRef
- Any
Implicitly
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
Visibility
- Public
- All
Type Members
- abstract type Out
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (SelfType[A], B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def ensuring(cond: (SelfType[A]) ⇒ Boolean, msg: ⇒ Any): SelfType[A]
- def ensuring(cond: (SelfType[A]) ⇒ Boolean): SelfType[A]
- def ensuring(cond: Boolean, msg: ⇒ Any): SelfType[A]
- def ensuring(cond: Boolean): SelfType[A]
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- def formatted(fmtstr: String): String
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def →[B](y: B): (SelfType[A], B)