[FIR] Fix overload resolution ambiguity between expect and non-expect in native
^KT-61778 Fixed
This commit is contained in:
committed by
Space Team
parent
57357d1995
commit
8e0c2af176
+5
-3
@@ -318,21 +318,23 @@ class ConeOverloadConflictResolver(
|
||||
private fun List<CandidateSignature>.exactMaxWith(): CandidateSignature? {
|
||||
var result: CandidateSignature? = null
|
||||
for (candidate in this) {
|
||||
if (result == null || isOfNotLessSpecificShape(candidate, result)) {
|
||||
if (result == null || checkExpectAndNotLessSpecificShape(candidate, result)) {
|
||||
result = candidate
|
||||
}
|
||||
}
|
||||
if (result == null) return null
|
||||
if (any { it != result && isOfNotLessSpecificShape(it, result) }) {
|
||||
if (any { it != result && checkExpectAndNotLessSpecificShape(it, result) }) {
|
||||
return null
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun isOfNotLessSpecificShape(
|
||||
private fun checkExpectAndNotLessSpecificShape(
|
||||
call1: FlatSignature<Candidate>,
|
||||
call2: FlatSignature<Candidate>
|
||||
): Boolean {
|
||||
if (!call1.isExpect && call2.isExpect) return true
|
||||
if (call1.isExpect && !call2.isExpect) return false
|
||||
val hasVarargs1 = call1.hasVarargs
|
||||
val hasVarargs2 = call2.hasVarargs
|
||||
if (hasVarargs1 && !hasVarargs2) return false
|
||||
|
||||
+13
@@ -201,4 +201,17 @@ class CustomK2Tests : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@GradleTest
|
||||
@DisplayName("No overload resolution ambiguity between expect and non-expect in native")
|
||||
fun kt61778NoOverloadResolutionAmbiguityBetweenExpectAndNonExpectInNative(gradleVersion: GradleVersion) {
|
||||
project(
|
||||
"k2-no-overload-resolution-ambiguity-between-expect-and-non-expect-in-native", gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copyEnsuringK2()
|
||||
) {
|
||||
build("compileCommonMainKotlinMetadata") {
|
||||
assertTasksExecuted(":compileCommonMainKotlinMetadata")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// ISSUE: KT-61778
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
applyDefaultHierarchyTemplate()
|
||||
|
||||
linuxX64()
|
||||
macosArm64()
|
||||
macosX64()
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
private val mutexPool by lazy { 42 }
|
||||
Reference in New Issue
Block a user