Fix parent and containingFile for throws-reference list
Otherwise, exception is thrown during type inference because default implementations effectively return null ^KT-29287 Fixed
This commit is contained in:
@@ -56,7 +56,11 @@ internal abstract class KtUltraLightMethod(
|
||||
abstract override fun buildTypeParameterList(): PsiTypeParameterList
|
||||
|
||||
private val _throwsList: PsiReferenceList by lazyPub {
|
||||
val list = KotlinLightReferenceListBuilder(manager, language, PsiReferenceList.Role.THROWS_LIST)
|
||||
val list =
|
||||
object : KotlinLightReferenceListBuilder(manager, language, PsiReferenceList.Role.THROWS_LIST) {
|
||||
override fun getParent() = this@KtUltraLightMethod
|
||||
override fun getContainingFile() = this@KtUltraLightMethod.containingFile
|
||||
}
|
||||
computeDescriptor()?.let {
|
||||
for (ex in FunctionCodegen.getThrownExceptions(it)) {
|
||||
val psiClassType = ex.defaultType.asPsiType(support, TypeMappingMode.DEFAULT, list) as? PsiClassType ?: continue
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
import foo.A;
|
||||
|
||||
public class ThrowsOnGenericMethod {
|
||||
public static void main(String[] args) {
|
||||
new A().<error descr="Unhandled exception: java.io.IOException">foo</error>("");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package foo;
|
||||
import java.io.IOException
|
||||
|
||||
class A {
|
||||
@Throws(IOException::class)
|
||||
fun <E> foo(y: E) {}
|
||||
}
|
||||
|
||||
// ALLOW_AST_ACCESS
|
||||
+1
@@ -0,0 +1 @@
|
||||
// WITH_RUNTIME
|
||||
Generated
+5
@@ -139,6 +139,11 @@ public class JavaAgainstKotlinBinariesCheckerTestGenerated extends AbstractJavaA
|
||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ReturnInnerClasses.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ThrowsOnGenericMethod.kt")
|
||||
public void testThrowsOnGenericMethod() throws Exception {
|
||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ThrowsOnGenericMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("TopLevelFunctionInDataFlowInspection.kt")
|
||||
public void testTopLevelFunctionInDataFlowInspection() throws Exception {
|
||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/TopLevelFunctionInDataFlowInspection.kt");
|
||||
|
||||
+5
@@ -141,6 +141,11 @@ public class JavaAgainstKotlinSourceCheckerTestGenerated extends AbstractJavaAga
|
||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ReturnInnerClasses.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ThrowsOnGenericMethod.kt")
|
||||
public void testThrowsOnGenericMethod() throws Exception {
|
||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ThrowsOnGenericMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("TopLevelFunctionInDataFlowInspection.kt")
|
||||
public void testTopLevelFunctionInDataFlowInspection() throws Exception {
|
||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/TopLevelFunctionInDataFlowInspection.kt");
|
||||
|
||||
+5
@@ -141,6 +141,11 @@ public class JavaAgainstKotlinSourceCheckerWithUltraLightTestGenerated extends A
|
||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ReturnInnerClasses.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ThrowsOnGenericMethod.kt")
|
||||
public void testThrowsOnGenericMethod() throws Exception {
|
||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/ThrowsOnGenericMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("TopLevelFunctionInDataFlowInspection.kt")
|
||||
public void testTopLevelFunctionInDataFlowInspection() throws Exception {
|
||||
runTest("idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/TopLevelFunctionInDataFlowInspection.kt");
|
||||
|
||||
Reference in New Issue
Block a user