Add origin for generated jvm overloads and tweak equals methods to distinguish them
- KT-7586 Strange navigation issue #KT-7586 Fixed
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import test.kotlin.A;
|
||||
|
||||
import static test.kotlin.KotlinPackage.foo;
|
||||
|
||||
class JvmOverloadsFunctions {
|
||||
public static void main(String[] args) {
|
||||
A a = new A() { };
|
||||
|
||||
foo(a.getClass(), a, true, "Some");
|
||||
foo(a.getClass(), a, true);
|
||||
foo(a.getClass(), a);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package test.kotlin
|
||||
|
||||
trait A
|
||||
|
||||
kotlin.jvm.overloads
|
||||
public fun foo<T : A>(k: Class<T>, a: A, b: Boolean = false, s: String="hello"): List<T> {
|
||||
println("$b $s")
|
||||
return listOf()
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
// WITH_RUNTIME
|
||||
@@ -0,0 +1,7 @@
|
||||
public class AutoGeneratedOverloads {
|
||||
public static void foo() {
|
||||
k.KPackage.<caret>withJvmOverloads(0);
|
||||
}
|
||||
}
|
||||
|
||||
// REF: (in k).withJvmOverloads(Int,Boolean,String)
|
||||
@@ -47,4 +47,9 @@ trait TraitWithImpl {
|
||||
fun foo() = 1
|
||||
}
|
||||
|
||||
public class TraitWithDelegatedWithImpl(f: TraitWithImpl): TraitWithImpl by f
|
||||
public class TraitWithDelegatedWithImpl(f: TraitWithImpl) : TraitWithImpl by f
|
||||
|
||||
kotlin.jvm.overloads
|
||||
public fun withJvmOverloads(i: Int, b: Boolean = false, s: String="hello") {}
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.checkers;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.dataFlow.DataFlowInspection;
|
||||
import com.intellij.codeInspection.nullable.NullableStuffInspection;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -26,7 +27,9 @@ import com.siyeh.ig.bugs.StaticCallOnSubclassInspection;
|
||||
import com.siyeh.ig.bugs.StaticFieldReferenceOnSubclassInspection;
|
||||
import kotlin.Function1;
|
||||
import kotlin.KotlinPackage;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.KotlinDaemonAnalyzerTestCase;
|
||||
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil;
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
|
||||
import org.jetbrains.kotlin.utils.UtilsPackage;
|
||||
@@ -55,30 +58,56 @@ public class KotlinAndJavaCheckerTest extends KotlinDaemonAnalyzerTestCase {
|
||||
throw new IllegalArgumentException("Can't find inspection tool with identifier: " + toolString);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
@Nullable
|
||||
protected String getConfigFileText() {
|
||||
File configureFile = new File(getTestDataPath(), getTestName(false) + ".txt");
|
||||
|
||||
if (!configureFile.exists()) return DEFAULT_TOOLS;
|
||||
if (!configureFile.exists()) return null;
|
||||
|
||||
try {
|
||||
String configureText = FileUtil.loadFile(configureFile, true);
|
||||
|
||||
InTextDirectivesUtils.assertHasUnknownPrefixes(configureText, KotlinPackage.listOf("TOOL:"));
|
||||
List<String> toolsStrings = InTextDirectivesUtils.findListWithPrefixes(configureText, "TOOL:");
|
||||
|
||||
return ArrayUtil.toObjectArray(KotlinPackage.map(toolsStrings, new Function1<String, LocalInspectionTool>() {
|
||||
@Override
|
||||
public LocalInspectionTool invoke(String toolString) {
|
||||
return mapStringToTool(toolString);
|
||||
}
|
||||
}), LocalInspectionTool.class);
|
||||
return FileUtil.loadFile(configureFile, true);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
String configFileText = getConfigFileText();
|
||||
if (configFileText == null) return DEFAULT_TOOLS;
|
||||
|
||||
List<String> toolsStrings = InTextDirectivesUtils.findListWithPrefixes(configFileText, "TOOL:");
|
||||
|
||||
return ArrayUtil.toObjectArray(KotlinPackage.map(toolsStrings, new Function1<String, LocalInspectionTool>() {
|
||||
@Override
|
||||
public LocalInspectionTool invoke(String toolString) {
|
||||
return mapStringToTool(toolString);
|
||||
}
|
||||
}), LocalInspectionTool.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Module createMainModule() throws IOException {
|
||||
Module module = super.createMainModule();
|
||||
|
||||
String configFileText = getConfigFileText();
|
||||
if (configFileText != null && InTextDirectivesUtils.isDirectiveDefined(configFileText, "// WITH_RUNTIME")) {
|
||||
ConfigLibraryUtil.configureKotlinRuntime(module);
|
||||
}
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectJdk() {
|
||||
return PluginTestCaseBase.mockJdk();
|
||||
@@ -121,6 +150,10 @@ public class KotlinAndJavaCheckerTest extends KotlinDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testJvmOverloadsFunctions() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEnumAutoGeneratedMethods() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,12 @@ public class ReferenceResolveInJavaTestGenerated extends AbstractReferenceResolv
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/resolve/referenceInJava"), Pattern.compile("^(.+)\\.java$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("AutoGeneratedOverloads.java")
|
||||
public void testAutoGeneratedOverloads() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/referenceInJava/AutoGeneratedOverloads.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Class.java")
|
||||
public void testClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/referenceInJava/Class.java");
|
||||
|
||||
Reference in New Issue
Block a user