Skip to content

Protected method 'inline' #9363

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
edolgy opened this issue Jul 14, 2020 · 0 comments · Fixed by #13430
Closed

Protected method 'inline' #9363

edolgy opened this issue Jul 14, 2020 · 0 comments · Fixed by #13430

Comments

@edolgy
Copy link

edolgy commented Jul 14, 2020

Minimized code

class Foo:
  protected inline def fooProtected: Int = 12

object Foo extends Foo:
  inline def foo: Int = fooProtected

object Bar:
  def bar: Int = Foo.foo

Output

[error] method fooProtected in class Foo cannot be accessed as a member of 
[error] (Foo$_this : (scalqa.Foo : scalqa.Foo.type)) from module class Bar$.
[error]  Access to protected method fooProtected not permitted because enclosing object Bar in package scalqa
[error]  is not a subclass of class Foo in package scalqa where target is defined

Expectation

The error is legitimate, you cannot inline protected method call into unprotected context.

However, if the protected method is inlined itself, it is a different story. The call must be permitted (not sure if the context of the method should be examined for further restrictions, in all my scenarios it is really simple).

This is not a trivial issue. For libraries which heavily rely on inlining this is a major design hurdle.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 16, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 31, 2021
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants