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

Incorrectly generated inner class name #9940

Closed
scabug opened this issue Sep 29, 2016 · 7 comments
Closed

Incorrectly generated inner class name #9940

scabug opened this issue Sep 29, 2016 · 7 comments
Labels

Comments

@scabug
Copy link

scabug commented Sep 29, 2016

  1. This code:
class Buf {
  class ByteArray {
    object Owned
  }
}

object Buf {
  object ByteArray {
    object Owned
  }
}

results in the following error message:

test.scala:3: error: name clash: class Buf defines class ByteArray
and its companion object Buf also defines object ByteArray
  class ByteArray {
        ^
one error found

It seems like there should be no name clash.

  1. This code:
object Buf {
  object ByteArray {
    object Owned
  }
}

generates a class Buf$ByteArray$Owned$. According to the JLS, and if a singleton object is a considered a class with a dollar appended, it should be Buf$$ByteArray$$Owned$.

@scabug
Copy link
Author

scabug commented Sep 29, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9940?orig=1
Reporter: @axel22
Affected Versions: 2.11.8, 2.12.0-RC1
Duplicates #2034

@scabug
Copy link
Author

scabug commented Sep 29, 2016

@SethTisue said:
These are two unrelated issues, I think.

Addressing just the name clash part: first, note that the inner "Owner" objects aren't necessary to reproduce; "class A { object B }; object A { object B }" is sufficient.

The code in nsc/typechecker/SuperAccessors.scala that performs this check was added by Martin back in Scala 2.6 days, here scala/scala@81a4d20b. The same check still exists in Dotty. It isn't obvious to me what would go wrong if the check were removed, but it was certainly put there on purpose.

@scabug
Copy link
Author

scabug commented Sep 29, 2016

@axel22 said:
Indeed, the code you show is more minimal.

In any case, it seems like there should be no reason why a class and its companion should not both define an inner class with the same name, and the current naming for the inner class of the companion object seems wrong..

@scabug
Copy link
Author

scabug commented Sep 29, 2016

@soc said:
I think we had a ticket with a fix attached for this already, but I can't remember the issue number right now ...

@scabug
Copy link
Author

scabug commented Sep 30, 2016

@soc said:
I think this is #2034.

@scabug
Copy link
Author

scabug commented Sep 30, 2016

@axel22 said:
Thanks, having looked at Iulian's comment there, things are more clear.

@scabug scabug added the backend label Apr 7, 2017
@scabug scabug added this to the Backlog milestone Apr 7, 2017
@SethTisue SethTisue removed this from the Backlog milestone Mar 1, 2018
@SethTisue
Copy link
Member

closing on the assumption this is just #2034

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

No branches or pull requests

3 participants