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.
1 parent c48a598 commit a80a11eCopy full SHA for a80a11e
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))
444
+ fail("Traits cannot have secondary constructors")
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