[FIR] Add tests for companionObjectCall
This commit is contained in:
committed by
Mikhail Glukhikh
parent
f678db2f89
commit
97007ae6c5
@@ -0,0 +1,47 @@
|
||||
// UNEXPECTED BEHAVIOUR
|
||||
// Issue: KT-37056
|
||||
class A()
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
fun case1(a: A?) {
|
||||
val test = a?.let {
|
||||
|
||||
Case1.invoke(it) //resolved to private constructor
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>Case1<!>(it) //resolved to private constructor
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>Case1<!>(A()) //resolved to private constructor
|
||||
}
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>Case1<!>(A()) //resolved to private constructor
|
||||
<!INAPPLICABLE_CANDIDATE!>Case1<!>(a = A()) //resolved to private constructor
|
||||
}
|
||||
|
||||
class Case1 private constructor(val a: String) {
|
||||
companion object {
|
||||
operator fun invoke(a: A) = ""
|
||||
}
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 2
|
||||
fun case2(a: A){
|
||||
<!INAPPLICABLE_CANDIDATE!>Case2<!>(a)
|
||||
<!INAPPLICABLE_CANDIDATE!>Case2<!>(a = a)
|
||||
}
|
||||
|
||||
class Case2 {
|
||||
companion object {
|
||||
operator fun invoke(a: A) = ""
|
||||
}
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
fun case3(a: A){
|
||||
Case3.Companion(a) //ok resolved to (2)
|
||||
Case3.Companion(parameterA = a) //ok resolved to (2)
|
||||
}
|
||||
class Case3 {
|
||||
companion object {
|
||||
operator fun invoke(parameterA: A) = "" //(2)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
FILE: companionObjectCall.kt
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun case1(a: R|A?|): R|kotlin/Unit| {
|
||||
lval test: R|kotlin/Nothing?| = R|<local>/a|?.R|kotlin/let|<R|A|, R|kotlin/Nothing|>(<L> = let@fun <anonymous>(it: R|A|): R|kotlin/Nothing| <kind=EXACTLY_ONCE> {
|
||||
Q|Case1|.R|/Case1.Companion.invoke|(R|<local>/it|)
|
||||
<Inapplicable(HIDDEN): [/Case1.Case1]>#(R|<local>/it|)
|
||||
^ <Inapplicable(HIDDEN): [/Case1.Case1]>#(R|/A.A|())
|
||||
}
|
||||
)
|
||||
<Inapplicable(HIDDEN): [/Case1.Case1]>#(R|/A.A|())
|
||||
<Inapplicable(HIDDEN): [/Case1.Case1]>#(a = R|/A.A|())
|
||||
}
|
||||
public final class Case1 : R|kotlin/Any| {
|
||||
private constructor(a: R|kotlin/String|): R|Case1| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val a: R|kotlin/String| = R|<local>/a|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|Case1.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final operator fun invoke(a: R|A|): R|kotlin/String| {
|
||||
^invoke String()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final fun case2(a: R|A|): R|kotlin/Unit| {
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/Case2.Case2]>#(R|<local>/a|)
|
||||
<Inapplicable(INAPPLICABLE): [/Case2.Case2]>#(a = R|<local>/a|)
|
||||
}
|
||||
public final class Case2 : R|kotlin/Any| {
|
||||
public constructor(): R|Case2| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|Case2.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final operator fun invoke(a: R|A|): R|kotlin/String| {
|
||||
^invoke String()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final fun case3(a: R|A|): R|kotlin/Unit| {
|
||||
Q|Case3|.R|/Case3.Companion|.R|/Case3.Companion.invoke|(R|<local>/a|)
|
||||
Q|Case3|.R|/Case3.Companion|.R|/Case3.Companion.invoke|(parameterA = R|<local>/a|)
|
||||
}
|
||||
public final class Case3 : R|kotlin/Any| {
|
||||
public constructor(): R|Case3| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|Case3.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final operator fun invoke(parameterA: R|A|): R|kotlin/String| {
|
||||
^invoke String()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -48,6 +48,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/resolve/testData/resolve/companion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("companionObjectCall.kt")
|
||||
public void testCompanionObjectCall() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/companionObjectCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("companionUsesNested.kt")
|
||||
public void testCompanionUsesNested() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/companionUsesNested.kt");
|
||||
|
||||
Generated
+5
@@ -48,6 +48,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/resolve/testData/resolve/companion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("companionObjectCall.kt")
|
||||
public void testCompanionObjectCall() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/companionObjectCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("companionUsesNested.kt")
|
||||
public void testCompanionUsesNested() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/companionUsesNested.kt");
|
||||
|
||||
Reference in New Issue
Block a user