Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Overriding parameterless trait methods when cross compiling #16742

kyri-petrou started this conversation in General Discussion
Discussion options

Hi there. I'm trying to cross compile a library to Scala 3, but I'm stuck with the following:

In Scala 2.12 / 2.13 the following is allowed:

trait Foo {
 def foo(): String
}
case class Bar(override val foo: String) extends Foo

However, in Scala 3, the following error is raised:

error overriding method foo in trait Foo of type (): String;
 value foo of type String has incompatible type
case class Bar(foo: String) extends Foo

Is there anything that could be done in this case (e.g., a compiler flag) to allow this code to be cross-compiled for both Scala 2 and 3?

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /