Skip to content
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

Compiler allows empty argument lists for traits #6805

Open
scabug opened this issue Dec 12, 2012 · 5 comments
Open

Compiler allows empty argument lists for traits #6805

scabug opened this issue Dec 12, 2012 · 5 comments
Assignees
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
Milestone

Comments

@scabug
Copy link

scabug commented Dec 12, 2012

scala> trait T
defined trait T

scala> class C extends T()
defined class C

scala> new T(){}
res0: T = $anon$1@3ffa1b16

scala> class C extends AnyRef with T()
<console>:1: error: traits or objects may not have parameters
       class C extends AnyRef with T()
                                    ^
@scabug
Copy link
Author

scabug commented Dec 12, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6805?orig=1
Reporter: @xeno-by
Affected Versions: 2.9.2, 2.10.0

@scabug
Copy link
Author

scabug commented Dec 12, 2012

@xeno-by said:
This situation happens because in a lot of places in the compiler we silently promote Nil to ListOfNil. Therefore there's code that compensates for such promotions in cases when the receiver is actually nullary.

Hence it's currently impossible to do the validation for New, but as of late it's possible to do the validation for parent types as in extends T() and new T(){}. So the fix should be a real simple change to typedParentType.

On the other hand, do we really want to fix this thing given that we plan to introduce trait parameters in the near future? Martin, could you please comment?

@scabug
Copy link
Author

scabug commented Dec 12, 2012

@odersky said:
I think it should have low priority. No need for a fix.

@scabug scabug added the quickfix label Apr 7, 2017
@scabug scabug added this to the Backlog milestone Apr 7, 2017
@SethTisue SethTisue added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Aug 19, 2023
@SethTisue
Copy link
Member

SethTisue commented Aug 19, 2023

Scala 3 does have trait parameters now

@som-snytt
Copy link

scala 2.13.11> trait T
trait T

scala 2.13.11> class C extends AnyRef with T()
class C

@som-snytt som-snytt self-assigned this Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
Projects
None yet
Development

No branches or pull requests

3 participants