[FIR] Correctly detect super type in delegated constructor call
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
// FILE: AJava.java
|
||||
|
||||
public class AJava {
|
||||
public AJava(String s) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
class BJava : AJava, C {
|
||||
constructor(s: String) : super(s)
|
||||
}
|
||||
|
||||
open class AKt(val s: String)
|
||||
|
||||
class BKt : AKt, C {
|
||||
constructor(s: String) : super(s)
|
||||
}
|
||||
|
||||
interface C
|
||||
|
||||
typealias QQQ = AKt
|
||||
|
||||
typealias DDD = C
|
||||
|
||||
class CKt : QQQ, DDD {
|
||||
constructor(s: String) : super(s)
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
FILE: main.kt
|
||||
public final class BJava : R|AJava|, R|C| {
|
||||
public constructor(s: R|kotlin/String|): R|BJava| {
|
||||
super<R|AJava|>(R|<local>/s|)
|
||||
}
|
||||
|
||||
}
|
||||
public open class AKt : R|kotlin/Any| {
|
||||
public constructor(s: R|kotlin/String|): R|AKt| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val s: R|kotlin/String| = R|<local>/s|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public final class BKt : R|AKt|, R|C| {
|
||||
public constructor(s: R|kotlin/String|): R|BKt| {
|
||||
super<R|AKt|>(R|<local>/s|)
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface C : R|kotlin/Any| {
|
||||
}
|
||||
public final typealias QQQ = R|AKt|
|
||||
public final typealias DDD = R|C|
|
||||
public final class CKt : R|QQQ|, R|DDD| {
|
||||
public constructor(s: R|kotlin/String|): R|CKt| {
|
||||
super<R|QQQ|>(R|<local>/s|)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ FILE: LinkedList.kt
|
||||
FILE: HashSet.kt
|
||||
public final class HashSet<T> : R|java/util/HashSet<T>| {
|
||||
public constructor<T>(): R|util/HashSet<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<R|java/util/HashSet<T>|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ FILE: notASupertype.kt
|
||||
}
|
||||
public final class B : R|A| {
|
||||
public constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
public final fun g(): R|kotlin/Unit| {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ FILE: checkArguments.kt
|
||||
}
|
||||
public final class C : R|B| {
|
||||
public constructor(): R|C| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<R|B|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
FILE: test.kt
|
||||
public final class MyDecorator : R|Decorator<LookupElement>| {
|
||||
public constructor(): R|MyDecorator| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<R|Decorator<LookupElement>|>()
|
||||
}
|
||||
|
||||
public final override fun getLookupString(): R|kotlin/String| {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ FILE: test.kt
|
||||
|
||||
public final class Extra : R|test/Test| {
|
||||
public constructor(x: R|kotlin/Int|): R|test/Test.Extra| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<R|test/Test|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/Int| = R|<local>/x|
|
||||
|
||||
Generated
+18
@@ -723,6 +723,24 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/constructors")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Constructors extends AbstractFirDiagnosticsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInConstructors() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/constructors"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("noSuperCallInSupertypes.kt")
|
||||
public void testNoSuperCallInSupertypes() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/delegates")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+18
@@ -723,6 +723,24 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/constructors")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Constructors extends AbstractFirDiagnosticsWithLightTreeTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInConstructors() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/constructors"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("noSuperCallInSupertypes.kt")
|
||||
public void testNoSuperCallInSupertypes() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/delegates")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+28
-2
@@ -6,9 +6,9 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
|
||||
|
||||
import com.intellij.openapi.progress.ProcessCanceledException
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRefsOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeStubDiagnostic
|
||||
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildVariableAssignment
|
||||
import org.jetbrains.kotlin.fir.references.*
|
||||
import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.builder.buildExplicitSuperReference
|
||||
import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
@@ -25,6 +26,7 @@ import org.jetbrains.kotlin.fir.resolve.calls.candidate
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.*
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.InvocationKindTransformer
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.StoreReceiver
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.firClassLike
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType
|
||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
@@ -604,6 +606,21 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
|
||||
when (delegatedConstructorCall.calleeReference) {
|
||||
is FirResolvedNamedReference, is FirErrorNamedReference -> return delegatedConstructorCall.compose()
|
||||
}
|
||||
if (delegatedConstructorCall.isSuper && delegatedConstructorCall.constructedTypeRef is FirImplicitTypeRef) {
|
||||
val containers = components.context.containers
|
||||
val containingClass = containers[containers.lastIndex - 1] as FirClass<*>
|
||||
val superClass = containingClass.superTypeRefs.firstOrNull {
|
||||
if (it !is FirResolvedTypeRef) return@firstOrNull false
|
||||
val declaration = extractSuperTypeDeclaration(it) ?: return@firstOrNull false
|
||||
declaration.classKind == ClassKind.CLASS
|
||||
} as FirResolvedTypeRef? ?: session.builtinTypes.anyType
|
||||
delegatedConstructorCall.replaceConstructedTypeRef(superClass)
|
||||
delegatedConstructorCall.replaceCalleeReference(buildExplicitSuperReference {
|
||||
source = delegatedConstructorCall.calleeReference.source
|
||||
superTypeRef = superClass
|
||||
})
|
||||
}
|
||||
|
||||
dataFlowAnalyzer.enterCall(delegatedConstructorCall)
|
||||
var callCompleted = true
|
||||
var result = delegatedConstructorCall
|
||||
@@ -661,6 +678,15 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractSuperTypeDeclaration(typeRef: FirTypeRef): FirRegularClass? {
|
||||
if (typeRef !is FirResolvedTypeRef) return null
|
||||
return when (val declaration = typeRef.firClassLike(session)) {
|
||||
is FirRegularClass -> declaration
|
||||
is FirTypeAlias -> extractSuperTypeDeclaration(declaration.expandedTypeRef)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
override fun transformAugmentedArraySetCall(augmentedArraySetCall: FirAugmentedArraySetCall, data: ResolutionMode): CompositeTransformResult<FirStatement> {
|
||||
assert(augmentedArraySetCall.operation in FirOperation.ASSIGNMENTS)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
open class A(val x: String) {
|
||||
constructor(`in`: String, y: String) : this(`in` + y)
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
class B : A()
|
||||
|
||||
sealed class A() {
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
open class Base(val callback: () -> String)
|
||||
|
||||
class Outer {
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
inline class S(val string: String)
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
open class A(val x: String = "abc", val y: String = "efg") {
|
||||
constructor(x: String, y: String, z: Int): this(x, y + "#" + z.toString())
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
var log = ""
|
||||
|
||||
open class Base(val s: String)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
internal open class B<T>(val x: T, val y: T) {
|
||||
constructor(x: T): this(x, x)
|
||||
override fun toString() = "$x#$y"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
open class C(val grandParentProp: String)
|
||||
fun box(): String {
|
||||
var sideEffects: String = ""
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
var sideEffects: String = ""
|
||||
|
||||
internal abstract class B {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
class CustomException : Throwable {
|
||||
constructor(message: String?, cause: Throwable?) : super(message, cause)
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
class MyThrowable : Throwable {
|
||||
val x: String
|
||||
|
||||
|
||||
+1
-1
@@ -13,6 +13,6 @@ class B1(x: List<String>) : A<CharSequence>("", x)
|
||||
class B2(x: List<Int>) : <!INAPPLICABLE_CANDIDATE!>A<CharSequence><!>("", x)
|
||||
|
||||
class C : A<CharSequence> {
|
||||
constructor(x: List<String>) : <!INAPPLICABLE_CANDIDATE!>super<!>("", x)
|
||||
constructor(x: List<String>) : super("", x)
|
||||
constructor(x: List<Int>, y: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>("", x)
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -16,6 +16,6 @@ class B1(x: List<String>) : A<CharSequence>("", x)
|
||||
class B2(x: List<Int>) : <!INAPPLICABLE_CANDIDATE!>A<CharSequence><!>("", x)
|
||||
|
||||
class C : A<CharSequence> {
|
||||
constructor(x: List<String>) : <!INAPPLICABLE_CANDIDATE!>super<!>("", x)
|
||||
constructor(x: List<String>) : super("", x)
|
||||
constructor(x: List<Int>, y: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>("", x)
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -8,7 +8,7 @@ expect open class A {
|
||||
}
|
||||
|
||||
expect class B : A {
|
||||
constructor(i: Int)
|
||||
<!INAPPLICABLE_CANDIDATE!>constructor(i: Int)<!>
|
||||
|
||||
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>("B")
|
||||
constructor() : super("B")
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ package toplevelObjectDeclarations
|
||||
open fun foo() : Int = 1
|
||||
}
|
||||
|
||||
class T : Foo {}
|
||||
<!INAPPLICABLE_CANDIDATE!>class T : Foo {}<!>
|
||||
|
||||
object A : Foo {
|
||||
<!INAPPLICABLE_CANDIDATE!>object A<!> : Foo {
|
||||
val x : Int = 2
|
||||
|
||||
fun test() : Int {
|
||||
|
||||
@@ -70,5 +70,5 @@ class B : A("") {
|
||||
}
|
||||
|
||||
class C : A {
|
||||
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>("")
|
||||
constructor() : super("")
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@ open class S(
|
||||
|
||||
class A : S {
|
||||
|
||||
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>(
|
||||
constructor() : super(
|
||||
foo(),
|
||||
Nested(),
|
||||
Inner(),
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ class B2 : A() {}
|
||||
class B3 : A("") {}
|
||||
|
||||
class B4 : A {
|
||||
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>(1)
|
||||
constructor() : super(1)
|
||||
constructor(x: Int) : super()
|
||||
constructor(x: Int, y: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>("")
|
||||
constructor(x: Int, y: Int) : super("")
|
||||
}
|
||||
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
open class Outer {
|
||||
inner open class A protected constructor(x: Int) {
|
||||
protected constructor() : this(1)
|
||||
|
||||
protected constructor(x: String) : this(2)
|
||||
}
|
||||
|
||||
inner class B1 : A(1) {}
|
||||
inner class B2 : A() {}
|
||||
inner class B3 : A("") {}
|
||||
|
||||
inner class B4 : A {
|
||||
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>(1)
|
||||
constructor(x: Int) : super()
|
||||
constructor(x: Int, y: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>("")
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
open class Outer {
|
||||
inner open class A protected constructor(x: Int) {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ class A : B {
|
||||
val myProp: Int = 1
|
||||
override val parentProp = 1
|
||||
|
||||
constructor(x: Int, y: Int = global): <!INAPPLICABLE_CANDIDATE!>super<!>(x + y + global) {
|
||||
constructor(x: Int, y: Int = global): super(x + y + global) {
|
||||
foo(x, y, myProp)
|
||||
x + y + myProp + parentProp + super.parentProp
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,5 +35,5 @@ class A : B {
|
||||
// no cycle, just call to super constuctor
|
||||
constructor(x1: Double, x2: Double): this(x1, x2, 1.0)
|
||||
constructor(x1: Double, x2: Double, x3: Double): this(x1, x2, x3, 1.0)
|
||||
constructor(x1: Double, x2: Double, x3: Double, x4: Double): <!INAPPLICABLE_CANDIDATE!>super<!>(1.toByte())
|
||||
constructor(x1: Double, x2: Double, x3: Double, x4: Double): super(1.toByte())
|
||||
}
|
||||
|
||||
Vendored
+6
-6
@@ -2,8 +2,8 @@
|
||||
open class B0(x: Int)
|
||||
|
||||
class A0 : B0 {
|
||||
constructor()
|
||||
constructor(x: Int) : super()
|
||||
<!INAPPLICABLE_CANDIDATE!>constructor()<!>
|
||||
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>()
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
@@ -26,8 +26,8 @@ open class B2 {
|
||||
}
|
||||
|
||||
class A2 : B2 {
|
||||
constructor()
|
||||
constructor(x: Int) : super()
|
||||
<!INAPPLICABLE_CANDIDATE!>constructor()<!>
|
||||
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>()
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
@@ -37,6 +37,6 @@ open class B3 {
|
||||
}
|
||||
|
||||
class A3 : B3 {
|
||||
constructor()
|
||||
constructor(x: Int) : super()
|
||||
<!INAPPLICABLE_CANDIDATE!>constructor()<!>
|
||||
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>()
|
||||
}
|
||||
@@ -6,14 +6,14 @@ open class B<T>(x: T, y: T) {
|
||||
|
||||
class A0 : B<String?> {
|
||||
constructor()
|
||||
constructor(x: String): <!INAPPLICABLE_CANDIDATE!>super<!>(x)
|
||||
constructor(x: String, y: String): <!INAPPLICABLE_CANDIDATE!>super<!>(x, y)
|
||||
constructor(x: String): super(x)
|
||||
constructor(x: String, y: String): super(x, y)
|
||||
}
|
||||
|
||||
class A1<R> : B<R> {
|
||||
constructor()
|
||||
constructor(x: R): <!INAPPLICABLE_CANDIDATE!>super<!>(x)
|
||||
constructor(x: R, y: R): <!INAPPLICABLE_CANDIDATE!>super<!>(x, y)
|
||||
constructor(x: R): super(x)
|
||||
constructor(x: R, y: R): super(x, y)
|
||||
}
|
||||
|
||||
class A2<R> {
|
||||
|
||||
@@ -13,14 +13,14 @@ class A0<T1, T2> {
|
||||
}
|
||||
|
||||
class A1<T1, T2> : B<T1, T2> {
|
||||
constructor(x: T1, y: T2): <!INAPPLICABLE_CANDIDATE!>super<!>(x, y)
|
||||
constructor(x: T1, y: T2): super(x, y)
|
||||
constructor(x: T1, y: Int): <!INAPPLICABLE_CANDIDATE!>super<!>(x, y)
|
||||
constructor(x: T1, y: T1, z: T1): <!INAPPLICABLE_CANDIDATE!>super<!>(x, y)
|
||||
}
|
||||
|
||||
class A2<T1, T2> : B<T1, Int> {
|
||||
constructor(x: T1, y: T2): <!INAPPLICABLE_CANDIDATE!>super<!>(x, y)
|
||||
constructor(x: T1, y: Int): <!INAPPLICABLE_CANDIDATE!>super<!>(x, y)
|
||||
constructor(x: T1, y: Int): super(x, y)
|
||||
constructor(x: T1, y: T1, z: T1): <!INAPPLICABLE_CANDIDATE!>super<!>(x, y)
|
||||
constructor(x: T1, y: T2, z: String): <!INAPPLICABLE_CANDIDATE!>super<!>(y, 1)
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ open class B<X, Y : X> {
|
||||
}
|
||||
|
||||
class A<T1, T2 : T1> : B<T1, T2> {
|
||||
constructor(x: T1, y: T2): <!INAPPLICABLE_CANDIDATE!>super<!>(x, y)
|
||||
constructor(x: T2, y: T2, z: String): <!INAPPLICABLE_CANDIDATE!>super<!>(x, y)
|
||||
constructor(x: T1, y: T2): super(x, y)
|
||||
constructor(x: T2, y: T2, z: String): super(x, y)
|
||||
|
||||
constructor(x: T2, z: String, z1: String): <!INAPPLICABLE_CANDIDATE!>super<!>(x, "")
|
||||
constructor(x: T2, z: String, z1: String, z2: String): <!INAPPLICABLE_CANDIDATE!>super<!>(x, 1)
|
||||
constructor(x: T1, z: String, z1: String, z2: String, z3: String): <!INAPPLICABLE_CANDIDATE!>super<!>(x, "")
|
||||
constructor(x: T1, z: String, z1: String, z2: String, z3: String, z4: String): <!INAPPLICABLE_CANDIDATE!>super<!>(x, 1)
|
||||
constructor(x: T2, z: String, z1: String): super(x, "")
|
||||
constructor(x: T2, z: String, z1: String, z2: String): super(x, 1)
|
||||
constructor(x: T1, z: String, z1: String, z2: String, z3: String): super(x, "")
|
||||
constructor(x: T1, z: String, z1: String, z2: String, z3: String, z4: String): super(x, 1)
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ open class Base<T>(p: Any?) {
|
||||
|
||||
class D: Base<Int>("") {
|
||||
inner class B : Base<String> {
|
||||
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>(<!INAPPLICABLE_CANDIDATE!>foo1<!>(""))
|
||||
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>(foo1(1))
|
||||
constructor() : super(<!INAPPLICABLE_CANDIDATE!>foo1<!>(""))
|
||||
constructor(x: Int) : super(foo1(1))
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -6,8 +6,8 @@ open class Base<T>(p: Any?) {
|
||||
|
||||
class D: Base<Int>(1) {
|
||||
inner class B : Base<Int> {
|
||||
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>(foo1(1))
|
||||
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>(this@B.<!UNRESOLVED_REFERENCE!>foo1<!>(1))
|
||||
constructor(x: Int, y: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>(this@D.foo1(1))
|
||||
constructor() : super(foo1(1))
|
||||
constructor(x: Int) : super(this@B.<!UNRESOLVED_REFERENCE!>foo1<!>(1))
|
||||
constructor(x: Int, y: Int) : super(this@D.foo1(1))
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,8 +5,8 @@ open class Base(p: Any?) {
|
||||
|
||||
fun Base.foo() {
|
||||
class B : Base {
|
||||
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>(foo1())
|
||||
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>(this@foo.foo1())
|
||||
constructor(x: Int, y: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>(this@B.<!UNRESOLVED_REFERENCE!>foo1<!>())
|
||||
constructor() : super(foo1())
|
||||
constructor(x: Int) : super(this@foo.foo1())
|
||||
constructor(x: Int, y: Int) : super(this@B.<!UNRESOLVED_REFERENCE!>foo1<!>())
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -5,9 +5,9 @@ open class Base<T>(p: Any?) {
|
||||
|
||||
fun Base<Int>.foo() {
|
||||
class B : Base<String> {
|
||||
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>(<!INAPPLICABLE_CANDIDATE!>foo1<!>(""))
|
||||
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>(foo1(1))
|
||||
constructor(x: Int, y: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>(this@foo.foo1(12))
|
||||
constructor(x: Int, y: Int, z: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>(this@B.<!UNRESOLVED_REFERENCE!>foo1<!>(""))
|
||||
constructor() : super(<!INAPPLICABLE_CANDIDATE!>foo1<!>(""))
|
||||
constructor(x: Int) : super(foo1(1))
|
||||
constructor(x: Int, y: Int) : super(this@foo.foo1(12))
|
||||
constructor(x: Int, y: Int, z: Int) : super(this@B.<!UNRESOLVED_REFERENCE!>foo1<!>(""))
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
open class C(val x: Int)
|
||||
|
||||
class D : C {
|
||||
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>(
|
||||
constructor() : super(
|
||||
{
|
||||
val s = ""
|
||||
<!UNRESOLVED_REFERENCE!>s<!>()
|
||||
|
||||
compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt
Vendored
+1
-1
@@ -2,5 +2,5 @@
|
||||
open class A(p1: String, p2: String, p3: String, p4: String, p5: String)
|
||||
|
||||
class B : A {
|
||||
constructor(s: String)
|
||||
<!INAPPLICABLE_CANDIDATE!>constructor(s: String)<!>
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ open class B(x: Double) {
|
||||
interface C
|
||||
class A : B, C {
|
||||
constructor(): <!INAPPLICABLE_CANDIDATE!>super<!>(' ')
|
||||
constructor(x: Int)
|
||||
<!INAPPLICABLE_CANDIDATE!>constructor(x: Int)<!>
|
||||
}
|
||||
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
fun <T> array(vararg x: T): Array<T> = null!!
|
||||
|
||||
open class B(vararg y: String) {
|
||||
constructor(x: Int): this(x.toString(), *array("1"), "2")
|
||||
}
|
||||
|
||||
class A : B {
|
||||
constructor(x: String, y: String): <!INAPPLICABLE_CANDIDATE!>super<!>(x, *array("3"), y)
|
||||
constructor(x: String): <!INAPPLICABLE_CANDIDATE!>super<!>(x)
|
||||
constructor(): super()
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
fun <T> array(vararg x: T): Array<T> = null!!
|
||||
|
||||
|
||||
Vendored
-17
@@ -1,17 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
fun <T> array(vararg x: T): Array<T> = null!!
|
||||
|
||||
open class B(x: Int) {
|
||||
constructor(vararg y: String): this(y[0].length)
|
||||
}
|
||||
|
||||
class A : B {
|
||||
constructor(x: String, y: String): <!INAPPLICABLE_CANDIDATE!>super<!>(x, *array("q"), y)
|
||||
constructor(x: String): <!INAPPLICABLE_CANDIDATE!>super<!>(x)
|
||||
constructor(): super()
|
||||
}
|
||||
|
||||
val b1 = B()
|
||||
val b2 = B("1", "2", "3")
|
||||
val b3 = B("1", *array("2", "3"), "4")
|
||||
val b4 = B(1)
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
fun <T> array(vararg x: T): Array<T> = null!!
|
||||
|
||||
|
||||
+2
-2
@@ -60,13 +60,13 @@ open class Foo10(x: Int = 10, y: Float = 0f)
|
||||
class Foo11: Foo10 {
|
||||
constructor(
|
||||
x: Float
|
||||
): <!INAPPLICABLE_CANDIDATE!>super<!>(1, 1f,)
|
||||
): super(1, 1f,)
|
||||
}
|
||||
|
||||
class Foo12: Foo10 {
|
||||
constructor(
|
||||
x: Float
|
||||
): <!INAPPLICABLE_CANDIDATE!>super<!>(1, 1f,/**/)
|
||||
): super(1, 1f,/**/)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
|
||||
compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.fir.kt
Vendored
-104
@@ -1,104 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_ANONYMOUS_PARAMETER, -UNUSED_VARIABLE
|
||||
// !LANGUAGE: +TrailingCommas
|
||||
|
||||
open class Foo1(x: Int = 10, y: Float = 0f,)
|
||||
|
||||
class Foo2(
|
||||
val x: Int = 10,
|
||||
var y: Float,
|
||||
): Foo1(x, y) {
|
||||
constructor(
|
||||
x: Float,
|
||||
y: Int = 10,
|
||||
): this(1, 1f,) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
enum class Foo3(x: Int, )
|
||||
|
||||
fun foo4(x: Int, y: Comparable<Float>,) {}
|
||||
|
||||
fun foo5(x: Int = 10,) {}
|
||||
|
||||
fun foo6(vararg x: Int,) {}
|
||||
|
||||
fun foo61(vararg x: Int,/**/) {}
|
||||
|
||||
fun foo7(y: Float, vararg x: Int,) {}
|
||||
|
||||
val foo8: (Int, Int,) -> Int = fun(
|
||||
x,
|
||||
y,
|
||||
): Int {
|
||||
return x + y
|
||||
}
|
||||
|
||||
val foo9: (Int, Int, Int,) -> Int =
|
||||
fun (x, y: Int, z,): Int {
|
||||
return x + y
|
||||
}
|
||||
|
||||
open class Foo10(x: Int = 10, y: Float = 0f)
|
||||
|
||||
class Foo11: Foo10 {
|
||||
constructor(
|
||||
x: Float
|
||||
): <!INAPPLICABLE_CANDIDATE!>super<!>(1, 1f,)
|
||||
}
|
||||
|
||||
class Foo12: Foo10 {
|
||||
constructor(
|
||||
x: Float
|
||||
): <!INAPPLICABLE_CANDIDATE!>super<!>(1, 1f,/**/)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val x1 = {
|
||||
x: Comparable<Comparable<Number>>,
|
||||
y: Iterable<Iterable<Number>>,
|
||||
->
|
||||
println("1")
|
||||
}
|
||||
val x11 = {
|
||||
x: Comparable<Comparable<Number>>,
|
||||
y: Iterable<Iterable<Number>>,/**/
|
||||
->
|
||||
println("1")
|
||||
}
|
||||
val x2 = { x: Comparable<Comparable<Number>>,
|
||||
-> println("1")
|
||||
}
|
||||
val x3: ((Int,) -> Int) -> Unit = { x: (Int,) -> Int, -> println("1") }
|
||||
val x4: ((Int,) -> Int) -> Unit = { x, -> println("1") }
|
||||
|
||||
try {
|
||||
println(1)
|
||||
} catch (e: Exception,) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
println(1)
|
||||
} catch (e: Exception,) {
|
||||
|
||||
} catch (e: Exception,) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
println(1)
|
||||
} catch (e: Exception,) {
|
||||
|
||||
} finally {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
println(1)
|
||||
} catch (e: Exception,/**/) {
|
||||
|
||||
} finally {
|
||||
|
||||
}
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_ANONYMOUS_PARAMETER, -UNUSED_VARIABLE
|
||||
// !LANGUAGE: +TrailingCommas
|
||||
|
||||
|
||||
+12
-5
@@ -88,7 +88,14 @@ FILE fqName:<root> fileName:/argumentReorderingInDelegatingConstructorCall.kt
|
||||
VALUE_PARAMETER name:xx index:0 type:kotlin.Int
|
||||
VALUE_PARAMETER name:yy index:1 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
ERROR_CALL 'Cannot find delegated constructor call' type=kotlin.Any
|
||||
BLOCK type=<root>.Base origin=ARGUMENTS_REORDERING_FOR_CALL
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val]
|
||||
GET_VAR 'yy: kotlin.Int declared in <root>.Test2.<init>' type=kotlin.Int origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val]
|
||||
GET_VAR 'xx: kotlin.Int declared in <root>.Test2.<init>' type=kotlin.Int origin=null
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (x: kotlin.Int, y: kotlin.Int) [primary] declared in <root>.Base'
|
||||
x: GET_VAR 'val tmp_3: kotlin.Int [val] declared in <root>.Test2.<init>' type=kotlin.Int origin=null
|
||||
y: GET_VAR 'val tmp_2: kotlin.Int [val] declared in <root>.Test2.<init>' type=kotlin.Int origin=null
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[<root>.Base]'
|
||||
CONSTRUCTOR visibility:public <> (xxx:kotlin.Int, yyy:kotlin.Int, a:kotlin.Any) returnType:<root>.Test2
|
||||
VALUE_PARAMETER name:xxx index:0 type:kotlin.Int
|
||||
@@ -96,13 +103,13 @@ FILE fqName:<root> fileName:/argumentReorderingInDelegatingConstructorCall.kt
|
||||
VALUE_PARAMETER name:a index:2 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
BLOCK type=<root>.Test2 origin=ARGUMENTS_REORDERING_FOR_CALL
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val]
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val]
|
||||
GET_VAR 'yyy: kotlin.Int declared in <root>.Test2.<init>' type=kotlin.Int origin=null
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val]
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val]
|
||||
GET_VAR 'xxx: kotlin.Int declared in <root>.Test2.<init>' type=kotlin.Int origin=null
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (xx: kotlin.Int, yy: kotlin.Int) declared in <root>.Test2'
|
||||
xx: GET_VAR 'val tmp_3: kotlin.Int [val] declared in <root>.Test2.<init>' type=kotlin.Int origin=null
|
||||
yy: GET_VAR 'val tmp_2: kotlin.Int [val] declared in <root>.Test2.<init>' type=kotlin.Int origin=null
|
||||
xx: GET_VAR 'val tmp_5: kotlin.Int [val] declared in <root>.Test2.<init>' type=kotlin.Int origin=null
|
||||
yy: GET_VAR 'val tmp_4: kotlin.Int [val] declared in <root>.Test2.<init>' type=kotlin.Int origin=null
|
||||
PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val]
|
||||
FUN FAKE_OVERRIDE name:<get-x> visibility:public modality:FINAL <> ($this:<root>.Base) returnType:kotlin.Int [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val]
|
||||
|
||||
Vendored
+2
-2
@@ -22,12 +22,12 @@ FILE fqName:<root> fileName:/delegatingConstructorCallsInSecondaryConstructors.k
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Test
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Base'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[<root>.Base]'
|
||||
CONSTRUCTOR visibility:public <> (xx:kotlin.Int) returnType:<root>.Test
|
||||
VALUE_PARAMETER name:xx index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Base'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[<root>.Base]'
|
||||
CONSTRUCTOR visibility:public <> (xx:kotlin.Short) returnType:<root>.Test
|
||||
VALUE_PARAMETER name:xx index:0 type:kotlin.Short
|
||||
|
||||
Vendored
+3
-3
@@ -33,7 +33,7 @@ FILE fqName:<root> fileName:/secondaryConstructorWithInitializersFromClassBody.k
|
||||
receiver: GET_VAR '<this>: <root>.TestProperty declared in <root>.TestProperty.<get-x>' type=<root>.TestProperty origin=null
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.TestProperty
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Base'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestProperty modality:FINAL visibility:public superTypes:[<root>.Base]'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
@@ -66,12 +66,12 @@ FILE fqName:<root> fileName:/secondaryConstructorWithInitializersFromClassBody.k
|
||||
value: CONST Int type=kotlin.Int value=0
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.TestInitBlock
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Base'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestInitBlock modality:FINAL visibility:public superTypes:[<root>.Base]'
|
||||
CONSTRUCTOR visibility:public <> (z:kotlin.Any) returnType:<root>.TestInitBlock
|
||||
VALUE_PARAMETER name:z index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Base'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestInitBlock modality:FINAL visibility:public superTypes:[<root>.Base]'
|
||||
CONSTRUCTOR visibility:public <> (y:kotlin.Int) returnType:<root>.TestInitBlock
|
||||
VALUE_PARAMETER name:y index:0 type:kotlin.Int
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ FILE fqName:<root> fileName:/expectClassInherited.kt
|
||||
CONSTRUCTOR visibility:public <> (i:kotlin.Int) returnType:<root>.B [primary]
|
||||
VALUE_PARAMETER name:i index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
DELEGATING_CONSTRUCTOR_CALL 'protected constructor <init> () [primary] declared in <root>.A'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:OPEN visibility:public [expect] superTypes:[<root>.A]'
|
||||
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.B) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ FILE fqName:<root> fileName:/expectedSealedClass.kt
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Add
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Add [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
DELEGATING_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.Ops'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Add modality:FINAL visibility:public [expect] superTypes:[<root>.Ops]'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ FILE fqName:<root> fileName:/kt16904.kt
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test1
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Test1
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[<root>.A]'
|
||||
CALL 'public final fun plusAssign (x: kotlin.Int): kotlin.Unit [operator] declared in <root>.B' type=kotlin.Unit origin=null
|
||||
$this: CALL 'public final fun <get-x> (): <root>.B declared in <root>.A' type=<root>.B origin=GET_PROPERTY
|
||||
|
||||
Reference in New Issue
Block a user