Parameters of function types are always considered local

This commit is contained in:
Pavel V. Talanov
2016-03-01 19:53:34 +03:00
parent e121ef0fdc
commit 363d545bd5
3 changed files with 36 additions and 1 deletions
@@ -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
+24
View File
@@ -0,0 +1,24 @@
fun <K, V> intercept(<warning>block</warning>: (key: K, next: (K) -> V, K) -> V) {
}
fun <T : (Int) -> String> f() {
}
fun <T> g() where T: (unit: Unit) -> Unit {
}
class C<T : (Int) -> String>() {
}
class CC<T>() where T : (Int) -> String {
}
interface I<T>
val c = object : I<(String) -> String> {}
class CCC() : I<(Int) -> Int>
@@ -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");