Use modules instead of files for MPP diagnostic
Using files turned to be a bad idea, because people often use the same name for files with expects and with corresponding actuals. This commits disambiguiates ambiguous message for AMBIGUOUS_ACTUALS/AMBGIUOUS_EXPECTS diagnostics by using modules instead of files ^KT-32582 Fixed
This commit is contained in:
@@ -648,9 +648,9 @@ public interface Errors {
|
|||||||
DiagnosticFactory2<KtNamedDeclaration, MemberDescriptor,
|
DiagnosticFactory2<KtNamedDeclaration, MemberDescriptor,
|
||||||
Map<Incompatible, Collection<MemberDescriptor>>> ACTUAL_WITHOUT_EXPECT =
|
Map<Incompatible, Collection<MemberDescriptor>>> ACTUAL_WITHOUT_EXPECT =
|
||||||
DiagnosticFactory2.create(ERROR, INCOMPATIBLE_DECLARATION);
|
DiagnosticFactory2.create(ERROR, INCOMPATIBLE_DECLARATION);
|
||||||
DiagnosticFactory2<KtNamedDeclaration, DeclarationDescriptor, Collection<String>> AMBIGUOUS_ACTUALS =
|
DiagnosticFactory2<KtNamedDeclaration, DeclarationDescriptor, Collection<ModuleDescriptor>> AMBIGUOUS_ACTUALS =
|
||||||
DiagnosticFactory2.create(ERROR, INCOMPATIBLE_DECLARATION);
|
DiagnosticFactory2.create(ERROR, INCOMPATIBLE_DECLARATION);
|
||||||
DiagnosticFactory2<KtNamedDeclaration, DeclarationDescriptor, Collection<String>> AMBIGUOUS_EXPECTS =
|
DiagnosticFactory2<KtNamedDeclaration, DeclarationDescriptor, Collection<ModuleDescriptor>> AMBIGUOUS_EXPECTS =
|
||||||
DiagnosticFactory2.create(ERROR, INCOMPATIBLE_DECLARATION);
|
DiagnosticFactory2.create(ERROR, INCOMPATIBLE_DECLARATION);
|
||||||
|
|
||||||
DiagnosticFactory2<KtNamedDeclaration, ClassDescriptor,
|
DiagnosticFactory2<KtNamedDeclaration, ClassDescriptor,
|
||||||
|
|||||||
+2
-2
@@ -288,9 +288,9 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(ACTUAL_WITHOUT_EXPECT, "{0} has no corresponding expected declaration{1}", CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM,
|
MAP.put(ACTUAL_WITHOUT_EXPECT, "{0} has no corresponding expected declaration{1}", CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM,
|
||||||
PlatformIncompatibilityDiagnosticRenderer.TEXT);
|
PlatformIncompatibilityDiagnosticRenderer.TEXT);
|
||||||
MAP.put(AMBIGUOUS_ACTUALS, "{0} has several compatible actual declarations in modules {1}", CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM, commaSeparated(
|
MAP.put(AMBIGUOUS_ACTUALS, "{0} has several compatible actual declarations in modules {1}", CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM, commaSeparated(
|
||||||
STRING));
|
MODULE));
|
||||||
MAP.put(AMBIGUOUS_EXPECTS, "{0} has several compatible expect declarations in modules {1}", CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM, commaSeparated(
|
MAP.put(AMBIGUOUS_EXPECTS, "{0} has several compatible expect declarations in modules {1}", CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM, commaSeparated(
|
||||||
STRING));
|
MODULE));
|
||||||
|
|
||||||
MAP.put(NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, "Actual class ''{0}'' has no corresponding members for expected class members:{1}",
|
MAP.put(NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, "Actual class ''{0}'' has no corresponding members for expected class members:{1}",
|
||||||
NAME, IncompatibleExpectedActualClassScopesRenderer.TEXT);
|
NAME, IncompatibleExpectedActualClassScopesRenderer.TEXT);
|
||||||
|
|||||||
@@ -82,11 +82,16 @@ object Renderers {
|
|||||||
@JvmField
|
@JvmField
|
||||||
val MODULE_WITH_PLATFORM = Renderer<ModuleDescriptor> { module ->
|
val MODULE_WITH_PLATFORM = Renderer<ModuleDescriptor> { module ->
|
||||||
val platform = module.platform
|
val platform = module.platform
|
||||||
val moduleName = module.moduleInfo?.unwrapPlatform()?.displayedName ?: ""
|
val moduleName = MODULE.render(module)
|
||||||
val platformNameIfAny = if (platform == null || platform.isCommon()) "" else " for " + platform.single().platformName
|
val platformNameIfAny = if (platform == null || platform.isCommon()) "" else " for " + platform.single().platformName
|
||||||
|
|
||||||
moduleName + platformNameIfAny
|
moduleName + platformNameIfAny
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
val MODULE = Renderer<ModuleDescriptor> { module ->
|
||||||
|
module.moduleInfo?.unwrapPlatform()?.displayedName ?: module.name.asString()
|
||||||
|
}
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val VISIBILITY = Renderer<Visibility> {
|
val VISIBILITY = Renderer<Visibility> {
|
||||||
|
|||||||
+4
-4
@@ -144,8 +144,8 @@ class ExpectedActualDeclarationChecker(
|
|||||||
reportOn,
|
reportOn,
|
||||||
descriptor,
|
descriptor,
|
||||||
atLeastWeaklyCompatibleActuals
|
atLeastWeaklyCompatibleActuals
|
||||||
.map { DescriptorUtils.getContainingSourceFile(it).let { it.name ?: it.toString() } }
|
.map { it.module }
|
||||||
.sorted()
|
.sortedBy { it.name.asString() }
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,8 +305,8 @@ class ExpectedActualDeclarationChecker(
|
|||||||
}
|
}
|
||||||
.map { (_, members) -> members }
|
.map { (_, members) -> members }
|
||||||
.flatten()
|
.flatten()
|
||||||
.map { DescriptorUtils.getContainingSourceFile(it).let { it.name ?: it.toString() } }
|
.map { it.module }
|
||||||
.sorted()
|
.sortedBy { it.name.asString() }
|
||||||
.toList()
|
.toList()
|
||||||
|
|
||||||
if (filesWithAtLeastWeaklyCompatibleExpects.size > 1) {
|
if (filesWithAtLeastWeaklyCompatibleExpects.size > 1) {
|
||||||
|
|||||||
@@ -5,73 +5,73 @@ Output:
|
|||||||
-- JVM --
|
-- JVM --
|
||||||
Exit code: COMPILATION_ERROR
|
Exit code: COMPILATION_ERROR
|
||||||
Output:
|
Output:
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:1:12: error: expected function 'f1' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:1:12: error: expected function 'f1' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because return type is different:
|
The following declaration is incompatible because return type is different:
|
||||||
public actual fun f1(): String
|
public actual fun f1(): String
|
||||||
|
|
||||||
expect fun f1()
|
expect fun f1()
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:5:14: error: expected function 'f3' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:5:14: error: expected function 'f3' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because parameter types are different:
|
The following declaration is incompatible because parameter types are different:
|
||||||
public actual fun f3(name: Double): Unit
|
public actual fun f3(name: Double): Unit
|
||||||
|
|
||||||
expect fun f3(name: String)
|
expect fun f3(name: String)
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:6:24: error: expected function 'f3ext' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:6:24: error: expected function 'f3ext' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because parameter types are different:
|
The following declaration is incompatible because parameter types are different:
|
||||||
public actual fun Double.f3ext(): Unit
|
public actual fun Double.f3ext(): Unit
|
||||||
|
|
||||||
expect fun String.f3ext()
|
expect fun String.f3ext()
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:8:14: error: expected function 'f4' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:8:14: error: expected function 'f4' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because parameter shapes are different (extension vs non-extension):
|
The following declaration is incompatible because parameter shapes are different (extension vs non-extension):
|
||||||
public actual fun String.f4(): Unit
|
public actual fun String.f4(): Unit
|
||||||
|
|
||||||
expect fun f4(name: String)
|
expect fun f4(name: String)
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:10:12: error: expected function 'f5' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:10:12: error: expected function 'f5' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because parameter shapes are different (extension vs non-extension):
|
The following declaration is incompatible because parameter shapes are different (extension vs non-extension):
|
||||||
public actual fun f5(name: String): Unit
|
public actual fun f5(name: String): Unit
|
||||||
|
|
||||||
expect fun String.f5()
|
expect fun String.f5()
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:12:14: error: expected function 'f6' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:12:14: error: expected function 'f6' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because number of value parameters is different:
|
The following declaration is incompatible because number of value parameters is different:
|
||||||
public actual fun f6(p2: Int): Unit
|
public actual fun f6(p2: Int): Unit
|
||||||
|
|
||||||
expect fun f6(p1: String, p2: Int)
|
expect fun f6(p1: String, p2: Int)
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:14:12: error: expected function 'f7' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:14:12: error: expected function 'f7' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because number of type parameters is different:
|
The following declaration is incompatible because number of type parameters is different:
|
||||||
public actual fun <K, V> f7(): Unit
|
public actual fun <K, V> f7(): Unit
|
||||||
|
|
||||||
expect fun <T> f7()
|
expect fun <T> f7()
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:19:12: error: expected function 'f11' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:19:12: error: expected function 'f11' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because upper bounds of type parameters are different:
|
The following declaration is incompatible because upper bounds of type parameters are different:
|
||||||
public actual fun <T : Annotation> f11(): Unit
|
public actual fun <T : Annotation> f11(): Unit
|
||||||
|
|
||||||
expect fun <T : Number> f11()
|
expect fun <T : Number> f11()
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:20:12: error: expected function 'f12' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:20:12: error: expected function 'f12' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because upper bounds of type parameters are different:
|
The following declaration is incompatible because upper bounds of type parameters are different:
|
||||||
public actual fun <U : MutableList<out String>> f12(): Unit
|
public actual fun <U : MutableList<out String>> f12(): Unit
|
||||||
|
|
||||||
expect fun <U : MutableList<String>> f12()
|
expect fun <U : MutableList<String>> f12()
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:21:12: error: expected function 'f13' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:21:12: error: expected function 'f13' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because upper bounds of type parameters are different:
|
The following declaration is incompatible because upper bounds of type parameters are different:
|
||||||
public actual fun <A, B : Comparable<B>> f13(): Unit
|
public actual fun <A, B : Comparable<B>> f13(): Unit
|
||||||
|
|
||||||
expect fun <A, B : Comparable<A>> f13()
|
expect fun <A, B : Comparable<A>> f13()
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:32:15: error: expected function 'f21' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:32:15: error: expected function 'f21' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because parameter types are different:
|
The following declaration is incompatible because parameter types are different:
|
||||||
public actual fun f21(c: Unit.() -> Unit): Unit
|
public actual fun f21(c: Unit.() -> Unit): Unit
|
||||||
|
|
||||||
expect fun f21(c: suspend Unit.() -> Unit)
|
expect fun f21(c: suspend Unit.() -> Unit)
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleCallables/common.kt:33:15: error: expected function 'f22' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleCallables/common.kt:33:15: error: expected function 'f22' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because parameter types are different:
|
The following declaration is incompatible because parameter types are different:
|
||||||
public actual fun f22(c: suspend Unit.() -> Unit): Unit
|
public actual fun f22(c: suspend Unit.() -> Unit): Unit
|
||||||
|
|
||||||
|
|||||||
@@ -5,19 +5,19 @@ Output:
|
|||||||
-- JVM --
|
-- JVM --
|
||||||
Exit code: COMPILATION_ERROR
|
Exit code: COMPILATION_ERROR
|
||||||
Output:
|
Output:
|
||||||
compiler/testData/multiplatform/incompatibleClasses/common.kt:14:16: error: expected class 'C1' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleClasses/common.kt:14:16: error: expected class 'C1' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because number of type parameters is different:
|
The following declaration is incompatible because number of type parameters is different:
|
||||||
public final actual class C1<A, Extra>
|
public final actual class C1<A, Extra>
|
||||||
|
|
||||||
expect class C1<A>
|
expect class C1<A>
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleClasses/common.kt:16:16: error: expected class 'C3' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleClasses/common.kt:16:16: error: expected class 'C3' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because upper bounds of type parameters are different:
|
The following declaration is incompatible because upper bounds of type parameters are different:
|
||||||
public final actual class C3<D, E : D?>
|
public final actual class C3<D, E : D?>
|
||||||
|
|
||||||
expect class C3<D, E : D>
|
expect class C3<D, E : D>
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/incompatibleClasses/common.kt:18:16: error: expected class 'C4' has no actual declaration in module
|
compiler/testData/multiplatform/incompatibleClasses/common.kt:18:16: error: expected class 'C4' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because upper bounds of type parameters are different:
|
The following declaration is incompatible because upper bounds of type parameters are different:
|
||||||
public actual typealias C4<F> = C4Impl<F>
|
public actual typealias C4<F> = C4Impl<F>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Output:
|
|||||||
-- JVM --
|
-- JVM --
|
||||||
Exit code: COMPILATION_ERROR
|
Exit code: COMPILATION_ERROR
|
||||||
Output:
|
Output:
|
||||||
compiler/testData/multiplatform/missingOverload/common.kt:7:13: error: expected function 'g' has no actual declaration in module
|
compiler/testData/multiplatform/missingOverload/common.kt:7:13: error: expected function 'g' has no actual declaration in module <main>
|
||||||
The following declaration is incompatible because parameter types are different:
|
The following declaration is incompatible because parameter types are different:
|
||||||
public actual fun g(a: Any): Unit
|
public actual fun g(a: Any): Unit
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ fun useInSignature(a: A) = a.toString()
|
|||||||
compiler/testData/multiplatform/optionalExpectationIncorrectUse/common.kt:9:1: error: this annotation is not applicable to target 'class'
|
compiler/testData/multiplatform/optionalExpectationIncorrectUse/common.kt:9:1: error: this annotation is not applicable to target 'class'
|
||||||
@OptionalExpectation
|
@OptionalExpectation
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/optionalExpectationIncorrectUse/common.kt:10:14: error: expected class 'NotAnAnnotationClass' has no actual declaration in module
|
compiler/testData/multiplatform/optionalExpectationIncorrectUse/common.kt:10:14: error: expected class 'NotAnAnnotationClass' has no actual declaration in module <main>
|
||||||
expect class NotAnAnnotationClass
|
expect class NotAnAnnotationClass
|
||||||
^
|
^
|
||||||
compiler/testData/multiplatform/optionalExpectationIncorrectUse/common.kt:12:1: error: '@OptionalExpectation' can only be used on an expected annotation class
|
compiler/testData/multiplatform/optionalExpectationIncorrectUse/common.kt:12:1: error: '@OptionalExpectation' can only be used on an expected annotation class
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
package sample
|
package sample
|
||||||
|
|
||||||
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom.kt, left.kt")!>A<!> {
|
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom, left")!>A<!> {
|
||||||
fun <!AMBIGUOUS_ACTUALS("Function 'foo'", "bottom.kt, left.kt")!>foo<!>(): Int
|
fun <!AMBIGUOUS_ACTUALS("Function 'foo'", "bottom, left")!>foo<!>(): Int
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
package foo
|
package foo
|
||||||
|
|
||||||
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom.kt, middle.kt")!>A<!>
|
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom, middle")!>A<!>
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
package foo
|
package foo
|
||||||
|
|
||||||
expect class <!AMBIGUOUS_ACTUALS("Class 'ActualInMiddleCompatibleInBottom'", "bottom.kt, middle.kt")!>ActualInMiddleCompatibleInBottom<!>
|
expect class <!AMBIGUOUS_ACTUALS("Class 'ActualInMiddleCompatibleInBottom'", "bottom, middle")!>ActualInMiddleCompatibleInBottom<!>
|
||||||
expect class <!AMBIGUOUS_ACTUALS("Class 'CompatibleInMiddleActualInBottom'", "bottom.kt, middle.kt")!>CompatibleInMiddleActualInBottom<!>
|
expect class <!AMBIGUOUS_ACTUALS("Class 'CompatibleInMiddleActualInBottom'", "bottom, middle")!>CompatibleInMiddleActualInBottom<!>
|
||||||
|
|
||||||
expect class <!AMBIGUOUS_ACTUALS("Class 'CompatibleInMiddleAndBottom'", "bottom.kt, middle.kt")!>CompatibleInMiddleAndBottom<!>
|
expect class <!AMBIGUOUS_ACTUALS("Class 'CompatibleInMiddleAndBottom'", "bottom, middle")!>CompatibleInMiddleAndBottom<!>
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
package foo
|
package foo
|
||||||
|
|
||||||
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom.kt, middle.kt")!>A<!>
|
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom, middle")!>A<!>
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
actual class <!AMBIGUOUS_EXPECTS("Actual class 'A'", "left.kt, right.kt")!>A<!>
|
actual class <!AMBIGUOUS_EXPECTS("Actual class 'A'", "left, right")!>A<!>
|
||||||
Reference in New Issue
Block a user