final case class Extractor(whole: Type, fixed: List[Type], repeated: Repeated, typeOfSinglePattern: Type) extends Product with Serializable
An 'extractor' can be a case class or an unapply or unapplySeq method. Decoding what it is that they extract takes place before we arrive here, so that this class can concentrate only on the relationship between patterns and types.
In a case class, the class is the unextracted type and the fixed and repeated types are derived from its constructor parameters.
In an unapply, this is reversed: the parameter to the unapply is the unextracted type, and the other types are derived based on the return type of the unapply method.
In other words, this case class and unapply are encoded the same:
case class Foo(x: Int, y: Int, zs: Char*) def unapplySeq(x: Foo): Option[(Int, Int, Seq[Char])]
Both are Extractor(Foo, Int :: Int :: Nil, Repeated(Seq[Char], Char, Char*))
- whole
The type in its unextracted form
- fixed
The non-sequence types which are extracted
- repeated
The sequence type which is extracted
- Source
- PatternExpander.scala
- Alphabetic
- By Inheritance
- Extractor
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
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): (Extractor, B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def allTypes: collection.immutable.List[Type]
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
asSinglePattern: Extractor
A pattern with arity-1 that doesn't match the arity of the Product-like result of the
get
method, will match that result in its entirety.A pattern with arity-1 that doesn't match the arity of the Product-like result of the
get
method, will match that result in its entirety. Example:warning: there was one deprecation warning; re-run with -deprecation for details scala> object Extractor { def unapply(a: Any): Option[(Int, String)] = Some((1, "2")) } defined object Extractor scala> "" match { case Extractor(x: Int, y: String) => } scala> "" match { case Extractor(xy : (Int, String)) => } warning: there was one deprecation warning; re-run with -deprecation for details
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- def elementType: Type
- def ensuring(cond: (Extractor) ⇒ Boolean, msg: ⇒ Any): Extractor
- def ensuring(cond: (Extractor) ⇒ Boolean): Extractor
- def ensuring(cond: Boolean, msg: ⇒ Any): Extractor
- def ensuring(cond: Boolean): Extractor
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- val fixed: List[Type]
- def formatted(fmtstr: String): String
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- def hasSeq: Boolean
- def isErroneous: Boolean
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- def offeringString: String
-
def
productArity: Int
- Definition Classes
- Extractor → Product
- val repeated: Repeated
- def sequenceType: Type
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- Extractor → AnyRef → Any
- val typeOfSinglePattern: Type
- def varargsTypes: collection.immutable.List[Type]
-
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
- @throws( ... )
- val whole: Type
- def →[B](y: B): (Extractor, B)
The Scala compiler and reflection APIs.