Skip to content

Commit

Permalink
HigherKindedTypeSurface diags
Browse files Browse the repository at this point in the history
  • Loading branch information
OndrejSpanel committed Apr 4, 2024
1 parent 92cc1ae commit b285de1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ private[surface] class CompileTimeSurfaceFactory[Q <: Quotes](using quotes: Q):
val len = h.paramNames.size
val params = (0 until len).map { i => h.param(i) }
val args = params.map(surfaceOf(_))
println(s"HigherKindedTypeSurface A $name $params ${args.map(_.show)}")
'{ HigherKindedTypeSurface(${ Expr(name) }, ${ Expr(fullName) }, ${ inner }, ${ Expr.ofSeq(args) }) }
case a @ AppliedType if a.typeSymbol.name.contains("$") =>
'{ org.opengrabeso.airframe.surface.ExistentialType }
Expand All @@ -245,10 +246,12 @@ private[surface] class CompileTimeSurfaceFactory[Q <: Quotes](using quotes: Q):
val fullName = fullTypeNameOf(a)
val args = a.args.map(surfaceOf(_))
// TODO support type erasure instead of using AnyRefSurface
println(s"HigherKindedTypeSurface B $name")
'{ HigherKindedTypeSurface(${ Expr(name) }, ${ Expr(fullName) }, AnyRefSurface, ${ Expr.ofSeq(args) }) }
case p @ ParamRef(TypeLambda(typeNames, _, _), _) =>
val name = typeNames.mkString(",")
val fullName = fullTypeNameOf(p)
println(s"HigherKindedTypeSurface C $name $fullName $typeNames")
'{ HigherKindedTypeSurface(${ Expr(name) }, ${ Expr(fullName) }, AnyRefSurface, Seq.empty) }
}

Expand Down Expand Up @@ -307,6 +310,7 @@ private[surface] class CompileTimeSurfaceFactory[Q <: Quotes](using quotes: Q):
}

private def clsOf(t: TypeRepr): Expr[Class[_]] =
//Literal(ClassOfConstant(t)).changeOwner(Symbol.spliceOwner).asExpr.asInstanceOf[Expr[Class[_]]]
Literal(ClassOfConstant(t)).asExpr.asInstanceOf[Expr[Class[_]]]

private def newGenericSurfaceOf(t: TypeRepr, docstring: Option[String] = None): Expr[Surface] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object RecursiveHigherKindTypeTest {
class MyTask[A]

object Holder {
type BySkinny[A] = MyTask[A]
type BySkinny[SkinnyA] = MyTask[SkinnyA]
def bySkinny: Holder[BySkinny] = new InterpretedHolder
}

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ val buildSettings = tokenSettings ++ Seq[Setting[_]](
"-deprecation",
"-release:8",
// Use this flag for debugging Macros
// "-Xcheck-macros",
"-Xcheck-macros",
"-Wconf:msg=`_` is deprecated for wildcard arguments of types:s",
"-Wconf:msg=with as a type operator has been deprecated:s",
"-Wconf:msg=The syntax .* is no longer supported for vararg splices:s",
Expand Down

0 comments on commit b285de1

Please sign in to comment.