diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 4902823fdec..d5fae3d0951 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -218,7 +218,6 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { parameter("containingClassName") } - val OVERRIDING_FINAL_MEMBER by error(PositioningStrategy.OVERRIDE_MODIFIER) { parameter>("overriddenDeclaration") parameter("containingClassName") @@ -240,7 +239,6 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { parameter("overridingDeclaration") parameter("overriddenDeclaration") } - } group("Redeclarations") { @@ -282,13 +280,11 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { parameter("function") } - val FUNCTION_DECLARATION_WITH_NO_NAME by error(PositioningStrategy.DECLARATION_SIGNATURE) // TODO: val ANONYMOUS_FUNCTION_WITH_NAME by error1(SourceElementPositioningStrategies.DECLARATION_NAME) val ANONYMOUS_FUNCTION_PARAMETER_WITH_DEFAULT_VALUE by error(PositioningStrategy.PARAMETER_DEFAULT_VALUE) val USELESS_VARARG_ON_PARAMETER by warning() - } group("Properties & accessors") { @@ -324,7 +320,6 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val EXPECTED_DELEGATED_PROPERTY by error() } - group("Destructuring declaration") { val INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION by error() val COMPONENT_FUNCTION_MISSING by error { @@ -340,7 +335,6 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { parameter("componentFunctionName") } - // TODO: val COMPONENT_FUNCTION_ON_NULLABLE by ... // TODO: val COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH by ... } @@ -363,7 +357,9 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val UNSAFE_CALL by error(PositioningStrategy.DOT_BY_SELECTOR) { parameter("receiverType") } - // TODO: val UNSAFE_IMPLICIT_INVOKE_CALL by error1() + val UNSAFE_IMPLICIT_INVOKE_CALL by error() { + parameter("receiverType") + } // TODO: val UNSAFE_INFIX_CALL by ... // TODO: val UNSAFE_OPERATOR_CALL by ... // TODO: val UNEXPECTED_SAFE_CALL by ... diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index c0c1fdcb848..58f0043bd53 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -230,6 +230,7 @@ object FirErrors { // Nullability val UNSAFE_CALL by error1(SourceElementPositioningStrategies.DOT_BY_SELECTOR) + val UNSAFE_IMPLICIT_INVOKE_CALL by error1() // When expressions val NO_ELSE_IN_WHEN by error1>(SourceElementPositioningStrategies.WHEN_EXPRESSION) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt index 5dc5e0205eb..a4e2600f6f4 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt @@ -101,7 +101,7 @@ object FirDestructuringDeclarationChecker : FirPropertyChecker() { reporter.report( FirErrors.COMPONENT_FUNCTION_ON_NULLABLE.on( originalDestructuringDeclarationOrInitializerSource, - (diagnostic.candidateSymbol.fir as FirSimpleFunction).name + (diagnostic.candidate.symbol.fir as FirSimpleFunction).name ), context ) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index d990001c853..e8f15e5f7dc 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -157,6 +157,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UNINITIALIZED_VAR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UNRESOLVED_LABEL import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UNRESOLVED_REFERENCE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UNSAFE_CALL +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UNSAFE_IMPLICIT_INVOKE_CALL import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UNUSED_VARIABLE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.UPPER_BOUND_VIOLATED import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.USELESS_VARARG_ON_PARAMETER @@ -506,11 +507,11 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { "Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type {0}", RENDER_TYPE ) - //map.put( - // UNSAFE_IMPLICIT_INVOKE_CALL, - // "Reference has a nullable type ''{0}'', use explicit \"?.invoke\" to make a function-like call instead.", - // RENDER_TYPE - //) + map.put( + UNSAFE_IMPLICIT_INVOKE_CALL, + "Reference has a nullable type ''{0}'', use explicit \"?.invoke\" to make a function-like call instead.", + RENDER_TYPE + ) // When expressions map.put(NO_ELSE_IN_WHEN, "''when'' expression must be exhaustive, add necessary {0}", WHEN_MISSING_CASES) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt index cf172a497b5..52d7689207c 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt @@ -58,20 +58,19 @@ private fun mapInapplicableCandidateError( source: FirSourceElement, ): FirDiagnostic<*> { // TODO: Need to distinguish SMARTCAST_IMPOSSIBLE - // TODO: handle other UNSAFE_* variants: invoke, infix, operator - val rootCause = diagnostic.diagnostics.find { it.applicability == diagnostic.applicability } + // TODO: handle other UNSAFE_* variants: infix, operator + val rootCause = diagnostic.candidate.diagnostics.find { it.applicability == diagnostic.applicability } if (rootCause != null && rootCause is InapplicableWrongReceiver && rootCause.actualType?.isNullable == true && - (rootCause.expectedType == null || !rootCause.expectedType!!.isMarkedNullable) + (rootCause.expectedType == null || rootCause.expectedType!!.isEffectivelyNotNull()) ) { - val expectedType = rootCause.expectedType - - if (expectedType == null || expectedType.isEffectivelyNotNull()) { - return FirErrors.UNSAFE_CALL.on(source, rootCause.actualType!!) + if (diagnostic.candidate.callInfo.isImplicitInvoke) { + return FirErrors.UNSAFE_IMPLICIT_INVOKE_CALL.on(source, rootCause.actualType!!) } + return FirErrors.UNSAFE_CALL.on(source, rootCause.actualType!!) } - return FirErrors.INAPPLICABLE_CANDIDATE.on(source, diagnostic.candidateSymbol) + return FirErrors.INAPPLICABLE_CANDIDATE.on(source, diagnostic.candidate.symbol) } private fun ConeSimpleDiagnostic.getFactory(): FirDiagnosticFactory0 { diff --git a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt index afaaf000399..a5eb04a7cdd 100644 --- a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt +++ b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt @@ -1231,9 +1231,9 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver private fun FlowContent.generate(diagnostic: ConeDiagnostic) { when (diagnostic) { is ConeInapplicableCandidateError -> { - describeVerbose(diagnostic.candidateSymbol) + describeVerbose(diagnostic.candidate.symbol) br - diagnostic.errors.forEach { callDiagnostic -> + diagnostic.candidate.system.errors.forEach { callDiagnostic -> when (callDiagnostic) { is NewConstraintError -> { ident() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirInvokeResolveTowerExtension.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirInvokeResolveTowerExtension.kt index fc0138efa64..a06f03705ca 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirInvokeResolveTowerExtension.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirInvokeResolveTowerExtension.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.fir.resolve.calls.tower -import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.expressions.builder.FirQualifiedAccessExpressionBuilder @@ -156,7 +155,9 @@ internal class FirInvokeResolveTowerExtension( val invokeFunctionInfo = info.copy( - explicitReceiver = invokeReceiverExpression, name = OperatorNameConventions.INVOKE, + explicitReceiver = invokeReceiverExpression, + name = OperatorNameConventions.INVOKE, + isImplicitInvoke = true, candidateForCommonInvokeReceiver = invokeReceiverCandidate.takeUnless { invokeBuiltinExtensionMode } ).let { when { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt index 8555107a894..34cb331bcf6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt @@ -38,20 +38,11 @@ class ConeHiddenCandidateError( override val reason: String get() = "HIDDEN: ${describeSymbol(candidateSymbol)} is invisible" } -class ConeInapplicableCandidateError private constructor( +class ConeInapplicableCandidateError( val applicability: CandidateApplicability, - val candidateSymbol: AbstractFirBasedSymbol<*>, - val diagnostics: List, - val errors: List + val candidate: Candidate, ) : ConeDiagnostic() { - constructor(applicability: CandidateApplicability, candidate: Candidate) : this( - applicability, - candidate.symbol, - candidate.diagnostics, - candidate.system.errors - ) - - override val reason: String get() = "Inapplicable($applicability): ${describeSymbol(candidateSymbol)}" + override val reason: String get() = "Inapplicable($applicability): ${describeSymbol(candidate.symbol)}" } class ConeAmbiguityError(val name: Name, val applicability: CandidateApplicability, val candidates: Collection>) : ConeDiagnostic() { diff --git a/compiler/testData/diagnostics/tests/extensions/kt1875.fir.kt b/compiler/testData/diagnostics/tests/extensions/kt1875.fir.kt index 30a0fe540d1..c1b2b66183d 100644 --- a/compiler/testData/diagnostics/tests/extensions/kt1875.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/kt1875.fir.kt @@ -9,13 +9,13 @@ interface T { } fun test(t: T) { - t.f(1) //unsafe call error + t.f(1) //unsafe call error t.f?.invoke(1) } fun test1(t: T?) { t.f(1) // todo resolve f as value and report UNSAFE_CALL - t?.f(1) + t?.f(1) t.f?.invoke(1) t?.f?.invoke(1) } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.fir.kt deleted file mode 100644 index 8189379f712..00000000000 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.fir.kt +++ /dev/null @@ -1,23 +0,0 @@ -// FILE: J.java - -import org.jetbrains.annotations.*; - -public class J { - public interface Invoke { - void invoke(); - } - - @NotNull - public static Invoke staticNN; - @Nullable - public static Invoke staticN; - public static Invoke staticJ; -} - -// FILE: k.kt - -fun test() { - J.staticNN() - J.staticN() - J.staticJ() -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt index a1c251fae35..d8d9347ddf9 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: J.java import org.jetbrains.annotations.*; diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/unsafeCallWithInvoke.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/unsafeCallWithInvoke.fir.kt index dddbda1ff30..27539cd2175 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/unsafeCallWithInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/unsafeCallWithInvoke.fir.kt @@ -4,7 +4,7 @@ operator fun String.invoke(i: Int) {} fun foo(s: String?) { - s(1) + s(1) - (s ?: null)(1) + (s ?: null)(1) } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt index a339133b60c..41aeacd7829 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt @@ -7,8 +7,8 @@ fun test(a: A) { (a.x)("") } "".(a.x)() - a.x("") - (a.x)("") + a.x("") + (a.x)("") with("") { a.x() diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/kt30695_2.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/kt30695_2.fir.kt index ee5b1fb0b16..1bdeabc1273 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/kt30695_2.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/kt30695_2.fir.kt @@ -14,7 +14,7 @@ class MemberInvokeOwner { class Cls { fun testImplicitReceiver() { - nullableExtensionProperty() + nullableExtensionProperty() } } @@ -30,7 +30,7 @@ fun testNullableReceiver(nullable: Cls?) { } fun testNotNullableReceiver(notNullable: Cls) { - notNullable.nullableExtensionProperty() + notNullable.nullableExtensionProperty() notNullable?.extensionProperty() } @@ -38,6 +38,6 @@ fun testFlexibleReceiver() { val flexible = JavaClass.createFlexible() flexible.extensionProperty() flexible?.extensionProperty() - flexible.nullableExtensionProperty() - flexible?.nullableExtensionProperty() + flexible.nullableExtensionProperty() + flexible?.nullableExtensionProperty() } diff --git a/compiler/testData/diagnostics/tests/safeCall.fir.kt b/compiler/testData/diagnostics/tests/safeCall.fir.kt index 2cdf67aa545..6e02bc3303b 100644 --- a/compiler/testData/diagnostics/tests/safeCall.fir.kt +++ b/compiler/testData/diagnostics/tests/safeCall.fir.kt @@ -1,7 +1,7 @@ // !WITH_NEW_INFERENCE fun f(s: String, action: (String.() -> Unit)?) { - s.foo().bar().action() + s.foo().bar().action() } fun String.foo() = "" @@ -12,4 +12,4 @@ fun String.bar() = "" val functions: Map Any> = TODO() -fun run(name: String) = functions[name]() \ No newline at end of file +fun run(name: String) = functions[name]() \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt index 280bc9152a5..51c1b9ece1b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt @@ -361,23 +361,23 @@ fun case_21() { // TESTCASE NUMBER: 22 fun case_22(a: (() -> Unit)?) { if (a != null !is Boolean) { - a() - a().equals(null) - a().propT - a().propAny - a().propNullableT - a().propNullableAny - a().funT() - a().funAny() - a().funNullableT() - a().funNullableAny() + a() + a().equals(null) + a().propT + a().propAny + a().propNullableT + a().propNullableAny + a().funT() + a().funAny() + a().funNullableT() + a().funNullableAny() } } // TESTCASE NUMBER: 23 fun case_23(a: ((Float) -> Int?)?, b: Float?) { if (a != null !is Boolean && b !== null is Boolean) { - val x = a(b) + val x = a(b) if (x != null) { x x.equals(null) @@ -396,8 +396,8 @@ fun case_23(a: ((Float) -> Int?)?, b: Float?) { // TESTCASE NUMBER: 24 fun case_24(a: ((() -> Unit) -> Unit)?, b: (() -> Unit)?) = if (a !== null is Boolean && b !== null !is Boolean) { - a(?")!>b) - a(b) + a(?")!>b) + a(b) ?")!>b.equals(null) ?")!>b.propT ?")!>b.propAny @@ -440,7 +440,7 @@ fun case_25(b: Boolean) { // TESTCASE NUMBER: 26 fun case_26(a: ((Float) -> Int?)?, b: Float?) { if (a != null == true == false && b != null == true == false) { - val x = a(b) + val x = a(b) if (x != null == true === false) { x x.equals(null) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/2.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/2.fir.kt index fc921ac860d..5dd3f3ab3e1 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/2.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/2.fir.kt @@ -67,7 +67,7 @@ fun case_3(b: Boolean) { val y = if (b) x else null if (false || false || false || false || y !== null) { - val z = ?")!>y() + val z = ?")!>y() ?>?")!>y.equals(null) ?>?")!>y.propT ?>?")!>y.propAny @@ -87,7 +87,7 @@ fun case_3(b: Boolean) { // TESTCASE NUMBER: 4 fun case_4(a: ((Float) -> Int?)?, b: Float?) { if (a != null == true && b != null == true || false || false || false || false || false || false || false || false || false) { - val x = a(b) + val x = a(b) ?")!>a.equals(null) ?")!>a.propT ?")!>a.propAny @@ -274,7 +274,7 @@ fun case_11(b: Boolean) { val y = if (b) x else null if (y === null && true) else { - val z = ?")!>y() + val z = ?")!>y() ?>?")!>y.equals(null) ?>?")!>y.propT ?>?")!>y.propAny @@ -298,7 +298,7 @@ fun case_12(a: ((Float) -> Int?)?, b: Float?, c: Boolean?) { if (true && a == null == true || b == null == true) { } else { - val x = a(b) + val x = a(b) ?")!>a.equals(null) ?")!>a.propT ?")!>a.propAny diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt index 7a2c794098a..df90a41a8e8 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt @@ -422,7 +422,7 @@ fun case_21() { // TESTCASE NUMBER: 22 fun case_22(a: (() -> Unit)?) { if (a != implicitNullableNothingProperty) { - a() + a() ?")!>a.equals(null) ?")!>a.propT ?")!>a.propAny @@ -438,7 +438,7 @@ fun case_22(a: (() -> Unit)?) { // TESTCASE NUMBER: 23 fun case_23(a: ((Float) -> Int?)?, b: Float?, z: Nothing?) { if (a != z && b !== z && b !== z) { - val x = a(b) + val x = a(b) if (x != z || x !== implicitNullableNothingProperty) { x x.equals(null) @@ -457,7 +457,7 @@ fun case_23(a: ((Float) -> Int?)?, b: Float?, z: Nothing?) { // TESTCASE NUMBER: 24 fun case_24(a: ((() -> Unit) -> Unit)?, b: (() -> Unit)?, z: Nothing?) = if (a !== z && b !== z) { - a(?")!>b) + a(?")!>b) , kotlin.Unit>?")!>a.equals(null) , kotlin.Unit>?")!>a.propT , kotlin.Unit>?")!>a.propAny @@ -489,7 +489,7 @@ fun case_25(b: Boolean, z: Nothing?) { val y = if (b) x else z if (y !== z || y != implicitNullableNothingProperty) { - val z1 = ?")!>y() + val z1 = ?")!>y() if (z1 != z && implicitNullableNothingProperty !== z1) { ?")!>z1.a @@ -511,7 +511,7 @@ fun case_26(a: ((Float) -> Int?)?, b: Float?) { var z = null if (a != z == true && b != implicitNullableNothingProperty == true) { - val x = a(b) + val x = a(b) if (x != implicitNullableNothingProperty == true || z !== x) { x x.equals(null) @@ -575,7 +575,7 @@ fun case_29(x: Boolean) { val y = if (x) z else null if (false || false || false || false || y !== v) { - val t = ?")!>y() + val t = ?")!>y() if (z !== t || false) { ?")!>t.a @@ -595,7 +595,7 @@ fun case_29(x: Boolean) { // TESTCASE NUMBER: 30 fun case_30(a: ((Float) -> Int?)?, b: Float?) { if (implicitNullableNothingProperty != a == true && b != implicitNullableNothingProperty == true || false || false || false || false || false || false || false || false || false) { - val x = a(b) + val x = a(b) if (false || implicitNullableNothingProperty != x == true) { x x.equals(null) @@ -651,7 +651,7 @@ fun case_33(a: ((Float) -> Int?)?, b: Float?, c: Boolean?) { if (true && a == z == true || b == null == true) { } else { - val x = a(b) + val x = a(b) if (x == z == true && x === z || (c != z && !c)) { } else { @@ -1054,7 +1054,7 @@ fun case_60(b: Boolean) { val y = if (b) x else nullableNothingProperty if (y != nullableNothingProperty) { - val z = ?")!>y() + val z = ?")!>y() if (z == nullableNothingProperty) { ?")!>z diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt index 7b7ff033335..076f229c9ff 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt @@ -406,7 +406,7 @@ fun case_21() { fun case_22(a: (() -> Unit)?) { var y = null if (a != null || y != a) { - a() + a() ?")!>a.equals(null) ?")!>a.propT ?")!>a.propAny @@ -422,7 +422,7 @@ fun case_22(a: (() -> Unit)?) { // TESTCASE NUMBER: 23 fun case_23(a: ((Float) -> Int?)?, b: Float?, c: Nothing?) { if (a != null && b !== null || a != c && b !== c) { - val x = a(b) + val x = a(b) if (x != null || c !== x) { x x.equals(null) @@ -441,7 +441,7 @@ fun case_23(a: ((Float) -> Int?)?, b: Float?, c: Nothing?) { // TESTCASE NUMBER: 24 fun case_24(a: ((() -> Unit) -> Unit)?, b: (() -> Unit)?) = if (a !== null && b !== null || implicitNullableNothingProperty != a && nullableNothingProperty !== b) { - a(?")!>b) + a(?")!>b) , kotlin.Unit>?")!>a.equals(null) , kotlin.Unit>?")!>a.propT , kotlin.Unit>?")!>a.propAny @@ -475,7 +475,7 @@ fun case_25(b: Boolean) { if (y !== null || x()!!.b != y) { if (x()!!.b != y) { - val z = ?")!>y() + val z = ?")!>y() if (z != null) { & ?")!>z.a @@ -498,7 +498,7 @@ fun case_26(a: ((Float) -> Int?)?, b: Float?) { var c: Nothing? = null if (a != null == true && b != null == true || c != a == true && b != c == true) { - val x = a(b) + val x = a(b) if (x != null == true) { x x.equals(null) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/fir/FirUtils.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/fir/FirUtils.kt index bdbd0c52b94..0424c83339e 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/fir/FirUtils.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/fir/FirUtils.kt @@ -41,7 +41,7 @@ internal fun FirReference.getResolvedKtSymbolOfNameReference(builder: KtSymbolBy internal fun FirErrorNamedReference.getCandidateSymbols(): Collection> = when (val diagnostic = diagnostic) { - is ConeInapplicableCandidateError -> listOf(diagnostic.candidateSymbol) + is ConeInapplicableCandidateError -> listOf(diagnostic.candidate.symbol) is ConeHiddenCandidateError -> listOf(diagnostic.candidateSymbol) is ConeAmbiguityError -> diagnostic.candidates is ConeOperatorAmbiguityError -> diagnostic.candidates diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt index a9c65c0b055..83693dea8f7 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt @@ -268,7 +268,7 @@ internal object FirReferenceResolveHelper { val candidates = when (val diagnostic = fir.diagnostic) { is ConeAmbiguityError -> diagnostic.candidates is ConeOperatorAmbiguityError -> diagnostic.candidates - is ConeInapplicableCandidateError -> listOf(diagnostic.candidateSymbol) + is ConeInapplicableCandidateError -> listOf(diagnostic.candidate.symbol) else -> emptyList() } return candidates.mapNotNull { it.fir.buildSymbol(symbolBuilder) }