Skip to content

Conversation

@ghostbuster91
Copy link
Contributor

PR Checklist (not all items are relevant to all PRs)

  • Added unit-tests (for runtime code)
  • Added bootstrapped code + smoke tests (when the rendering logic is modified)
  • Added build-plugins integration tests (when reflection loading is required at codegen-time)
  • Added alloy compliance tests (when simpleRestJson protocol behaviour is expanded/updated)
  • Updated dynamic module to match generated-code behaviour
  • Added documentation
  • Updated changelog

@ghostbuster91 ghostbuster91 changed the title Scala3 cross-compile codegen module against scala3 May 18, 2025
import scala.reflect.runtime.universe._
val str = Literal(Constant(raw))
.toString()
// Escape the string as a Scala literal (surround with quotes, escape special characters)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

homestly I think we should just use scalameta for small things like these (rendering constants)

Copy link
Contributor

@Baccata Baccata May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine, if you want to pull it I don't mind. But don't get your hopes up about rewriting the codegen in scalameta

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I'm not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it in the past and while having the snippets to compile at the same time you compile your code is mind-blowing there was a lot of hassle sometimes to get them right.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, the ancestor to smithy4s was actually written with scalameta. Lots of friction.

Copy link
Member

@kubukoz kubukoz Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hints:

  • libraryDependencies += ("org.scalameta" %% "scalameta" % "4.11.0").cross(CrossVersion.for3Use2_13)
  • scala.meta.Lit.String(s).printSyntaxFor(scala.meta.dialects.Scala3)

that's how I use it in https://github.com/kubukoz/smithy-playground/blob/c34be16f534795041295f4379a6ca8040297c4b1/modules/parser-gen/src/main/scala/playground/parsergen/ParserGen.scala#L355C25-L355C92 anyway

@kubukoz
Copy link
Member

kubukoz commented Jul 28, 2025

we'll need this for #1790. @ghostbuster91 how do you feel about finishing this up?

@ghostbuster91
Copy link
Contributor Author

Sounds like a good case. I will try to do this this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants