Comments (3)
@goshacodes how exactly to reproduce the tuples from your generated code example?
from scala3.
I'll return with example today
from scala3.
object Example:
inline def example: Unit =
${ ExampleMacro.example }
object ExampleMacro:
def example(using quotes: Quotes): Expr[Unit] =
import quotes.reflect.*
val term = ValDef.let(
Symbol.spliceOwner,
List('{5}.asTerm, '{"foo"}.asTerm)
) { refs =>
refs.foldRight[Term]('{ EmptyTuple }.asTerm) { (el, acc) =>
Select.unique(acc, "*:")
.appliedToTypes(List(el.tpe, acc.tpe))
.appliedToArgs(List(el))
}
}
'{println(${Expr(term.show(using Printer.TreeAnsiCode)})}
output:
{
val x: scala.Int = 5
val `x₂`: java.lang.String = "foo"
scala.Tuple$package.EmptyTuple.*:[x.type, scala.Tuple$package.EmptyTuple.type](`x₂`).*:[x.type, scala.*:[x, scala.Tuple$package.EmptyTuple]](x)
}
expected:
(x, x2)
or at least x *: x2 *: EmptyTuple
from scala3.
Related Issues (20)
- Automatic rewrite for `<function> _` can produce non-compiling code for curried functions
- Crash at inlining probably polutes the error reports when inlined value is `Nothing`
- Type mismatch after compiler rewrite for `A with B <:< C`
- Crash in match type with wildcards when using `-Xkind-projector:underscores` HOT 3
- Leaking scoped capabilities HOT 1
- No workaround to dependent-type match types after SIP-56 HOT 6
- Import outside a package clause is not shadowed by an import inside the package clause
- Using full qualifier names for anonymous given naming to avoid double definition HOT 3
- Overloading resolution incorrectly drops alternative with match type result when a target type is provided
- given CanEqual reported as unused even if required by strictEquality HOT 1
- Cannot select from named tuple literal
- Overlapping patches crash when using `-rewrite` and `compiletime.testing.typeCheckErrors`
- Associated types become opaque with indirection
- `-source:3.4-migration` `-rewrite` should remove empty argument list for class with only context bounds
- "Deferred inline" error when calling inline methods on a type class
- Regression for `-Wunused:import` in `business4s/decisions4s` HOT 1
- Match type fails to reduce in non-exhaustive pattern match
- `experimental.modularity` breaks `as`-named infix type
- Scaladoc removes indentation of first line, making code incorrect
- Incrementally compiled code that iterates over Mirror's `MirroredElemTypes` in a macro sometimes dealiases an `opaque` type to its underlying type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala3.