trait Glb[Mixin] extends Serializable
A type class that converts a mix-in type to the greatest lower bound of the components of the mix-in.
This Glb type class provides an extension method glb via implicit view, which can be import as follow:
import com.thoughtworks.feature.Glb.ops._
Author:
杨博 (Yang Bo) <[email protected]>
- Source
- Glb.scala
Given a mix-in of two refinement components,
type A = Option[Any] { def get: Immutable } type B = Option[Any] { def get: Iterable[String] } val ab: A with B = Some(List("cool"))
when convert it to its greatest lower bound,
val glbOfAB = toAllGlbOps(ab).glb
Then the common method should return the greatest lower bound of each components's return type.
val result: Immutable with Iterable[String] = glbOfAB.get result should be(List("cool"))
- Note
This Glb type class is implemented via scala.reflect.api.Types.glb, which is similar to intersection operator in Dotty, except this Glb works for refinement type only.
,The implicit conversion toAllGlbOps must be explicitly invoked, as a workaround of https://github.com/scala/bug/issues/10671
Example:
Linear Supertypes
Type Hierarchy
Ordering
- Alphabetic
- By Inheritance
Inherited
- Glb
- Serializable
- Serializable
- Any
Implicitly
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
Visibility
- Public
- All
Type Members
- abstract type Out >: Mixin <: Mixin
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
- def +(other: String): String
- def ->[B](y: B): (Glb[Mixin], B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def ensuring(cond: (Glb[Mixin]) ⇒ Boolean, msg: ⇒ Any): Glb[Mixin]
- def ensuring(cond: (Glb[Mixin]) ⇒ Boolean): Glb[Mixin]
- def ensuring(cond: Boolean, msg: ⇒ Any): Glb[Mixin]
- def ensuring(cond: Boolean): Glb[Mixin]
-
def
equals(arg0: Any): Boolean
- Definition Classes
- Any
- def formatted(fmtstr: String): String
-
final
def
glb(mixin: Mixin): Out
- Annotations
- @inline()
-
def
hashCode(): Int
- Definition Classes
- Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
toString(): String
- Definition Classes
- Any
- def →[B](y: B): (Glb[Mixin], B)