Skip to content

False shadowing deprecation warning from #8353 #11895

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
soronpo opened this issue Feb 24, 2020 · 4 comments · Fixed by scala/scala#8751
Closed

False shadowing deprecation warning from #8353 #11895

soronpo opened this issue Feb 24, 2020 · 4 comments · Fixed by scala/scala#8751
Labels
Milestone

Comments

@soronpo
Copy link

soronpo commented Feb 24, 2020

The following code emits a class shadowing deprecation warning where none exists (AFAIK).
This code compiles in dotty 0.22.0-RC1 without any warnings.

trait Bar {
  trait Foo
  val Foo : Foo
}
object SomeBar extends Bar {
  object Foo extends Foo
}
@lrytz
Copy link
Member

lrytz commented Feb 24, 2020

Thanks for testing the snapshot!

@som-snytt
Copy link

I'll spend a few minutes this evening, as I'm also interested in #8121 false warning.

@som-snytt
Copy link

Are type members allowed to shadow nested classes in parents? That seems like cheating.

@Jasper-M
Copy link

Jasper-M commented Feb 25, 2020

Are type members allowed to shadow nested classes in parents? That seems like cheating.

This is some weird stuff.

scala> trait A { type Foo; def foo: Foo }
trait A

scala> class B extends A { class Foo(); val foo = new Foo() }
class B

scala> class C extends B { type Foo = String; override val foo: this.Foo = "foo" }
                                                           ^
       error: incompatible type in overriding
       val foo: C.this.Foo (defined in class B);
        found   : C.this.java.lang.Foo
           (which expands to)  String
        required: C.this.Foo(in class B)

scala> class C extends B { type Foo = String; override val foo: super.Foo = new super.Foo() }
                                                           ^
       error: incompatible type in overriding
       def foo: C.this.Foo (defined in trait A);
        found   : C.this.Foo(in class B)
        required: C.this.java.lang.Foo
           (which expands to)  String

scala> class C extends B { type Foo = String; override val foo: super.Foo with this.Foo = null }
class C

Also, lol @ C.this.java.lang.Foo

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

Successfully merging a pull request may close this issue.

4 participants