Skip to content

Commit

Permalink
WIP 48 - use def rather than closure in Discover macro
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Sep 6, 2024
1 parent f986c19 commit 49e1ffc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main/define/src/mill/define/Discover.scala
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ object Discover {
// by wrapping the `overridesRoutes` in a lambda function we kind of work around
// the problem of generating a *huge* macro method body that finally exceeds the
// JVM's maximum allowed method size
val overridesLambda = '{(() => (${Expr(names)}, $mainDatas))()}
val overridesLambda = '{
def pair() = (${Expr(names)}, $mainDatas)
pair()
}
val lhs = Ref(defn.Predef_classOf).appliedToType(discoveredModuleType.widen).asExprOf[Class[?]]
'{$lhs -> $overridesLambda}
}
Expand All @@ -176,7 +179,7 @@ object Discover {
Discover.apply2(Map(${Varargs(mapping)}*))
}
// TODO: if needed for debugging, we can re-enable this
// report.warning(s"generated maindata for ${TypeRepr.of[T].show}:\n${expr.asTerm.show}", TypeRepr.of[T].typeSymbol.pos.getOrElse(Position.ofMacroExpansion))
// report.warning(s"generated discovery for ${TypeRepr.of[T].show}:\n${expr.asTerm.show}", TypeRepr.of[T].typeSymbol.pos.getOrElse(Position.ofMacroExpansion))
expr
}
}
Expand Down

0 comments on commit 49e1ffc

Please sign in to comment.