Fix problem of getting reference and parameter in functional literal inside other parameter (EA-48757)

This commit is contained in:
Nikolay Krasko
2013-08-15 17:39:15 +04:00
parent e984ce2aa8
commit eaf0c2cb84
3 changed files with 16 additions and 0 deletions
@@ -102,6 +102,12 @@ public class ResolveElementCache {
return additionalResolveCache.getValue().fun(elementOfAdditionalResolve);
}
JetParameter parameter = PsiTreeUtil.getTopmostParentOfType(jetElement, JetParameter.class);
if (parameter != null) {
// Parameters for function literal could be met inside other parameters. We can't make resolveToDescriptors for internal elements.
jetElement = parameter;
}
JetDeclaration declaration = PsiTreeUtil.getParentOfType(jetElement, JetDeclaration.class, false);
if (declaration != null) {
// Activate descriptor resolution
@@ -0,0 +1,5 @@
package testing
class TestClass(val test: (<caret>String) -> Int)
// REF: (jet).String
@@ -166,4 +166,9 @@ public class ReferenceResolveTestGenerated extends AbstractResolveBaseTest {
doTest("idea/testData/resolve/references/SeveralOverrides.kt");
}
@TestMetadata("TypeParameterInFunctionLiteral.kt")
public void testTypeParameterInFunctionLiteral() throws Exception {
doTest("idea/testData/resolve/references/TypeParameterInFunctionLiteral.kt");
}
}