Skip to content

Commit 7c486df

Browse files
committed
Fix #2631: Add custom error message
1 parent f595a1a commit 7c486df

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
@@ -389,6 +389,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
389389
}
390390
else if (name.toTermName == nme.ERROR)
391391
UnspecifiedErrorType
392+
else if (ctx.owner.isConstructor && ctx.owner.owner.unforcedDecls.toList.exists(_.name == tree.name))
393+
errorType(ex"$tree is not accessible from super constructor arguments", tree.pos)
392394
else
393395
errorType(new MissingIdent(tree, kind, name.show), tree.pos)
394396

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)