diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java index b293ec7dade..7d7003cda32 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -782,6 +782,11 @@ public class KtPsiUtil { declaration = PsiTreeUtil.getParentOfType(declaration, KtNamedDeclaration.class); } else if (declaration instanceof KtParameter) { + KtFunctionType functionType = PsiTreeUtil.getParentOfType(declaration, KtFunctionType.class); + if (functionType != null) { + return functionType; + } + PsiElement parent = declaration.getParent(); // val/var parameter of primary constructor should be considered as local according to containing class diff --git a/idea/testData/checker/regression/FunctionTypes.kt b/idea/testData/checker/regression/FunctionTypes.kt new file mode 100644 index 00000000000..79dfe2ba111 --- /dev/null +++ b/idea/testData/checker/regression/FunctionTypes.kt @@ -0,0 +1,24 @@ +fun intercept(block: (key: K, next: (K) -> V, K) -> V) { +} + +fun String> f() { + +} + +fun g() where T: (unit: Unit) -> Unit { + +} + +class C String>() { + +} + +class CC() where T : (Int) -> String { + +} + +interface I + +val c = object : I<(String) -> String> {} + +class CCC() : I<(Int) -> Int> \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java b/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java index 2c34070527b..e884a7fee9b 100644 --- a/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java @@ -496,6 +496,12 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest { doTest(fileName); } + @TestMetadata("FunctionTypes.kt") + public void testFunctionTypes() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/regression/FunctionTypes.kt"); + doTest(fileName); + } + @TestMetadata("InterfaceDeclarationAsExpression.kt") public void testInterfaceDeclarationAsExpression() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/regression/InterfaceDeclarationAsExpression.kt");