Skip to content

private-ness of trait constructor ignored #17089

Closed
@pweisenburger

Description

@pweisenburger

Compiler version

3.3.0-RC3

Minimized code

object o:
  trait T private[o]()

def test = new o.T { }

Output

The code compiles. I would expect it not to. My expectation was that trait T private[o]() scopes the constructor of T private in o (but maybe this is not the case?). I assume that the anonymous class created in new o.T { } calls the T's constructor. If that is the case, then I think creating instances of T should only be possible within o (which was the intention here).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions