[FIR] Implement PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL

^KT-59382 Fixed
This commit is contained in:
Nikolay Lunyak
2023-07-07 17:00:51 +03:00
committed by Space Team
parent 00fb927624
commit 4bba93f633
16 changed files with 79 additions and 82 deletions
@@ -1,21 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: GA.kt
package test.x
open class GA<T> protected constructor()
// FILE: Main.kt
package test
import test.x.GA
class C : GA<Any>() {
companion object {
fun bar() = GA<Any>() // Should be error
}
}
fun main(args: Array<String>) {
C.bar()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: GA.kt
+1 -1
View File
@@ -5,5 +5,5 @@ open class Foo protected constructor()
inline fun foo(f: () -> Unit) = object: Foo() {}
class A : Foo() {
inline fun foo(f: () -> Unit) = <!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE!>Foo<!>()
inline fun foo(f: () -> Unit) = <!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE, PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL!>Foo<!>()
}
@@ -1,26 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class A protected constructor(x: Int) {
protected constructor() : this(1)
public constructor(x: Double) : this(3)
}
class B4 : A(1) {
init {
A()
A(1)
A(5.0)
}
fun foo() {
A()
A(1)
A(5.0)
object : A() {}
object : A(1) {}
object : A(5.0) {}
class Local : A()
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class A protected constructor(x: Int) {
@@ -1,32 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: abc/A.java
package abc;
public class A {
protected A() {}
protected A(int x) {}
public A(double x) {}
}
// FILE: main.kt
import abc.*
class B4 : A(1) {
init {
A()
A(1)
A(5.0)
}
fun foo() {
A()
A(1)
A(5.0)
object : A() {}
object : A(1) {}
object : A(5.0) {}
class Local : A()
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: abc/A.java
@@ -21,8 +21,8 @@ val test3a = MyClass(1.0)
class MyDerived : MyClass(1.0) {
val test4 = <!INVISIBLE_REFERENCE!>MyAlias<!>(1)
val test4a = <!INVISIBLE_REFERENCE!>MyClass<!>(1)
val test5 = MyAlias("")
val test5a = MyClass("")
val test5 = <!PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL!>MyAlias<!>("")
val test5a = <!PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL!>MyClass<!>("")
val test6 = MyAlias(1.0)
val test6a = MyClass(1.0)
}