Skip to content

Commit b53660a

Browse files
committed
Fix #2631: Add custom error message
1 parent 0094097 commit b53660a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ class Typer extends Namer
396396
}
397397
else if (name.toTermName == nme.ERROR)
398398
UnspecifiedErrorType
399+
else if (ctx.owner.isConstructor && ctx.owner.owner.unforcedDecls.toList.exists(_.name == tree.name))
400+
errorType(ex"$tree is not accessible from super constructor arguments", tree.pos)
399401
else
400402
errorType(new MissingIdent(tree, kind, name.show), tree.pos)
401403

compiler/test-resources/repl/i2631

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
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 super constructor arguments

0 commit comments

Comments
 (0)