diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java index 54e8d2c7b61..ed4fb97f45b 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java @@ -1704,6 +1704,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/callableReference/memberExtensionsImportedFromObjectsUnsupported.kt"); } + @TestMetadata("noExceptionOnRedCodeWithArrayLikeCall.kt") + public void testNoExceptionOnRedCodeWithArrayLikeCall() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt"); + } + @TestMetadata("packageInLhs.kt") public void testPackageInLhs() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/packageInLhs.kt"); diff --git a/compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt b/compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt new file mode 100644 index 00000000000..3c1e261a52b --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt @@ -0,0 +1,13 @@ +// !LANGUAGE: +NewInference + +class DTO { + val q: Int = 0 + operator fun get(prop: KProperty1<*, Int>): Int = 0 +} + +fun foo(intDTO: DTO?, p: KProperty1<*, Int>) { + if (intDTO != null) { + intDTO[DTO::q] + intDTO.q + } +} diff --git a/compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.txt b/compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.txt new file mode 100644 index 00000000000..73859c15399 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.txt @@ -0,0 +1,12 @@ +package + +public fun foo(/*0*/ intDTO: DTO?, /*1*/ p: [ERROR : KProperty1<*, Int>]): kotlin.Unit + +public final class DTO { + public constructor DTO() + public final val q: kotlin.Int = 0 + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final operator fun get(/*0*/ prop: [ERROR : KProperty1<*, Int>]): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 6aceeed0fcd..7c271d2a1ec 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -1711,6 +1711,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/callableReference/memberExtensionsImportedFromObjectsUnsupported.kt"); } + @TestMetadata("noExceptionOnRedCodeWithArrayLikeCall.kt") + public void testNoExceptionOnRedCodeWithArrayLikeCall() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt"); + } + @TestMetadata("packageInLhs.kt") public void testPackageInLhs() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/packageInLhs.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 85487291425..fcf3e3b6560 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -1706,6 +1706,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/callableReference/memberExtensionsImportedFromObjectsUnsupported.kt"); } + @TestMetadata("noExceptionOnRedCodeWithArrayLikeCall.kt") + public void testNoExceptionOnRedCodeWithArrayLikeCall() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt"); + } + @TestMetadata("packageInLhs.kt") public void testPackageInLhs() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/packageInLhs.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt index 082b5656eb5..bbef27bb478 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt @@ -129,7 +129,10 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not fun isNumberedTypeWithOneOrMoreNumber(type: KotlinType): Boolean { val descriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return false - if (DescriptorUtils.getFqName(descriptor).parent().toSafe() != KOTLIN_REFLECT_FQ_NAME) return false + val fqName = DescriptorUtils.getFqName(descriptor) + if (fqName.isRoot) return false + + if (fqName.parent().toSafe() != KOTLIN_REFLECT_FQ_NAME) return false val shortName = descriptor.name.asString() for (prefix in PREFIXES) {