@@ -407,10 +407,6 @@ trait Definitions extends api.StandardDefinitions {
407407 lazy val JavaRepeatedParamClass = specialPolyClass(tpnme.JAVA_REPEATED_PARAM_CLASS_NAME , COVARIANT )(tparam => arrayType(tparam.tpe))
408408 lazy val RepeatedParamClass = specialPolyClass(tpnme.REPEATED_PARAM_CLASS_NAME , COVARIANT )(tparam => seqType(tparam.tpe))
409409
410- def dropByName (tp : Type ): Type = tp match {
411- case TypeRef (_, ByNameParamClass , arg :: Nil ) => arg
412- case _ => tp
413- }
414410 def isByNameParamType (tp : Type ) = tp.typeSymbol == ByNameParamClass
415411 def isScalaRepeatedParamType (tp : Type ) = tp.typeSymbol == RepeatedParamClass
416412 def isJavaRepeatedParamType (tp : Type ) = tp.typeSymbol == JavaRepeatedParamClass
@@ -431,29 +427,15 @@ trait Definitions extends api.StandardDefinitions {
431427 case _ => false
432428 }
433429
434- def repeatedToSingle (tp : Type ): Type = tp match {
435- case TypeRef (_, RepeatedParamClass , arg :: Nil ) => arg
436- case _ => tp
437- }
438-
439- def repeatedToSeq (tp : Type ): Type = (tp baseType RepeatedParamClass ) match {
440- case TypeRef (_, RepeatedParamClass , arg :: Nil ) => seqType(arg)
441- case _ => tp
442- }
443-
444- def seqToRepeated (tp : Type ): Type = (tp baseType SeqClass ) match {
445- case TypeRef (_, SeqClass , arg :: Nil ) => scalaRepeatedType(arg)
446- case _ => tp
447- }
448-
449- def isReferenceArray (tp : Type ) = tp match {
450- case TypeRef (_, ArrayClass , arg :: Nil ) => arg <:< AnyRefTpe
451- case _ => false
452- }
453- def isArrayOfSymbol (tp : Type , elem : Symbol ) = tp match {
454- case TypeRef (_, ArrayClass , arg :: Nil ) => arg.typeSymbol == elem
455- case _ => false
456- }
430+ // wrapping and unwrapping
431+ def dropByName (tp : Type ): Type = elementExtract(ByNameParamClass , tp) orElse tp
432+ def repeatedToSingle (tp : Type ): Type = elementExtract(RepeatedParamClass , tp) orElse tp
433+ def repeatedToSeq (tp : Type ): Type = elementTransform(RepeatedParamClass , tp)(seqType) orElse tp
434+ def seqToRepeated (tp : Type ): Type = elementTransform(SeqClass , tp)(scalaRepeatedType) orElse tp
435+ def isReferenceArray (tp : Type ) = elementTest(ArrayClass , tp)(_ <:< AnyRefTpe )
436+ def isArrayOfSymbol (tp : Type , elem : Symbol ) = elementTest(ArrayClass , tp)(_.typeSymbol == elem)
437+ def elementType (container : Symbol , tp : Type ): Type = elementExtract(container, tp)
438+ object ExprClassOf { def unapply (tp : Type ): Option [Type ] = elementExtractOption(ExprClass , tp) }
457439
458440 // collections classes
459441 lazy val ConsClass = requiredClass[scala.collection.immutable.:: [_]]
@@ -512,13 +494,6 @@ trait Definitions extends api.StandardDefinitions {
512494 lazy val ExprClass = ExprsClass .map(sym => getMemberClass(sym, tpnme.Expr ))
513495 def ExprSplice = ExprClass .map(sym => getMemberMethod(sym, nme.splice))
514496 def ExprValue = ExprClass .map(sym => getMemberMethod(sym, nme.value))
515- object ExprClassOf {
516- def unapply (tpe : Type ): Option [Type ] = tpe.dealias match {
517- case ExistentialType (_, underlying) => unapply(underlying)
518- case TypeRef (_, ExprClass , t :: Nil ) => Some (t)
519- case _ => None
520- }
521- }
522497
523498 lazy val ClassTagModule = requiredModule[scala.reflect.ClassTag [_]]
524499 lazy val ClassTagClass = requiredClass[scala.reflect.ClassTag [_]]
@@ -707,11 +682,6 @@ trait Definitions extends api.StandardDefinitions {
707682 (sym eq PartialFunctionClass ) || (sym eq AbstractPartialFunctionClass )
708683 }
709684
710- def elementType (container : Symbol , tp : Type ): Type = tp match {
711- case TypeRef (_, `container`, arg :: Nil ) => arg
712- case _ => NoType
713- }
714-
715685 def arrayType (arg : Type ) = appliedType(ArrayClass , arg)
716686 def byNameType (arg : Type ) = appliedType(ByNameParamClass , arg)
717687 def iteratorOfType (tp : Type ) = appliedType(IteratorClass , tp)
0 commit comments