Closed
Description
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.