Don't analyze function body if only parameter analyze is requested

This commit is contained in:
Nikolay Krasko
2016-04-27 16:48:02 +03:00
parent faa2745731
commit dd8b667360
2 changed files with 24 additions and 0 deletions
@@ -243,6 +243,14 @@ class ResolveElementCache(
return elementOfAdditionalResolve return elementOfAdditionalResolve
} }
is KtDeclaration -> {
if (element is KtParameter && !KtPsiUtil.isLocal(element)) {
return null
}
return elementOfAdditionalResolve
}
else -> return elementOfAdditionalResolve else -> return elementOfAdditionalResolve
} }
} }
@@ -323,6 +323,22 @@ class C(param1: String = "", param2: Int = 0) {
) )
} }
fun testNoBodyResolveOnFunctionParameterAnalyze() {
val file = configureWithKotlin(
"""
fun test(a: String) {
unresolved // Check diagnostics is empty even in FULL mode when starting analyzing for parameter
}
""")
val function = file.declarations[0] as KtNamedFunction
val functionParameter = function.valueParameters.first()
val context = functionParameter.analyze(BodyResolveMode.FULL)
assertEmpty(context.diagnostics.all())
}
private fun configureWithKotlin(@Language("kotlin") text: String): KtFile { private fun configureWithKotlin(@Language("kotlin") text: String): KtFile {
return myFixture.configureByText("Test.kt", text.trimIndent()) as KtFile return myFixture.configureByText("Test.kt", text.trimIndent()) as KtFile
} }