Fix script resolver failing

Specifically the case where some lib is in project dependencies and script dependencies at the same time

 #EA-105435 at least partially fixed
 #KT-19458 Fixed
 #KT-19474 Fixed
This commit is contained in:
Pavel V. Talanov
2017-09-06 21:31:29 +03:00
parent e9ce5bbb37
commit ebd3ac6dc8
4 changed files with 21 additions and 1 deletions
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.lazy.AbsentDescriptorHandler
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
internal class ResolutionFacadeImpl(
private val projectFacade: ProjectResolutionFacade,
@@ -84,7 +85,7 @@ internal class ResolutionFacadeImpl(
}
override fun <T : Any> tryGetFrontendService(element: PsiElement, serviceClass: Class<T>): T? {
return projectFacade.resolverForModuleInfo(element.getModuleInfo()).componentProvider.tryGetService(serviceClass)
return element.getModuleInfos().firstNotNullResult { projectFacade.tryGetResolverForModuleInfo(it)?.componentProvider?.tryGetService(serviceClass) }
}
fun <T : Any> getFrontendService(ideaModuleInfo: IdeaModuleInfo, serviceClass: Class<T>): T {
@@ -0,0 +1,7 @@
package test;
public class Utils {
public static void foo(String str) {
}
}
@@ -0,0 +1,6 @@
fun f(g: <error>Utils</error>) {
}
// DEPENDENCIES: classpath:lib-classes
// CONFLICTING_MODULE
@@ -54,6 +54,12 @@ public class ScriptConfigurationHighlightingTestGenerated extends AbstractScript
doTest(fileName);
}
@TestMetadata("conflictingModule")
public void testConflictingModule() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/script/definition/highlighting/conflictingModule/");
doTest(fileName);
}
@TestMetadata("customBaseClass")
public void testCustomBaseClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/script/definition/highlighting/customBaseClass/");