Questions tagged [scala-3]
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.
scala-3
602
questions
1
vote
0
answers
22
views
Scala 3 reflection: collect all members that are singleton objects
I have a method in Scala 2 that uses reflection. It doesn't work in Scala 3, and I would like to reimplement it so it works for Scala 3. (I will no longer need it for Scala 2 anymore, so it need not ...
0
votes
0
answers
21
views
Scala Spark Dataframe creation from Seq of tuples doesn't work in Scala 3, but does in Scala 2
When trying to test something locally with Scala Spark, I noticed the following problem and was wondering what causes it, and whether there exists a workaround.
Consider the following build ...
0
votes
1
answer
33
views
How to provide a generic Circe Decoder for a Scala 3 Enum Values?
In my model I have a subset of Enum Values (using refined types). So I need to provide Decoders for these Enum Values.
I have now the following version that works (I simplified the example with only ...
2
votes
1
answer
100
views
Test/compile not finding lib/jar with Scala 3 (but 2.13 works)
I'm packaging jars from generated source code with an sbt-plugin and the jars are fine and on the classpath.
Now I have two identical minimal projects targeting Scala 2.13 and 3.3. With 2.13 I can run ...
0
votes
1
answer
39
views
Scala 3 binary compatibility issue
As I am moving to help my organization adopt scala 3, i am trying to map out the potential chanllenge to look after.
Generally, i was readying about binary compatibility change with scala 3 and ...
1
vote
1
answer
59
views
Scala 3 macros: "dynamically" instantiating singleton objects at compile-time
I'm trying to create a macro that makes use of some objects.
Suppose I have the following definitions:
trait Foo:
def doStuff(): Unit
// in other files
object Bar extends Foo:
def doStuff() = ......
1
vote
1
answer
39
views
Scala 2 to Scala 3: Instantiating a trait no longer recognises new methods
The following code compiles and runs in Scala 2:
trait SomeTrait {
val myName: String
}
class SomeClass() extends SomeTrait {
override val myName: String = "Billy Banana"
}
val ...
0
votes
2
answers
68
views
Compilation Error: Instance not found: Conversion[models.Errorcode, _ <: Product] on Scala 3 Playframework
I've been recently migrating a playframework project from scala2 to scala3, and I found this error that only happens in scala 3 but it doesnt happen in scala 2:
play.sbt.PlayExceptions$...
2
votes
1
answer
47
views
Scala initialization order object vs. val
In the following program an object is reported as null, even though it is clearly initialized.
class MyClass()
class MyOtherClass(c: MyClass)
object Foo {
val myClass = new MyClass()
object ...
0
votes
1
answer
52
views
Add constructor to class with extensions possible?
Is it possible to add an additional constructor to a class from a library with scala 3 extensions?
I have a class ClassA with two constructors ClassA() and Class(text: String, num: Int).
I want to add ...
0
votes
0
answers
46
views
Type class in Scala with extension that overlaps in name with methods on type members
For a library I'm building in Scala 3 (current target 3.3), I am trying to construct a type class hierarchy to express various functionality I want to require from the types I'm using and introducing.
...
1
vote
1
answer
68
views
Using `opaque type` as a typeclass in Scala
Any idea why this does not compile: https://scastie.scala-lang.org/iPmLyim4Q8aQ2aMNIfj2gA
opaque type Global[Value] = Unit
object Global:
def derived[Value]: Global[Value] = ()
case class Yo() ...
0
votes
1
answer
52
views
Why doesn't my scalac prints any warning for missing "open" keyword
When compiling a willingly faulty Scala code implying a missing open modifier, my compiler doesn't notify any warning or error. This seems to contradict this line in the Scala book :
In Scala 3 ...
0
votes
1
answer
33
views
Using scoverage with scala3 and mill
TL;DR -- How do I configure the mill-contrib-scoverage plugin to work with Scala3?
Details:
Using the instructions at the Mill contributor's page, I get the following error when running the scoverage....
0
votes
1
answer
48
views
Is it possible to pass a scala 3 enum as parameter?
I'm trying to create a method that takes a Scala 3 enum as parameter, but this does not work, is this possible?
I try to do something like
trait Named:
def name: String
enum Birds(val name: String) ...