Skip to content

export should ignore overriden methods from Object #7086

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
liufengyun opened this issue Aug 22, 2019 · 0 comments
Closed

export should ignore overriden methods from Object #7086

liufengyun opened this issue Aug 22, 2019 · 0 comments

Comments

@liufengyun
Copy link
Contributor

liufengyun commented Aug 22, 2019

minimized code

class A {
  override def toString: String = "A"
}

class B(a: A) {
  export a._
}
6 |  export a._
  |           ^
  |         error overriding method toString in class Any of type (): String;
  |           method toString of type => String needs override modifier
one error found

expectation

The line export a._ should not export the method A.toString.

The specification says:

A member is eligible if all of the following holds:

- its owner is not a base class of the class(*) containing the export clause,
- it is accessible at the export clause,
- it is not a constructor, nor the (synthetic) class part of an object,
- it is a given instance (or an old-style implicit value) if and only if the export is tagged with given.

Maybe the first clause can be strengthened:

(1) its owner is not a base class of the class(*) containing the export clause
    - if the member overrides a method "m" in a base class, 
      then perform the same check (1) for "m".
odersky added a commit to dotty-staging/dotty that referenced this issue Aug 25, 2019
Change spec and implementation to not export members that override a symbol
in a baseclass of the class containing the export clause.
liufengyun added a commit that referenced this issue Aug 25, 2019
Fix #7086: Don't export overriding symbols
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

1 participant