We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 86d5d69 + 864f81d commit 957a80fCopy full SHA for 957a80f
compiler/src/dotty/tools/dotc/typer/Checking.scala
@@ -440,6 +440,8 @@ object Checking {
440
}
441
if (sym.isValueClass && sym.is(Trait) && !sym.isRefinementClass)
442
fail(CannotExtendAnyVal(sym))
443
+ if (sym.isConstructor && !sym.isPrimaryConstructor && sym.owner.is(Trait, butNot = JavaDefined))
444
+ fail("Traits cannot have secondary constructors " + sym.owner.flagsString)
445
checkCombination(Final, Open)
446
checkCombination(Sealed, Open)
447
checkCombination(Final, Sealed)
tests/neg/i8186.scala
@@ -0,0 +1,9 @@
1
+trait Test1() {
2
+ def this(x: Int) = // error
3
+ this()
4
+}
5
+
6
+trait Test2(x: Int) {
7
+ def this() = // error
8
+ this(3)
9
0 commit comments