Skip to content

Import renaming incompatible with super, access modifiers, etc #1915

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

Open
scabug opened this issue Apr 23, 2009 · 3 comments
Open

Import renaming incompatible with super, access modifiers, etc #1915

scabug opened this issue Apr 23, 2009 · 3 comments
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Apr 23, 2009

Consider the following code:

object wrap1 {
  trait A {
    def n = 3
  }
}

object wrap2 {
  trait A {
    def n = 7
  }
}

Suppose we want to inherit from both A's above. This produces an error, as expected:

// error: error overriding method n in trait A of type => Int;
//  method n in trait A of type => Int needs `override' modifier
trait B extends wrap1.A with wrap2.A

This, of course, is ambiguous

// error: ambiguous parent class qualifier
trait B extends wrap1.A with wrap2.A {
  override def n =
    super[A].n
}

Oops! This isn't allowed (as per the spec, but it's surprising)

// error: ']' expected but '.' found.
trait B extends wrap1.A with wrap2.A {
  override def n =
    super[wrap1.A].n
}

But the most surprising thing is that renaming doesn't work!

import wrap1.{A => A1}
import wrap2.{A => A2}

// error: A1 does not name a parent class of trait B
trait B extends A1 with A2 {
  override def n =
    super[A1].n
}

The same problem arises with access modifiers. Consider:

object Outer {
  object A {
    object A {
      import Outer.{A => RootA}
      
      // error: RootA is not an enclosing class
      private[RootA] trait B
    }
  }
}
@scabug
Copy link
Author

scabug commented Apr 23, 2009

@scabug scabug added the typer label Apr 6, 2017
@scabug scabug added this to the Backlog milestone Apr 6, 2017
@scala scala deleted a comment from scabug Mar 3, 2018
@scala scala deleted a comment from scabug Mar 3, 2018
@joroKr21
Copy link
Member

Still a problem in Scala 3 😞

@bjornregnell
Copy link

bjornregnell commented Jul 31, 2024

Users run into this...
as pointed out by @som-snytt here:
https://users.scala-lang.org/t/invoking-super-in-case-of-identical-name/10114/7

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