We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 05c0b52 commit 4be3172Copy full SHA for 4be3172
tests/neg/protected-constructors.scala
@@ -0,0 +1,17 @@
1
+class A protected (x: Int)
2
+
3
+// Protected constructor in super call arguments (transitive parent)
4
+class B(a: A) extends A(a.hashCode)
5
+class C extends B(new A(1)) // error
6
7
+// Protected constructor in own parent's arguments
8
+class D protected (x: Any)
9
+class E extends D(new D(1)) // error
10
11
+// Mixed visibility constructors
12
+class F protected (x: Int) {
13
+ def this() = this(0) // public secondary
14
+}
15
+class G(f: F) extends F(f.hashCode)
16
+class H extends G(new F()) // ok: public secondary in super args
17
+class J extends G(new F(1)) // error: protected primary in super args
0 commit comments