Skip to content

Commit

Permalink
Fix for Scala 2
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial committed Dec 23, 2023
1 parent 55348c4 commit 7d71d50
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object ReflectSurfaceFactory extends LogSupport {
val tpe = cs.toType
ofType(tpe) match {
// Workaround for sbt's layered class loader, which cannot find the original classes using the reflect mirror
case Alias(_, _, AnyRefSurface) if cs.isTrait =>
case Alias(_, _, AnyRefSurface, _) if cs.isTrait =>
new GenericSurface(cls)
case other => other
}
Expand Down Expand Up @@ -436,7 +436,8 @@ object ReflectSurfaceFactory extends LogSupport {

val name = symbol.asType.name.decodedName.toString
val fullName = s"${prefix.typeSymbol.fullName}.${name}"
val a = Alias(name, fullName, inner)
val typeArgs = typeArgsOf(alias).map(surfaceOf(_)).toIndexedSeq
val a = Alias(name, fullName, inner, typeArgs)
a
}

Expand Down Expand Up @@ -619,7 +620,7 @@ object ReflectSurfaceFactory extends LogSupport {
// For example, trait MyTag, which has no implementation will be just an java.lang.Object
val name = t.typeSymbol.name.decodedName.toString
val fullName = s"${prefix.typeSymbol.fullName}.${name}"
Alias(name, fullName, AnyRefSurface)
Alias(name, fullName, AnyRefSurface, Seq.empty)
case t @ RefinedType(List(_, baseType), decl) =>
// For traits with extended methods
new GenericSurface(resolveClass(baseType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ private[surface] object SurfaceMacros {
}
val name = symbol.asType.name.decodedName.toString
val fullName = s"${prefix.typeSymbol.fullName}.${name}"
q"wvlet.airframe.surface.Alias(${name}, ${fullName}, $inner)"
val typeArgs = args.map(surfaceOf(_))
q"wvlet.airframe.surface.Alias(${name}, ${fullName}, ${inner}, Seq(..${typeArgs}))"
}

private val higherKindedTypeFactory: SurfaceFactory = {
Expand Down Expand Up @@ -626,7 +627,7 @@ private[surface] object SurfaceMacros {

private val genericSurfaceFactory: SurfaceFactory = {
case t if t =:= typeOf[Any] =>
q"wvlet.airframe.surface.Alias(${"Any"}, ${"scala.Any"}, wvlet.airframe.surface.AnyRefSurface)"
q"wvlet.airframe.surface.Alias(${"Any"}, ${"scala.Any"}, wvlet.airframe.surface.AnyRefSurface, Seq.empty)"
case t @ TypeRef(prefix, symbol, args) if !args.isEmpty =>
val typeArgs = typeArgsOf(t).map(surfaceOf(_))
q"new wvlet.airframe.surface.GenericSurface(classOf[$t], typeArgs = IndexedSeq(..$typeArgs))"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ case class Alias(
override val name: String,
override val fullName: String,
ref: Surface,
override val typeArgs: Seq[Surface]
override val typeArgs: Seq[Surface] = Seq.empty
) extends GenericSurface(ref.rawType, typeArgs, ref.params, ref.objectFactory) {
override def toString: String = {
val typeSuffix = if (typeArgs.isEmpty) {
Expand Down

0 comments on commit 7d71d50

Please sign in to comment.