656 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
0
answers
53
views
Scala 3 is it possible to statically create code using quotes?
My idea was to embed data in a class "statically" - i.e. completely independant of other components - and write it to file during compile.
Something like this:
def createForm()(using Quotes) ...
5
votes
0
answers
95
views
Scala compiler infinitely compiling
I am converting a Scala 2.13 project to Scala 3. Since I have made that change, the compiler has never finished compiling.
There were normal syntax errors before the compiler hangs, which I have now ...
-1
votes
2
answers
142
views
When to use conditionals vs pattern matching, is there a performance trade off? [closed]
I have two possibilities to implement a simple list drop method.
A:
def drop[A](l: List[A], n: Int): List[A] = (n, l) match
case (n, l) if n <= 0 => l
case (_, Cons(_, t)) => drop(t, n - ...
0
votes
0
answers
38
views
staging.Compiler for experimental code in Scala 3
Consider the following code. When I run it, I see Flag -experimental set repeatedly message (the functionality seems correct otherwise). What should I do so it won't be displayed? (without (using ...
0
votes
0
answers
29
views
Upgrading Scala2 OSGI project using Apache Felix to Scala3
I am upgrading a Scala2, version 2.13.16, OSGI application using Apache Felix, version 7.0.5, to Scala3 version 3.7.3.
The Scala3 library scala3_library_3 is not released as a bundle, no doubt because ...
3
votes
0
answers
58
views
Why does case a & Nothing make this recursive Scala 3 match type compile?
In Scala 3 (3.3.x) I want a recursive match type over intersections:
sealed trait Authorization
trait Admin extends Authorization
trait Owner extends Authorization
trait Authorizer[A <: ...
0
votes
0
answers
69
views
How to suppress deprecated warnings in code generated for type classes?
In Scala 3 macros how to suppress deprecated warnings in code generated for type classes of types defined like here:
@deprecated("some reason") case class C(x: Int) derives SomeTypeClass
...
1
vote
1
answer
87
views
Referring to non-existent class while compiling to ScalaJS
I'm builing a ScalaJs & Scala3 application, when i run the npm run dev/build command I have the following error, and I'm not figuring out how to fix it:
Referring to non-existent class scala....
2
votes
0
answers
95
views
How to create `lazy val` with parametized name and value in Scala 3 macros?
It is so easy in Scala 2, just:
q"lazy val $name = $value"
I need it for local values, so I don't have multi-thread requirements
I've tried just adding Flags.Lazy to the val definition ...
1
vote
1
answer
150
views
Shouldn't be a straightforward way to evaluate a `scala.quoted.Expr` to a literal constant?
In the updated section of the answer to the question How to reduce a Term that is reducible to a constant, @DmytroMitin used an interesting approach to reduce an Expr[T] to a Literal(<T>Constant(...
0
votes
1
answer
88
views
Replacement for `x.asType match { case '[type t <: S; t] => ...` in Scala 3.3 (LTS)
Do we have any replacement for the following Scala 3.7 code:
x.asType match {
case '[type t <: S; t] =>
'{ apply[t] }.asExprOf[Any]
case _ =>
report.errorAndAbort(s"...
0
votes
1
answer
57
views
Scala given in lexical scope not found in called function
In Programming in Scala (5th ed), page 462, there is the following code:
def isort[T](xs: List[T])(using ord: Ord[T]): List[T] =
if xs.isEmpty then Nil
else insert(xs.head, isort(xs.tail))
def ...
1
vote
1
answer
372
views
Fix missing transnitive dependencies with jlink and scala3 `scala.quoted -> scala `
I'm trying to upgrade a scala library to scala3 and cannot seem to figure out how to get the scala3 language to work with jlink. It says I'm missing transitive dependencies on a jlink build. You can ...
1
vote
1
answer
88
views
Why does quoted expression raise errors while equivalent AST does not?
In the following example, using a quoted expression ('{ ... }) raises a compiler error, while the equivalent AST construction works fine. Why does this happen?
Code Example
// Using Scala 3.7.0
trait ...
0
votes
0
answers
36
views
Can I label a method in Scaladoc and then link to its documentation?
Linking to overloaded methods is a nightmare, especially since it is typical for argument lists to have common prefixes. Ugly, bug prone, brittle, and current IDEs aren't able to process such ...