Skip to content

Support constant folding for s, f and raw interpolators. #10315

Open
@nicolasstucki

Description

@nicolasstucki

We should be able to constant fold s, f and raw interpolator with constant inputs.

  val r: "abc" = s"ab${"c"}"

This would be useful when combined with inlining

inline val x = "abc"
inline val y = s"${y}dce"

A realistic use of this feature would be with the scala.compiletime.error method.

inline def f(x: Int) = 
  compiletime.error(s"Error code: $x")

f(3) // error: `Error code: 3`

This would need to happen when typing, probably in Inliner.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions