File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -396,7 +396,12 @@ class Typer extends Namer
396396 }
397397 else if (name.toTermName == nme.ERROR )
398398 UnspecifiedErrorType
399- else
399+ else if (ctx.owner.isConstructor && ctx.mode.is(Mode .InSuperCall ) &&
400+ ctx.owner.owner.unforcedDecls.lookup(tree.name).exists) {
401+ // When InSuperCall mode and in a constructor we are in the arguments
402+ // of a this(...) constructor call
403+ errorType(ex " $tree is not accessible from constructor arguments " , tree.pos)
404+ } else
400405 errorType(new MissingIdent (tree, kind, name.show), tree.pos)
401406
402407 val tree1 = ownType match {
Original file line number Diff line number Diff line change 1+ scala> class Foo(x : Any) { val foo : Integer = 0; def this() = { this(foo) } }
2+ 1 | class Foo(x : Any) { val foo : Integer = 0; def this() = { this(foo) } }
3+ | ^^^
4+ | foo is not accessible from constructor arguments
You can’t perform that action at this time.
0 commit comments