Make "reflection not found" a warning, provide a quick fix

Reporting the warning on each "::", as ReflectionNotFoundInspection did, is not
correct anymore, because for example name/get/set on properties works perfectly
without kotlin-reflect.jar in the classpath. So instead we report the warning
on calls to functions from reflection interfaces. This is not perfect either
because it's wrong in projects with custom implementations of reflection
interfaces, but this case is so rare that the users can suppress the warning
there anyway

 #KT-7176 Fixed
This commit is contained in:
Alexander Udalov
2015-07-02 17:39:16 +03:00
parent 4f1247f03f
commit 636b63a8c5
24 changed files with 240 additions and 261 deletions
@@ -10435,6 +10435,21 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
}
}
@TestMetadata("compiler/testData/diagnostics/tests/reflection")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Reflection extends AbstractJetDiagnosticsTest {
public void testAllFilesPresentInReflection() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/reflection"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("noReflectionInClassPath.kt")
public void testNoReflectionInClassPath() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/reflection/noReflectionInClassPath.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/diagnostics/tests/regressions")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -97,12 +97,6 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes
doJvmTest(fileName);
}
@TestMetadata("noReflectionInClasspath.args")
public void testNoReflectionInClasspath() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/noReflectionInClasspath.args");
doJvmTest(fileName);
}
@TestMetadata("nonExistingClassPathAndAnnotationsPath.args")
public void testNonExistingClassPathAndAnnotationsPath() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/nonExistingClassPathAndAnnotationsPath.args");
@@ -21,6 +21,7 @@ import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
@@ -126,8 +127,10 @@ public class JetExpectedResolveDataUtil {
Project project,
JetType... parameterTypes
) {
ModuleDescriptor emptyModule = JetTestUtils.createEmptyModule();
ModuleDescriptorImpl emptyModule = JetTestUtils.createEmptyModule();
ContainerForTests container = DiPackage.createContainerForTests(project, emptyModule);
emptyModule.setDependencies(emptyModule);
emptyModule.initialize(PackageFragmentProvider.Empty.INSTANCE$);
ExpressionTypingContext context = ExpressionTypingContext.newContext(
container.getAdditionalCheckerProvider(), new BindingTraceContext(), classDescriptor.getDefaultType().getMemberScope(),
@@ -23,8 +23,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider;
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor;
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor;
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
@@ -73,7 +75,10 @@ public class JetTypeCheckerTest extends JetLiteFixture {
builtIns = KotlinBuiltIns.getInstance();
ContainerForTests container = DiPackage.createContainerForTests(getProject(), JetTestUtils.createEmptyModule());
ModuleDescriptorImpl module = JetTestUtils.createEmptyModule();
ContainerForTests container = DiPackage.createContainerForTests(getProject(), module);
module.setDependencies(Collections.singletonList(module));
module.initialize(PackageFragmentProvider.Empty.INSTANCE$);
typeResolver = container.getTypeResolver();
expressionTypingServices = container.getExpressionTypingServices();