@@ -63,7 +63,7 @@ object ScalaReflection extends ScalaReflection {
6363 def dataTypeFor [T : TypeTag ]: DataType = dataTypeFor(localTypeOf[T ])
6464
6565 private def dataTypeFor (tpe : `Type`): DataType = ScalaReflectionLock .synchronized {
66- tpe match {
66+ tpe.dealias match {
6767 case t if t <:< definitions.IntTpe => IntegerType
6868 case t if t <:< definitions.LongTpe => LongType
6969 case t if t <:< definitions.DoubleTpe => DoubleType
@@ -93,7 +93,7 @@ object ScalaReflection extends ScalaReflection {
9393 * JVM form instead of the Scala Array that handles auto boxing.
9494 */
9595 private def arrayClassFor (tpe : `Type`): ObjectType = ScalaReflectionLock .synchronized {
96- val cls = tpe match {
96+ val cls = tpe.dealias match {
9797 case t if t <:< definitions.IntTpe => classOf [Array [Int ]]
9898 case t if t <:< definitions.LongTpe => classOf [Array [Long ]]
9999 case t if t <:< definitions.DoubleTpe => classOf [Array [Double ]]
@@ -192,7 +192,7 @@ object ScalaReflection extends ScalaReflection {
192192 case _ => UpCast (expr, expected, walkedTypePath)
193193 }
194194
195- tpe match {
195+ tpe.dealias match {
196196 case t if ! dataTypeFor(t).isInstanceOf [ObjectType ] => getPath
197197
198198 case t if t <:< localTypeOf[Option [_]] =>
@@ -479,7 +479,7 @@ object ScalaReflection extends ScalaReflection {
479479 }
480480 }
481481
482- tpe match {
482+ tpe.dealias match {
483483 case _ if ! inputObject.dataType.isInstanceOf [ObjectType ] => inputObject
484484
485485 case t if t <:< localTypeOf[Option [_]] =>
@@ -633,7 +633,7 @@ object ScalaReflection extends ScalaReflection {
633633 * we also treat [[DefinedByConstructorParams ]] as product type.
634634 */
635635 def optionOfProductType (tpe : `Type`): Boolean = ScalaReflectionLock .synchronized {
636- tpe match {
636+ tpe.dealias match {
637637 case t if t <:< localTypeOf[Option [_]] =>
638638 val TypeRef (_, _, Seq (optType)) = t
639639 definedByConstructorParams(optType)
@@ -680,7 +680,7 @@ object ScalaReflection extends ScalaReflection {
680680 /*
681681 * Retrieves the runtime class corresponding to the provided type.
682682 */
683- def getClassFromType (tpe : Type ): Class [_] = mirror.runtimeClass(tpe.typeSymbol.asClass)
683+ def getClassFromType (tpe : Type ): Class [_] = mirror.runtimeClass(tpe.dealias. typeSymbol.asClass)
684684
685685 case class Schema (dataType : DataType , nullable : Boolean )
686686
@@ -695,7 +695,7 @@ object ScalaReflection extends ScalaReflection {
695695
696696 /** Returns a catalyst DataType and its nullability for the given Scala Type using reflection. */
697697 def schemaFor (tpe : `Type`): Schema = ScalaReflectionLock .synchronized {
698- tpe match {
698+ tpe.dealias match {
699699 case t if t.typeSymbol.annotations.exists(_.tpe =:= typeOf[SQLUserDefinedType ]) =>
700700 val udt = getClassFromType(t).getAnnotation(classOf [SQLUserDefinedType ]).udt().newInstance()
701701 Schema (udt, nullable = true )
@@ -761,7 +761,7 @@ object ScalaReflection extends ScalaReflection {
761761 * Whether the fields of the given type is defined entirely by its constructor parameters.
762762 */
763763 def definedByConstructorParams (tpe : Type ): Boolean = {
764- tpe <:< localTypeOf[Product ] || tpe <:< localTypeOf[DefinedByConstructorParams ]
764+ tpe.dealias <:< localTypeOf[Product ] || tpe.dealias <:< localTypeOf[DefinedByConstructorParams ]
765765 }
766766
767767 private val javaKeywords = Set (" abstract" , " assert" , " boolean" , " break" , " byte" , " case" , " catch" ,
@@ -816,7 +816,7 @@ trait ScalaReflection {
816816 * synthetic classes, emulating behaviour in Java bytecode.
817817 */
818818 def getClassNameFromType (tpe : `Type`): String = {
819- tpe.erasure.typeSymbol.asClass.fullName
819+ tpe.dealias. erasure.typeSymbol.asClass.fullName
820820 }
821821
822822 /**
@@ -835,9 +835,10 @@ trait ScalaReflection {
835835 * support inner class.
836836 */
837837 def getConstructorParameters (tpe : Type ): Seq [(String , Type )] = {
838- val formalTypeArgs = tpe.typeSymbol.asClass.typeParams
839- val TypeRef (_, _, actualTypeArgs) = tpe
840- val params = constructParams(tpe)
838+ val dealiasedTpe = tpe.dealias
839+ val formalTypeArgs = dealiasedTpe.typeSymbol.asClass.typeParams
840+ val TypeRef (_, _, actualTypeArgs) = dealiasedTpe
841+ val params = constructParams(dealiasedTpe)
841842 // if there are type variables to fill in, do the substitution (SomeClass[T] -> SomeClass[Int])
842843 if (actualTypeArgs.nonEmpty) {
843844 params.map { p =>
@@ -851,7 +852,7 @@ trait ScalaReflection {
851852 }
852853
853854 protected def constructParams (tpe : Type ): Seq [Symbol ] = {
854- val constructorSymbol = tpe.member(nme.CONSTRUCTOR )
855+ val constructorSymbol = tpe.dealias. member(nme.CONSTRUCTOR )
855856 val params = if (constructorSymbol.isMethod) {
856857 constructorSymbol.asMethod.paramss
857858 } else {
0 commit comments