Private constructors are now accessed via synthetic constructor with DEFAULT_CONSTRUCTOR_MARKER as an additional argument #KT-6299 Fixed
A set of tests provided. Some external tests fixed accordingly. Companion object creation changed accordingly. Derived classes now can use base class with the private constructor. Refactoring of AccessorForFunctionDescriptor.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// See also KT-6299
|
||||
public open class Outer private constructor() {
|
||||
class Inner: Outer()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val outer = Outer.Inner()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// See also KT-6299
|
||||
public open class Outer private constructor() {
|
||||
companion object {
|
||||
fun foo() = Outer()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val outer = Outer.foo()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// See also KT-6299
|
||||
public open class Outer private constructor() {
|
||||
companion object {
|
||||
inline fun foo() = Outer()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val outer = Outer.foo()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// See also KT-6299
|
||||
public open class Outer private constructor(val s: String) {
|
||||
inner class Inner: Outer("O") {
|
||||
fun foo(): String {
|
||||
return this.s + this@Outer.s
|
||||
}
|
||||
}
|
||||
class Nested: Outer("K")
|
||||
fun bar() = Inner()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val inner = Outer.Nested().bar()
|
||||
return inner.foo()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// See also KT-6299
|
||||
public open class Outer private constructor(val x: Int) {
|
||||
constructor(): this(42)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val outer = Outer()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// See also KT-6299
|
||||
public open class Outer private constructor(val s: String, val f: Boolean = true) {
|
||||
class Inner: Outer("xyz")
|
||||
class Other: Outer("abc", true)
|
||||
class Another: Outer("", false)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val outer = Outer.Inner()
|
||||
val other = Outer.Other()
|
||||
val another = Outer.Another()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// See also KT-6299
|
||||
public open class Outer private constructor(val x: Int = 0) {
|
||||
class Inner: Outer()
|
||||
class Other: Outer(42)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val outer = Outer.Inner()
|
||||
val other = Outer.Other()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// See also KT-6299
|
||||
public open class Outer private constructor(val p: Outer?) {
|
||||
object First: Outer(null)
|
||||
class Other(p: Outer = First): Outer(p)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val second = Outer.Other()
|
||||
val third = Outer.Other(second)
|
||||
val fourth = Outer.Other(third)
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// See also KT-6299
|
||||
public open class Outer private constructor(val p: Outer?) {
|
||||
object Inner: Outer(null)
|
||||
object Other: Outer(Inner)
|
||||
object Another: Outer(Other)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val outer = Outer.Inner
|
||||
val other = Outer.Other
|
||||
val another = Outer.Another
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// See also KT-6299
|
||||
public open class Outer private constructor(val s: String, vararg i: Int) {
|
||||
class Inner: Outer("xyz")
|
||||
class Other: Outer("abc", 1, 2, 3)
|
||||
class Another: Outer("", 42)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val outer = Outer.Inner()
|
||||
val other = Outer.Other()
|
||||
val another = Outer.Another()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user