Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-trivial lambdas in Scala-style rendering format #490

Draft
wants to merge 14 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
fmt
varshith257 committed Nov 8, 2024
commit 834435963347ab7a6309c25959c282d6083c1ea8
Original file line number Diff line number Diff line change
@@ -263,6 +263,7 @@ abstract class LightTypeTag private[reflect] (
def scalaStyledName: String = {
ref match {
case lambda: LightTypeTagRef.Lambda =>
// Check if all lambda parameters are applied in the declared order
val isTrivial = lambda.input.indices.forall {
i =>
lambda.output match {
@@ -271,14 +272,18 @@ abstract class LightTypeTag private[reflect] (
case _ => false
}
}

if (isTrivial) {
// Render with `_` placeholders if trivial
s"${lambda.output.shortName}[${lambda.input.map(_ => "_").mkString(", ")}]"
} else {
// Render full form if non-trivial
s"[${lambda.input.mkString(", ")}] =>> ${lambda.output.shortName}"
}
case _ => ref.shortName

case LightTypeTagRef.FullReference(_, args, _) if args.nonEmpty =>
s"${ref.shortName}[${args.map(_ => "_").mkString(", ")}]"

case _ =>
ref.shortName
}
}