[FIR] Bring equivalent call behavior closer to K1

#KT-61159 Fixed
This commit is contained in:
Kirill Rakhman
2023-08-14 17:01:29 +02:00
committed by Space Team
parent 7c67e9e08b
commit fa77e3952d
39 changed files with 408 additions and 126 deletions
@@ -1,3 +0,0 @@
Resolved to:
0: (in testing) fun test()
1: (in testing) fun test()
@@ -1,2 +1,3 @@
Resolved to:
0: (in testing) fun test()
0: (in testing) fun test()
1: (in testing) fun test()
@@ -28143,6 +28143,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/allLambdas.kt");
}
@Test
@TestMetadata("equivalentCallsDifferentVisibility.kt")
public void testEquivalentCallsDifferentVisibility() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/equivalentCallsDifferentVisibility.kt");
}
@Test
@TestMetadata("extensionReceiverAndVarargs.kt")
public void testExtensionReceiverAndVarargs() throws Exception {
@@ -28143,6 +28143,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/allLambdas.kt");
}
@Test
@TestMetadata("equivalentCallsDifferentVisibility.kt")
public void testEquivalentCallsDifferentVisibility() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/equivalentCallsDifferentVisibility.kt");
}
@Test
@TestMetadata("extensionReceiverAndVarargs.kt")
public void testExtensionReceiverAndVarargs() throws Exception {
@@ -12,13 +12,13 @@ FILE: mixingImplicitAndExplicitReceivers.kt
public final fun withThis(): R|kotlin/Unit| {
when () {
!=(this@R|/Wrapper|.R|/Wrapper.s|, Null(null)) -> {
R|/takeString|(this@R|/Wrapper|.R|/Wrapper.s|)
<Ambiguity: takeString, [/takeString, /takeString]>#(this@R|/Wrapper|.R|/Wrapper.s|)
}
}
when () {
!=(this@R|/Wrapper|.R|/Wrapper.s|, Null(null)) -> {
R|/takeString|(this@R|/Wrapper|.R|/Wrapper.s|)
<Ambiguity: takeString, [/takeString, /takeString]>#(this@R|/Wrapper|.R|/Wrapper.s|)
}
}
@@ -3,10 +3,10 @@
class Wrapper(val s: String?) {
fun withThis() {
if (s != null) {
takeString(this.s) // Should be OK
<!OVERLOAD_RESOLUTION_AMBIGUITY!>takeString<!>(this.s) // Should be OK
}
if (this.s != null) {
takeString(s) // Should be OK
<!OVERLOAD_RESOLUTION_AMBIGUITY!>takeString<!>(s) // Should be OK
}
}
}
@@ -13,7 +13,7 @@ FILE: beyoundCalls.kt
}
public final fun foo(): R|kotlin/Unit| {
lval x: R|(kotlin/String) -> kotlin/Int| = ::R|/bar|
lval y: R|kotlin/reflect/KFunction1<kotlin/String, kotlin/Int>| = ::R|/bar|
lval y: <ERROR TYPE REF: Ambiguity: bar, [/bar, /bar]> = ::<Ambiguity: bar, [/bar, /bar]>#
lval z: R|kotlin/reflect/KFunction1<kotlin/String, kotlin/Int>| = ::R|/baz|
lval w: R|(kotlin/String) -> kotlin/Int| = ::R|/foobaz<kotlin/String, kotlin/Int>|
::R|/baz|
@@ -6,7 +6,7 @@ fun <T, R> foobaz(x: T): R = TODO()
fun foo() {
val x: (String) -> Int = ::bar
val y = ::bar
val y = ::<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!>
val z = ::baz
val w: (String) -> Int = ::foobaz
@@ -28143,6 +28143,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/allLambdas.kt");
}
@Test
@TestMetadata("equivalentCallsDifferentVisibility.kt")
public void testEquivalentCallsDifferentVisibility() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/equivalentCallsDifferentVisibility.kt");
}
@Test
@TestMetadata("extensionReceiverAndVarargs.kt")
public void testExtensionReceiverAndVarargs() throws Exception {
@@ -28155,6 +28155,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/allLambdas.kt");
}
@Test
@TestMetadata("equivalentCallsDifferentVisibility.kt")
public void testEquivalentCallsDifferentVisibility() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/equivalentCallsDifferentVisibility.kt");
}
@Test
@TestMetadata("extensionReceiverAndVarargs.kt")
public void testExtensionReceiverAndVarargs() throws Exception {
@@ -17402,6 +17402,22 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -17402,6 +17402,22 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -13,17 +13,19 @@ import org.jetbrains.kotlin.fir.resolve.calls.AbstractConeCallConflictResolver
import org.jetbrains.kotlin.fir.resolve.calls.Candidate
import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents
import org.jetbrains.kotlin.fir.scopes.impl.FirStandardOverrideChecker
import org.jetbrains.kotlin.fir.utils.exceptions.withFirEntry
import org.jetbrains.kotlin.resolve.calls.results.FlatSignature
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
// This conflict resolver filters JVM equivalent top-level functions
// like emptyArray() from intrinsics and built-ins
/**
* Resolver that filters out equivalent calls, mainly to deduplicate multiples of the same declaration coming from different versions
* of the same dependency, e.g., multiple stdlibs.
*
* Currently, it will also consider a declaration from source and one from binary equivalent if all conditions are met for backward
* compatibility with K1.
*/
class ConeEquivalentCallConflictResolver(
specificityComparator: TypeSpecificityComparator,
inferenceComponents: InferenceComponents,
transformerComponents: BodyResolveComponents
transformerComponents: BodyResolveComponents,
) : AbstractConeCallConflictResolver(
specificityComparator,
inferenceComponents,
@@ -38,8 +40,13 @@ class ConeEquivalentCallConflictResolver(
}
private fun filterOutEquivalentCalls(candidates: Collection<Candidate>): Set<Candidate> {
// Since we can consider a declaration from source and one from binary equivalent, we need to make sure we favor the one from
// source, otherwise we might get a behavior change to K1.
// See org.jetbrains.kotlin.resolve.calls.results.OverloadingConflictResolver.filterOutEquivalentCalls.
val fromSourceFirst = candidates.sortedBy { it.symbol.fir.source == null }
val result = mutableSetOf<Candidate>()
outerLoop@ for (myCandidate in candidates) {
outerLoop@ for (myCandidate in fromSourceFirst) {
val me = myCandidate.symbol.fir
if (me is FirCallableDeclaration && me.symbol.containingClassLookupTag() == null) {
for (otherCandidate in result) {
@@ -63,6 +70,11 @@ class ConeEquivalentCallConflictResolver(
secondCandidate: Candidate
): Boolean {
if (first.symbol.callableId != second.symbol.callableId) return false
// Emulate behavior from K1 where declarations from the same module are never equivalent.
// We expect REDECLARATION or CONFLICTING_OVERLOADS to be reported in those cases.
// See a.containingDeclaration == b.containingDeclaration check in
// org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides.areCallableDescriptorsEquivalent.
if (first.moduleData == second.moduleData) return false
if (first.isExpect != second.isExpect) return false
if (first is FirVariable != second is FirVariable) {
return false
@@ -73,15 +85,16 @@ class ConeEquivalentCallConflictResolver(
val overrideChecker = FirStandardOverrideChecker(inferenceComponents.session)
return if (first is FirProperty && second is FirProperty) {
overrideChecker.isOverriddenProperty(first, second) && overrideChecker.isOverriddenProperty(second, first)
overrideChecker.isOverriddenProperty(first, second, ignoreVisibility = true) &&
overrideChecker.isOverriddenProperty(second, first, ignoreVisibility = true)
} else if (first is FirSimpleFunction && second is FirSimpleFunction) {
overrideChecker.isOverriddenFunction(first, second) && overrideChecker.isOverriddenFunction(second, first)
overrideChecker.isOverriddenFunction(first, second, ignoreVisibility = true) &&
overrideChecker.isOverriddenFunction(second, first, ignoreVisibility = true)
} else {
false
}
}
/**
* If the candidate is a function, then the arguments
* order representation is an array containing the
@@ -122,32 +122,44 @@ class FirStandardOverrideChecker(private val session: FirSession) : FirAbstractO
}
override fun isOverriddenFunction(overrideCandidate: FirSimpleFunction, baseDeclaration: FirSimpleFunction): Boolean {
return isOverriddenFunction(overrideCandidate, baseDeclaration, ignoreVisibility = false)
}
fun isOverriddenFunction(overrideCandidate: FirSimpleFunction, baseDeclaration: FirSimpleFunction, ignoreVisibility: Boolean): Boolean {
if (overrideCandidate.valueParameters.size != baseDeclaration.valueParameters.size) return false
val substitutor = buildTypeParametersSubstitutorIfCompatible(overrideCandidate, baseDeclaration) ?: return false
if (!commonCallableChecks(overrideCandidate, baseDeclaration, substitutor)) return false
if (!commonCallableChecks(overrideCandidate, baseDeclaration, substitutor, ignoreVisibility)) return false
return overrideCandidate.valueParameters.zip(baseDeclaration.valueParameters).all { (memberParam, selfParam) ->
isEqualTypes(memberParam.returnTypeRef, selfParam.returnTypeRef, substitutor)
}
}
override fun isOverriddenProperty(
override fun isOverriddenProperty(overrideCandidate: FirCallableDeclaration, baseDeclaration: FirProperty): Boolean {
return isOverriddenProperty(overrideCandidate, baseDeclaration, ignoreVisibility = false)
}
fun isOverriddenProperty(
overrideCandidate: FirCallableDeclaration,
baseDeclaration: FirProperty
baseDeclaration: FirProperty,
ignoreVisibility: Boolean,
): Boolean {
if (overrideCandidate !is FirProperty) return false
val substitutor = buildTypeParametersSubstitutorIfCompatible(overrideCandidate, baseDeclaration) ?: return false
return commonCallableChecks(overrideCandidate, baseDeclaration, substitutor)
return commonCallableChecks(overrideCandidate, baseDeclaration, substitutor, ignoreVisibility)
}
private fun FirStandardOverrideChecker.commonCallableChecks(
overrideCandidate: FirCallableDeclaration,
baseDeclaration: FirCallableDeclaration,
substitutor: ConeSubstitutor,
// Overload-ability is used to filter out equivalent calls (see ConeEquivalentCallConflictResolver) in which case visibility
// must be ignored.
ignoreVisibility: Boolean,
): Boolean {
if (Visibilities.isPrivate(baseDeclaration.visibility)) return false
if (!ignoreVisibility && Visibilities.isPrivate(baseDeclaration.visibility)) return false
if (overrideCandidate.contextReceivers.size != baseDeclaration.contextReceivers.size) return false
overrideCandidate.lazyResolveToPhase(FirResolvePhase.TYPES)
@@ -0,0 +1,13 @@
// MODULE: lib
// FILE: lib.kt
val a = "FAIL 1"
// MODULE: main(lib)
// FILE: box.kt
private val a = "OK"
fun box(): String {
if (a != "OK") return a
return "OK"
}
@@ -0,0 +1,16 @@
fun kotlin.String.exampleExtensionFunction() {}
class UserKlass
fun <T> T.erroneousExtensionFunction1() {}
fun kotlin.text.Appendable.erroneousExtensionFunction2() {}
fun test(
exampleReceiver: kotlin.String,
receiver1: UserKlass,
receiver2: kotlin.text.Appendable
) {
exampleReceiver.exampleExtensionFunction()
receiver1.erroneousExtensionFunction1()
receiver2.erroneousExtensionFunction2()
}
@@ -11,7 +11,7 @@ class MyClass2 {}
fun test(mc1: MyClass, mc2: MyClass2) {
val (a, b) = <!COMPONENT_FUNCTION_MISSING!>mc1<!>
val (c) = mc2
val (c) = <!COMPONENT_FUNCTION_AMBIGUITY!>mc2<!>
//a,b,c are error types
use(a, b, c)
@@ -10,9 +10,9 @@ fun f(): Unit<!> = TODO()
fun f(): Unit<!> = TODO()
fun test(a: A, b: B) {
with(a) {
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(a) {
with(b) {
f()
<!OVERLOAD_RESOLUTION_AMBIGUITY!>f<!>()
}
}
}
@@ -0,0 +1,14 @@
// FIR_IDENTICAL
// MODULE: lib
// FILE: lib.kt
val lock = "1"
// MODULE: main(lib)
// FILE: main.kt
private val lock = "2"
fun test() {
lock
}
@@ -8,4 +8,4 @@ fun main(args: Array<String>) {}
fun main(args: Array<String>) {}
// FILE: c.kt
fun foo() { main(arrayOf("a", "b")) }
fun foo() { <!OVERLOAD_RESOLUTION_AMBIGUITY!>main<!>(arrayOf("a", "b")) }
@@ -29323,6 +29323,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/allLambdas.kt");
}
@Test
@TestMetadata("equivalentCallsDifferentVisibility.kt")
public void testEquivalentCallsDifferentVisibility() throws Exception {
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/equivalentCallsDifferentVisibility.kt");
}
@Test
@TestMetadata("extensionReceiverAndVarargs.kt")
public void testExtensionReceiverAndVarargs() throws Exception {
@@ -17000,6 +17000,22 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -17402,6 +17402,22 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -17402,6 +17402,22 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -14405,6 +14405,24 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
}
}
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class EquivalentCalls extends AbstractLightAnalysisModeTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1,97 +0,0 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION -NOTHING_TO_INLINE
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-278
* MAIN LINK: overload-resolution, building-the-overload-candidate-set-ocs, call-without-an-explicit-receiver -> paragraph 5 -> sentence 2
* PRIMARY LINKS: overload-resolution, building-the-overload-candidate-set-ocs, call-without-an-explicit-receiver -> paragraph 4 -> sentence 1
* overload-resolution, building-the-overload-candidate-set-ocs, call-with-an-explicit-receiver -> paragraph 6 -> sentence 4
* overload-resolution, building-the-overload-candidate-set-ocs, call-without-an-explicit-receiver -> paragraph 8 -> sentence 1
* overload-resolution, building-the-overload-candidate-set-ocs, call-without-an-explicit-receiver -> paragraph 6 -> sentence 1
* overload-resolution, building-the-overload-candidate-set-ocs, call-with-specified-type-parameters -> paragraph 1 -> sentence 2
* NUMBER: 4
* DESCRIPTION: The overload candidate sets for each pair of implicit receivers: declared in the package scope extension callables
*/
// FILE: TestCase1.kt
// TESTCASE NUMBER: 1
package testsCase1
import libPackageCase1.*
import libPackageCase1Explicit.emptyArray
<!CONFLICTING_OVERLOADS!>fun <T> Case1.emptyArray(): Array<T><!> = TODO()
class Case1(){
fun case1() {
emptyArray<Int>()
}
}
// FILE: Lib1.kt
package libPackageCase1
import testsCase1.*
public fun <T> emptyArray(): Array<T> = TODO()
fun <T> Case1.emptyArray(): Array<T> = TODO()
// FILE: Lib2.kt
package libPackageCase1Explicit
public fun <T> emptyArray(): Array<T> = TODO()
// FILE: LibtestsPack1.kt
// TESTCASE NUMBER: 1
package testsCase1
<!CONFLICTING_OVERLOADS!>fun <T> Case1.emptyArray(): Array<T><!> = TODO()
public fun <T> emptyArray(): Array<T> = TODO()
// FILE: TestCase2.kt
// TESTCASE NUMBER: 2
package testsCase2
import libPackageCase2.*
import libPackageCase2Explicit.emptyArray
<!CONFLICTING_OVERLOADS!>fun <T> Case2.emptyArray(): Array<T><!> = TODO()
class Case2(){
fun case1() {
emptyArray<Int>()
}
}
val Case2.emptyArray: A
get() = A()
class A {
operator fun invoke(): Unit = TODO()
}
// FILE: Lib3.kt
package libPackageCase2
import testsCase2.*
public fun <T> emptyArray(): Array<T> = TODO()
fun <T> Case2.emptyArray(): Array<T> = TODO()
// FILE: Lib4.kt
package libPackageCase2Explicit
public fun <T> emptyArray(): Array<T> = TODO()
// FILE: LibtestsPack2.kt
// TESTCASE NUMBER: 2
package testsCase2
<!CONFLICTING_OVERLOADS!>fun <T> Case2.emptyArray(): Array<T><!> = TODO()
public fun <T> emptyArray(): Array<T> = TODO()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION -NOTHING_TO_INLINE
// SKIP_TXT
@@ -273,6 +273,16 @@ abstract class AbstractCompileKotlinAgainstCustomBinariesTest : AbstractKotlinCo
doTestPreReleaseKotlinLibrary(K2JVMCompiler(), "library", tmpdir, "-Xallow-unstable-dependencies", "-Xskip-prerelease-check")
}
// KT-61051 K1/K2 difference on extension functions with specific extension receiver types when compiling code that has itself as a dependency
fun testDependencyOnItself() {
val compiledLibrary = compileLibrary("library")
compileKotlin(
"library/sample.kt",
output = tmpdir,
classpath = listOf(compiledLibrary),
)
}
// KT-60795 K2: missing INCOMPATIBLE_CLASS and corresponding CLI error
fun testWrongMetadataVersion() = muteForK2 {
doTestKotlinLibraryWithWrongMetadataVersion("library", null)
@@ -13178,6 +13178,22 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -13178,6 +13178,22 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -13178,6 +13178,22 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -13178,6 +13178,22 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -14263,6 +14263,25 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
@Tag("frontend-fir")
@FirPipeline()
@UseExtTestCaseGroupProvider()
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -14597,6 +14597,27 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
@Tag("frontend-fir")
@FirPipeline()
@UseExtTestCaseGroupProvider()
@UsePartialLinkage(mode = Mode.DISABLED)
@Tag("no-partial-linkage-may-be-skipped")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -14097,6 +14097,24 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
@UseExtTestCaseGroupProvider()
@DisabledTestsIfProperty(sourceLocations = { "compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt", "compiler/testData/codegen/box/multiplatform/defaultArguments/*.kt", "compiler/testData/codegen/box/multiplatform/migratedOldTests/*.kt", "compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt" }, property = ClassLevelProperty.TEST_MODE, propertyValue = "ONE_STAGE_MULTI_MODULE")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -14264,6 +14264,25 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
@UseExtTestCaseGroupProvider()
@UsePartialLinkage(mode = Mode.DISABLED)
@Tag("no-partial-linkage-may-be-skipped")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -13154,6 +13154,22 @@ public class FirWasmCodegenBoxTestGenerated extends AbstractFirWasmCodegenBoxTes
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")
@@ -13154,6 +13154,22 @@ public class K1WasmCodegenBoxTestGenerated extends AbstractK1WasmCodegenBoxTest
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/equivalentCalls")
@TestDataPath("$PROJECT_ROOT")
public class EquivalentCalls {
@Test
public void testAllFilesPresentInEquivalentCalls() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/equivalentCalls"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@Test
@TestMetadata("localEquivalentWins.kt")
public void testLocalEquivalentWins() throws Exception {
runTest("compiler/testData/codegen/box/equivalentCalls/localEquivalentWins.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/evaluate")
@TestDataPath("$PROJECT_ROOT")