Skip to content

class fields cannot be completed if the name clashes with an inaccessible field #15449

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
tanishiking opened this issue Jun 15, 2022 · 2 comments

Comments

@tanishiking
Copy link
Member

Compiler version

3.1.3-RC5

Minimized code

❯ scala-cli repl --scala 3.1.3-RC5


Welcome to Scala 3.1.3-RC5 (1.8.0_302, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                      
scala> abstract class Foo(val internal: String)
// defined class Foo
                                                                                                                                                                      
scala> class FooImpl(internal: String) extends Foo(internal)
// defined class FooImpl
                                                                                                                                                                      
scala> val foo = FooImpl("symbol")
val foo: FooImpl = FooImpl@5a05dd30
                                                                                                                                                                      

Output

scala> foo.
!=             ->             asInstanceOf   eq             formatted      hashCode       ne             notify         synchronized   wait
##             ==             ensuring       equals         getClass       isInstanceOf   nn             notifyAll      toString       

Expectation

internal field should be completed.


Additional notes

It works if...

The underlying abstract class's field and concrete class's constructor parameter name differs.

scala> abstract class Foo(val internal: String)
// defined class Foo
                                                                                                                                                                      
scala> class FooImpl(foo: String) extends Foo(foo)
// defined class FooImpl
                                                                                                                                                                                                                                                                                          
scala> val foo = FooImpl("symbol")
val foo: FooImpl = FooImpl@602af851
                                                                                                                                                                      
scala> foo.
!=             ->             asInstanceOf   eq             formatted      hashCode       isInstanceOf   nn             notifyAll      toString       
##             ==             ensuring       equals         getClass       internal       ne             notify         synchronized   wait

Use case

I found this problem when I play around with SymDenotation in lampepfl/dotty.

https://github.com/lampepfl/dotty/blob/741587d8e1c0238ca9c0986a77519cdf5a6f2fa8/compiler/src/dotty/tools/dotc/core/Denotations.scala#L178-L180

https://github.com/lampepfl/dotty/blob/741587d8e1c0238ca9c0986a77519cdf5a6f2fa8/compiler/src/dotty/tools/dotc/core/SymDenotations.scala#L31-L40

We can't complete symbol field on SymDenotation.

@tanishiking tanishiking added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 15, 2022
@odersky odersky removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Jun 15, 2022
@rochala
Copy link
Contributor

rochala commented Jun 15, 2022

I fixed it some time ago. It must not be contained in 3.1.3-RC5 as it is working properly on current nightly and is duplication of #15235
Closing it.

@rochala rochala closed this as completed Jun 15, 2022
@tanishiking
Copy link
Member Author

Oh, that's good to hear, thank you @rochala !

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

No branches or pull requests

4 participants