Skip to content

incorrect error when class with parameters follows trait in parents #6778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
anatoliykmetyuk opened this issue Jul 1, 2019 · 2 comments · Fixed by #14855
Closed

incorrect error when class with parameters follows trait in parents #6778

anatoliykmetyuk opened this issue Jul 1, 2019 · 2 comments · Fixed by #14855

Comments

@anatoliykmetyuk
Copy link
Contributor

minimized code

scala> trait Bar
// defined trait Bar
scala> enum B(x: Int) {
     |   case Foo extends Bar with B(10)
     | }
2 |  case Foo extends Bar with B(10)
  |                            ^^^^^
  |                            class B is not a trait
2 |  case Foo extends Bar with B(10)
  |                   ^
  |            missing argument for parameter x of constructor B: (x: Int): B

expectation

The second error message is wrong as we are definitely not missing an argument for B's constructor.

@bishabosha
Copy link
Member

this also exploits that checking for enum parent only checks first parent as now the errors include

2 |  case Foo extends Bar with B(10)
  |       ^
  |       enum case does not extend its enum class B

@bishabosha bishabosha changed the title (Slightly) misleading error message when incorrectly inheriting an enum case from a trait incorrect error when base class extended in wrong order Oct 16, 2020
@bishabosha
Copy link
Member

bishabosha commented Oct 16, 2020

minimise to

trait Foo
class A(x: Int)
class Bar extends Foo with A(10)

giving

4 |class Bar extends Foo with A(10)
  |                           ^^^^^
  |                           class A is not a trait
4 |class Bar extends Foo with A(10)
  |      ^
  |      missing argument for parameter x of constructor A: (x: Int): A

if Foo is a class then the second error is dropped

@bishabosha bishabosha changed the title incorrect error when base class extended in wrong order incorrect error when class with parameters is not first parent Oct 16, 2020
@bishabosha bishabosha changed the title incorrect error when class with parameters is not first parent incorrect error when class with parameters follows trait in parents Oct 16, 2020
odersky added a commit to dotty-staging/dotty that referenced this issue Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants