Scala 3.0 is a general-purpose language that makes use of the functional and object-oriented paradigms. It consolidates language constructs to improve the language’s consistency, safety, ergonomics, and performance.
Questions tagged [scala-3]
495 questions
38
votes
6 answers
What exactly is Dotty?
I am reading about Scala 3 and discovered dotty. I am trying to understand what it is. Somewhere I read "It is new compiler", somewhere I read "It is part of Scala 3", and somewhere I read "Dotty is new Scala 3".
Can somebody please explain to me…

nomadSK25
- 2,350
- 3
- 25
- 36
13
votes
1 answer
Add Scala 3.0 SDK to IntelliJ
Currently, the dotty compiler released its first Release Candidate and will be released in the next few months.
I updated the IntelliJ scala plugin to EarlyAccess to make it working with Scala 3.0, its problem with syntax highlighting resolved, but…

Nik Kashi
- 4,447
- 3
- 40
- 63
12
votes
1 answer
Extracting and accessing fields at compile time in Scala 3
Extracting names and types of elements of a case class at compile time in Scala 3 has been already explained well in this blog: https://blog.philipp-martini.de/blog/magic-mirror-scala3/
However, the same blog uses productElement to get the values…

Koosha
- 1,492
- 7
- 19
11
votes
1 answer
What does ?=> mean in Scala?
I have seen the ?=> symbol appear in Scala code and in some discussion posts about Scala 3, so I am assuming that it is a Scala 3+ symbol. Nothing appears when searching through documentation or Google, but it looks like the syntactic sugar for the…

Ian
- 5,704
- 6
- 40
- 72
10
votes
1 answer
What is the meaning of "?=>" in Scala 3?
I cannot find explanation of the following syntax rule:
FunType ::= FunTypeArgs (‘=>’ | ‘?=>’) Type

user3514920
- 141
- 1
- 3
10
votes
1 answer
scala 3 macro how to implement generic trait
I want to implement a proxy of some trait A (e.g. delegates method call to some rpc call), like this
def clientProxy[A](using Type[A], Quotes): Expr[A] = {
import quotes.reflect._
val defTrees: List[Tree] =…

jilen
- 5,633
- 3
- 35
- 84
10
votes
2 answers
How to generate a class in Dotty with macro?
Is it possible to generate a new class with macro in Dotty, Scala 3 ?
Zlaja

zlaja
- 1,351
- 3
- 13
- 23
9
votes
1 answer
How to get Scala annotations that are given to an argument of a method
Consider the following annotation:
// ok to have more meta
@field
@param
@compileTimeOnly("Only for code generation")
case class Annot(value: String) extends ConstantAnnotation
Now three uses:
case class A(x: Int, @Annot("z") y: String)
object A:
…

Koosha
- 1,492
- 7
- 19
9
votes
3 answers
How to create a general method for Scala 3 enums
I want to have a simple enumDescr function for any Scala 3 enum.
Example:
@description(enumDescr(InvoiceCategory))
enum InvoiceCategory:
case `Travel Expenses`
case Misc
case `Software License Costs`
In Scala 2 this is simple…

pme
- 14,156
- 3
- 52
- 95
9
votes
1 answer
Parsing scala 3 code from a String into Scala 3 AST at runtime
My goal is to get Scala 3 code as a String and to parse it into Abstract Syntax Tree for Scala 3 at runtime. In the process if the code has compilation errors, I should get that as part of some exception.
The larger goal is to end up with Expr[T] if…

arinray
- 178
- 1
- 12
9
votes
0 answers
Use case of kind polymorphism with AnyKind
Given
trait Int // proper type
trait List[A] // 1st-order-kinded type constructor
trait Functor[F[_]] // higher-order-kinded type constructor taking type constructor
trait I[H[F[_]]] // higher-order-kinded…

Mario Galic
- 47,285
- 6
- 56
- 98
8
votes
0 answers
In multi-stage compilation, should we use a standard serialisation method to ship objects through stages?
This question is formulated in Scala 3/Dotty but should be generalised to any language NOT in MetaML family.
The Scala 3 macro tutorial:
https://docs.scala-lang.org/scala3/reference/metaprogramming/macros.html
Starts with the The Phase Consistency…

tribbloid
- 4,026
- 14
- 64
- 103
8
votes
2 answers
Scala 3 Explicit Nulls flag makes String operations quite unusable
When using the new Scala 3's flag -Yexplicit-nulls, every Java code which doesn't have explicit non-null annotations is treated as nullable, thus every Java method not returning a primitive type T effectively returns T | Null.
Problem: In Scala,…

Ota Hauptmann
- 171
- 4
8
votes
2 answers
How to use akka in Scala 3?
How to use akka in Scala 3 ? I can't find akka dependencies while using scala 3
sbt errors :
[error] not found: /Users/admin/.ivy2/localcom.typesafe.akka/akka-actor-typed_3/2.6.15/ivys/ivy.xml
[error] not found:…

Ji Shuai
- 101
- 1
- 2
8
votes
2 answers
Difference between Scala 2 implicits and Scala 3 given/using
What is the difference between the implicit keyword in Scala 2 and given+using in Scala 3? Is it just that implicit has been split up into two keywords, or are the semantics also different, and if so, how?

user
- 7,435
- 3
- 14
- 44