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
396
396
}
397
397
else if (name.toTermName == nme.ERROR )
398
398
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
400
405
errorType(new MissingIdent (tree, kind, name.show), tree.pos)
401
406
402
407
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