[AA] don't treat broken code as function type parameter
inspired by KTIJ-23940
This commit is contained in:
+6
@@ -358,5 +358,11 @@ public class Fe10IdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated extends A
|
|||||||
public void testParameterInlining() throws Exception {
|
public void testParameterInlining() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/valueParameters/parameterInlining.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/valueParameters/parameterInlining.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("parameterNotFunctionalType.kt")
|
||||||
|
public void testParameterNotFunctionalType() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/valueParameters/parameterNotFunctionalType.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -358,5 +358,11 @@ public class FirIdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated extends Ab
|
|||||||
public void testParameterInlining() throws Exception {
|
public void testParameterInlining() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/valueParameters/parameterInlining.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/valueParameters/parameterInlining.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("parameterNotFunctionalType.kt")
|
||||||
|
public void testParameterNotFunctionalType() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/valueParameters/parameterNotFunctionalType.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -30,6 +30,7 @@ abstract class AbstractSymbolByPsiTest : AbstractSymbolTest() {
|
|||||||
is KtDestructuringDeclaration -> false
|
is KtDestructuringDeclaration -> false
|
||||||
is KtPropertyAccessor -> false
|
is KtPropertyAccessor -> false
|
||||||
is KtParameter -> !this.isFunctionTypeParameter && this.parent !is KtParameterList
|
is KtParameter -> !this.isFunctionTypeParameter && this.parent !is KtParameterList
|
||||||
|
is KtNamedFunction -> this.name != null
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -358,5 +358,11 @@ public class FirStandaloneNormalAnalysisSourceModuleSymbolByPsiTestGenerated ext
|
|||||||
public void testParameterInlining() throws Exception {
|
public void testParameterInlining() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/valueParameters/parameterInlining.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/valueParameters/parameterInlining.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("parameterNotFunctionalType.kt")
|
||||||
|
public void testParameterNotFunctionalType() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/valueParameters/parameterNotFunctionalType.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun f(p: (kotlin.Int, ERROR_TYPE(Unresolved type for p2)) -> ERROR(No type specified for unknown element), `<no name provided>`: ERROR(Missed a type for a value parameter <no name provided>))
|
||||||
|
|
||||||
|
fun `<no name provided>`()
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: /f
|
||||||
|
contextReceivers: []
|
||||||
|
contractEffects: []
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: f
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: kotlin/Unit
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: [
|
||||||
|
KtValueParameterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
contextReceivers: []
|
||||||
|
generatedPrimaryConstructorProperty: null
|
||||||
|
hasDefaultValue: false
|
||||||
|
isCrossinline: false
|
||||||
|
isExtension: false
|
||||||
|
isImplicitLambdaParameter: false
|
||||||
|
isNoinline: false
|
||||||
|
isVararg: false
|
||||||
|
name: p
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: kotlin/Function2<kotlin/Int, ERROR_TYPE, ERROR_TYPE>
|
||||||
|
symbolKind: LOCAL
|
||||||
|
typeParameters: []
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
KtValueParameterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
contextReceivers: []
|
||||||
|
generatedPrimaryConstructorProperty: null
|
||||||
|
hasDefaultValue: false
|
||||||
|
isCrossinline: false
|
||||||
|
isExtension: false
|
||||||
|
isImplicitLambdaParameter: false
|
||||||
|
isNoinline: false
|
||||||
|
isVararg: false
|
||||||
|
name: <no name provided>
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: ERROR_TYPE
|
||||||
|
symbolKind: LOCAL
|
||||||
|
typeParameters: []
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
]
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE_K1
|
||||||
|
fun f(p: (Int, p2(1,2)) -> Int) {
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun f(p: (kotlin.Int, ERROR_TYPE(Symbol not found for p2)) -> ERROR(Unwrapped type is null), `<no name provided>`: ERROR(No type for parameter))
|
||||||
|
|
||||||
|
fun `<no name provided>`()
|
||||||
Vendored
+65
@@ -0,0 +1,65 @@
|
|||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: /f
|
||||||
|
contextReceivers: []
|
||||||
|
contractEffects: []
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: f
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: kotlin/Unit
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: [
|
||||||
|
KtValueParameterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
contextReceivers: []
|
||||||
|
generatedPrimaryConstructorProperty: null
|
||||||
|
hasDefaultValue: false
|
||||||
|
isCrossinline: false
|
||||||
|
isExtension: false
|
||||||
|
isImplicitLambdaParameter: false
|
||||||
|
isNoinline: false
|
||||||
|
isVararg: false
|
||||||
|
name: p
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: kotlin/Function2<kotlin/Int, ERROR CLASS: Symbol not found for p2, ERROR CLASS: Unwrapped type is null>
|
||||||
|
symbolKind: LOCAL
|
||||||
|
typeParameters: []
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
KtValueParameterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
contextReceivers: []
|
||||||
|
generatedPrimaryConstructorProperty: null
|
||||||
|
hasDefaultValue: false
|
||||||
|
isCrossinline: false
|
||||||
|
isExtension: false
|
||||||
|
isImplicitLambdaParameter: false
|
||||||
|
isNoinline: false
|
||||||
|
isVararg: false
|
||||||
|
name: <no name provided>
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: ERROR CLASS: No type for parameter
|
||||||
|
symbolKind: LOCAL
|
||||||
|
typeParameters: []
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
]
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
|||||||
import com.intellij.navigation.ItemPresentation;
|
import com.intellij.navigation.ItemPresentation;
|
||||||
import com.intellij.navigation.ItemPresentationProviders;
|
import com.intellij.navigation.ItemPresentationProviders;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
|
import com.intellij.psi.PsiErrorElement;
|
||||||
import com.intellij.psi.search.LocalSearchScope;
|
import com.intellij.psi.search.LocalSearchScope;
|
||||||
import com.intellij.psi.search.SearchScope;
|
import com.intellij.psi.search.SearchScope;
|
||||||
import com.intellij.psi.tree.TokenSet;
|
import com.intellij.psi.tree.TokenSet;
|
||||||
@@ -144,7 +145,7 @@ public class KtParameter extends KtNamedDeclarationStub<KotlinParameterStub> imp
|
|||||||
private <T extends PsiElement> boolean checkParentOfParentType(Class<T> klass) {
|
private <T extends PsiElement> boolean checkParentOfParentType(Class<T> klass) {
|
||||||
// `parent` is supposed to be [KtParameterList]
|
// `parent` is supposed to be [KtParameterList]
|
||||||
PsiElement parent = getParent();
|
PsiElement parent = getParent();
|
||||||
if (parent == null) {
|
if (parent == null || parent.getNextSibling() instanceof PsiErrorElement) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return klass.isInstance(parent.getParent());
|
return klass.isInstance(parent.getParent());
|
||||||
|
|||||||
Reference in New Issue
Block a user