Fix KT-10764 IDEA doesn't show overload conflict between constructor and function...
When checking for overloads in package, consider functions and top-level class constructors as possibly conflicting between each other. NB OverloadUtil uses containing package scope from module descriptor.
Change diagnostic message for CONFLICTING_OVERLOAD: it's misleading in case of fun vs constructor conflict.
Add custom multifile test for diagnostics in IDE (probably not the best; should preprocess file content if it's required to check highlighting in multiple files, not only in the first file).
Add test for KT-10765 Incremental compilation misses overload conflict between constructor and function ...
Original commit: 65f754ffca
This commit is contained in:
+6
@@ -335,6 +335,12 @@ public class ExperimentalIncrementalJpsTestGenerated extends AbstractExperimenta
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("funVsConstructorOverloadConflict")
|
||||
public void testFunVsConstructorOverloadConflict() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/funVsConstructorOverloadConflict/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("functionBecameInline")
|
||||
public void testFunctionBecameInline() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/functionBecameInline/");
|
||||
|
||||
@@ -335,6 +335,12 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("funVsConstructorOverloadConflict")
|
||||
public void testFunVsConstructorOverloadConflict() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/funVsConstructorOverloadConflict/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("functionBecameInline")
|
||||
public void testFunctionBecameInline() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/functionBecameInline/");
|
||||
|
||||
+11
-18
@@ -4,9 +4,19 @@ End of files
|
||||
Compiling files:
|
||||
src/A.kt
|
||||
End of files
|
||||
COMPILATION FAILED
|
||||
'public constructor A(x: kotlin.String)' conflicts with another declaration: public constructor A(x: kotlin.String)
|
||||
|
||||
|
||||
Cleaning output files:
|
||||
out/production/module/AConstructorFunctionKt.class
|
||||
out/production/module/META-INF/module.kotlin_module
|
||||
End of files
|
||||
Compiling files:
|
||||
src/A.kt
|
||||
End of files
|
||||
Cleaning output files:
|
||||
out/production/module/AChild.class
|
||||
out/production/module/AConstructorFunctionKt.class
|
||||
out/production/module/CreateAFromIntKt.class
|
||||
out/production/module/CreateAFromStringKt.class
|
||||
out/production/module/META-INF/module.kotlin_module
|
||||
@@ -14,23 +24,6 @@ out/production/module/UseAKt.class
|
||||
End of files
|
||||
Compiling files:
|
||||
src/AChild.kt
|
||||
src/AConstructorFunction.kt
|
||||
src/createAFromInt.kt
|
||||
src/createAFromString.kt
|
||||
src/useA.kt
|
||||
End of files
|
||||
COMPILATION FAILED
|
||||
Overload resolution ambiguity:
|
||||
public constructor A(x: kotlin.String) defined in A
|
||||
public fun A(x: kotlin.String): A defined in root package
|
||||
|
||||
|
||||
Cleaning output files:
|
||||
out/production/module/A.class
|
||||
End of files
|
||||
Compiling files:
|
||||
src/A.kt
|
||||
src/AChild.kt
|
||||
src/createAFromInt.kt
|
||||
src/createAFromString.kt
|
||||
src/useA.kt
|
||||
|
||||
@@ -6,4 +6,4 @@ Compiling files:
|
||||
src/fun2.kt
|
||||
End of files
|
||||
COMPILATION FAILED
|
||||
'public fun function(): kotlin.Unit' is already defined in test
|
||||
'public fun function(): kotlin.Unit' conflicts with another declaration: public fun function(): kotlin.Unit
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
Cleaning output files:
|
||||
out/production/module/META-INF/module.kotlin_module
|
||||
out/production/module/test/Fun2Kt.class
|
||||
End of files
|
||||
Compiling files:
|
||||
src/fun2.kt
|
||||
End of files
|
||||
COMPILATION FAILED
|
||||
'public constructor function()' conflicts with another declaration: public constructor function()
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
fun function() {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package test
|
||||
|
||||
val x = 1
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
val x = 1
|
||||
|
||||
class function
|
||||
Reference in New Issue
Block a user