Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial committed Aug 21, 2023
1 parent fdf3bdd commit 11cb3a4
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,6 @@ private[surface] class CompileTimeSurfaceFactory[Q <: Quotes](using quotes: Q) {
.toSeq
// Exclude primitive surfaces as it is already defined in Primitive object
.filterNot(x => primitiveTypeFactory.isDefinedAt(x._1))
// Do not generate lazy surface inside lazy val for avoiding infinite loop
// .filterNot(x => lazySurface.contains(x._1))
.sortBy(_._2)
.reverse
.map { case (tpe, order) =>
Expand All @@ -734,9 +732,13 @@ private[surface] class CompileTimeSurfaceFactory[Q <: Quotes](using quotes: Q) {
// Use alphabetically ordered variable names
f"__s${surfaceVarCount}%03X",
TypeRepr.of[Surface],
// Use lazy val to avoid forward reference error
// If the surface itself is lazy, we need to eagerly initialize it to update the surface cache
if (lazySurface.contains(tpe)) Flags.EmptyFlags else Flags.Lazy,
if (lazySurface.contains(tpe)) {
// If the surface itself is lazy, we need to eagerly initialize it to update the surface cache
Flags.EmptyFlags
} else {
// Use lazy val to avoid forward reference error
Flags.Lazy
},
Symbol.noSymbol
)
surfaceVarCount += 1
Expand All @@ -752,7 +754,9 @@ private[surface] class CompileTimeSurfaceFactory[Q <: Quotes](using quotes: Q) {
}.toList

/**
* Generate a code like this: {{ val __s0 = Surface.of[A] val __s1 = Surface.of[B] ...
* Generate a code like this:
*
* {{ lazy val __s000 = Surface.of[A]; lazy val __s001 = Surface.of[B] ...
*
* ClassMethodSurface( .... ) }}
*/
Expand Down

0 comments on commit 11cb3a4

Please sign in to comment.