Skip to content

Check trait constructor for accessibility even if not called at Typer #17094

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

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
checkSimpleKinded(parent)
// allow missing type parameters if there are implicit arguments to pass
// since we can infer type arguments from them
val constr = psym.primaryConstructor
if psym.is(Trait) && constr.exists && !cls.isRefinementClass then
ensureAccessible(constr.termRef, superAccess = true, tree.srcPos)
else
checkParentCall(result, cls)
if cls is Case then
Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i17089.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object o:
trait T private[o]()

def test = new o.T { } // error