diff --git a/compiler/fir/analysis-tests/testData/resolve/kt41984.fir.txt b/compiler/fir/analysis-tests/testData/resolve/kt41984.fir.txt index 0de2d198e4f..fb68bb84095 100644 --- a/compiler/fir/analysis-tests/testData/resolve/kt41984.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/kt41984.fir.txt @@ -20,7 +20,7 @@ FILE: main.kt } public final fun test_1(b: R|B|, x: R|kotlin/Int|, inv: R|Inv|): R|kotlin/Unit| { - R|/b|.R|SubstitutionOverride|(R|/x|) - R|/b|.#(Null(null)) + R|/b|.#(R|/x|) + R|/b|.#(Null(null)) R|/b|.R|SubstitutionOverride|(R|/inv|) } diff --git a/compiler/fir/analysis-tests/testData/resolve/kt41984.kt b/compiler/fir/analysis-tests/testData/resolve/kt41984.kt index 740bc2bdeb1..ba80ec9f6ed 100644 --- a/compiler/fir/analysis-tests/testData/resolve/kt41984.kt +++ b/compiler/fir/analysis-tests/testData/resolve/kt41984.kt @@ -16,8 +16,8 @@ public abstract class A { class Inv -open class B : A() { - override fun take(value: V): String { +open class B : A() { + override fun take(value: V): String { return "" } @@ -25,7 +25,7 @@ open class B : A() { } fun test_1(b: B, x: Int, inv: Inv) { - b.take(x) - b.take(null) + b.take(x) + b.take(null) b.takeInv(inv) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt index 8ac279e8ec4..8c0cc9553a3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.types.model.KotlinTypeMarker import org.jetbrains.kotlin.types.model.SimpleTypeMarker class FirStandardOverrideChecker(private val session: FirSession) : FirAbstractOverrideChecker() { - private val context: ConeTypeContext = session.typeContext + private val context = session.typeContext private fun isEqualTypes(substitutedCandidateType: ConeKotlinType, substitutedBaseType: ConeKotlinType): Boolean { return with(context) { @@ -45,16 +45,11 @@ class FirStandardOverrideChecker(private val session: FirSession) : FirAbstractO } private fun isEqualTypes(candidateType: ConeKotlinType, baseType: ConeKotlinType, substitutor: ConeSubstitutor): Boolean { - val substitutedCandidateType = substitutor.substituteOrSelf(candidateType).unwrapDefinitelyNotNullType() - val substitutedBaseType = substitutor.substituteOrSelf(baseType).unwrapDefinitelyNotNullType() + val substitutedCandidateType = substitutor.substituteOrSelf(candidateType) + val substitutedBaseType = substitutor.substituteOrSelf(baseType) return isEqualTypes(substitutedCandidateType, substitutedBaseType) } - private fun ConeKotlinType.unwrapDefinitelyNotNullType(): ConeKotlinType = when (this) { - is ConeDefinitelyNotNullType -> original - else -> this - } - fun isEqualTypes(candidateTypeRef: FirTypeRef, baseTypeRef: FirTypeRef, substitutor: ConeSubstitutor): Boolean { candidateTypeRef.ensureResolvedTypeDeclaration(session, requiredPhase = FirResolvePhase.TYPES) baseTypeRef.ensureResolvedTypeDeclaration(session, requiredPhase = FirResolvePhase.TYPES) diff --git a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overridesJavaAnnotated.fir.kt b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overridesJavaAnnotated.fir.kt index 66612880650..e6c24d76077 100644 --- a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overridesJavaAnnotated.fir.kt +++ b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overridesJavaAnnotated.fir.kt @@ -18,7 +18,7 @@ interface B : A { interface C : A { override fun foo(x: T2 & Any): T2 & Any - override fun bar(x: T2): T2 + override fun bar(x: T2): T2 } interface D : A { diff --git a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt index d1c1f6d6e57..cb122f583f9 100644 --- a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt +++ b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt @@ -82,6 +82,13 @@ FILE fqName: fileName:/AbstractMutableMap.kt VALUE_PARAMETER name:p0 index:0 type:K of .MyMap VALUE_PARAMETER name:p1 index:1 type:@[EnhancedNullability] V of .MyMap VALUE_PARAMETER name:p2 index:2 type:@[EnhancedNullability] java.util.function.BiFunction.MyMap?, in @[FlexibleNullability] V of .MyMap?, out @[FlexibleNullability] V of .MyMap?> + FUN FAKE_OVERRIDE name:merge visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap, p0:@[FlexibleNullability] K of .MyMap?, p1:V of .MyMap, p2:@[EnhancedNullability] java.util.function.BiFunction.MyMap?, in @[FlexibleNullability] V of .MyMap?, out @[FlexibleNullability] V of .MyMap?>) returnType:V of .MyMap? [fake_override] + overridden: + public open fun merge (p0: @[FlexibleNullability] K of kotlin.collections.AbstractMutableMap?, p1: V of kotlin.collections.AbstractMutableMap, p2: @[EnhancedNullability] java.util.function.BiFunction): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap + $this: VALUE_PARAMETER name: type:kotlin.collections.MutableMap + VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] K of .MyMap? + VALUE_PARAMETER name:p1 index:1 type:V of .MyMap + VALUE_PARAMETER name:p2 index:2 type:@[EnhancedNullability] java.util.function.BiFunction.MyMap?, in @[FlexibleNullability] V of .MyMap?, out @[FlexibleNullability] V of .MyMap?> FUN FAKE_OVERRIDE name:computeIfPresent visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap, p0:K of .MyMap, p1:@[EnhancedNullability] java.util.function.BiFunction.MyMap?, in @[FlexibleNullability] V of .MyMap?, out @[FlexibleNullability] V of .MyMap?>) returnType:V of .MyMap? [fake_override] overridden: public open fun computeIfPresent (p0: K of kotlin.collections.AbstractMutableMap, p1: @[EnhancedNullability] java.util.function.BiFunction): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt index b50277a84c9..af4ff61363b 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt @@ -1,7 +1,7 @@ @OptIn(markerClass = [ExperimentalTypeInference::class]) fun scopedFlow(@BuilderInference block: @ExtensionFunctionType SuspendFunction2, Unit>): Flow { return flow(block = local suspend fun FlowCollector.() { - val collector: FlowCollector = + val collector: FlowCollector = flowScope(block = local suspend fun CoroutineScope.() { block.invoke(p1 = , p2 = collector) } @@ -12,7 +12,7 @@ fun scopedFlow(@BuilderInference block: @ExtensionFunctionType Suspen fun Flow.onCompletion(action: @ExtensionFunctionType SuspendFunction2, Throwable?, Unit>): Flow { return unsafeFlow(block = local suspend fun FlowCollector.() { - val safeCollector: SafeCollector = SafeCollector(collector = ) + val safeCollector: SafeCollector = SafeCollector(collector = ) safeCollector.invokeSafely(action = action) } ) @@ -27,11 +27,11 @@ inline fun unsafeFlow(@BuilderInference crossinline block: @Extension } @Deprecated(message = "binary compatibility with a version w/o FlowCollector receiver", level = DeprecationLevel.HIDDEN) -fun Flow.onCompletion(action: SuspendFunction1): ErrorType { - return error("") /* ErrorCallExpression */local fun () { - action.invoke(p1 = error("") /* ErrorCallExpression */) +fun Flow.onCompletion(action: SuspendFunction1): Flow { + return .onCompletion(action = local suspend fun FlowCollector.(it: Throwable?) { + action.invoke(p1 = it) } -; +) } private fun CoroutineScope.asFairChannel(flow: Flow<*>): ReceiveChannel { @@ -113,12 +113,12 @@ interface CoroutineScope { } interface Flow { - abstract suspend fun collect(collector: FlowCollector) + abstract suspend fun collect(collector: FlowCollector) } interface FlowCollector { - abstract suspend fun emit(value: T) + abstract suspend fun emit(value: T) } @@ -138,7 +138,7 @@ interface ProducerScope : CoroutineScope, SendChannel { } interface SendChannel { - abstract suspend fun send(e: E) + abstract suspend fun send(e: E) } diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt index b5b65b6c620..86d5bed4a44 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt @@ -14,8 +14,8 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.FlowCollector.scopedFlow>) returnType:kotlin.Unit [suspend] $receiver: VALUE_PARAMETER name: type:.FlowCollector.scopedFlow> BLOCK_BODY - VAR name:collector type:.FlowCollector [val] - GET_VAR ': .FlowCollector.scopedFlow> declared in .scopedFlow.' type=.FlowCollector origin=null + VAR name:collector type:.FlowCollector.scopedFlow> [val] + GET_VAR ': .FlowCollector.scopedFlow> declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null CALL 'public final fun flowScope (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.CoroutineScope, R of .flowScope>): R of .flowScope [suspend] declared in ' type=kotlin.Unit origin=null : kotlin.Unit block: FUN_EXPR type=kotlin.coroutines.SuspendFunction1<.CoroutineScope, kotlin.Unit> origin=LAMBDA @@ -25,7 +25,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt CALL 'public abstract fun invoke (p1: P1 of kotlin.coroutines.SuspendFunction2, p2: P2 of kotlin.coroutines.SuspendFunction2): R of kotlin.coroutines.SuspendFunction2 [suspend,operator] declared in kotlin.coroutines.SuspendFunction2' type=kotlin.Unit origin=null $this: GET_VAR 'block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> declared in .scopedFlow' type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> origin=VARIABLE_AS_FUNCTION p1: GET_VAR ': .CoroutineScope declared in .scopedFlow..' type=.CoroutineScope origin=null - p2: GET_VAR 'val collector: .FlowCollector [val] declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null + p2: GET_VAR 'val collector: .FlowCollector.scopedFlow> [val] declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit>) returnType:.Flow.onCompletion> TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] $receiver: VALUE_PARAMETER name: type:.Flow.onCompletion> @@ -38,13 +38,13 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.FlowCollector.onCompletion>) returnType:kotlin.Unit [suspend] $receiver: VALUE_PARAMETER name: type:.FlowCollector.onCompletion> BLOCK_BODY - VAR name:safeCollector type:.SafeCollector [val] + VAR name:safeCollector type:.SafeCollector.onCompletion> [val] CONSTRUCTOR_CALL 'public constructor (collector: .FlowCollector.SafeCollector>) [primary] declared in .SafeCollector' type=.SafeCollector.onCompletion> origin=null : T of .onCompletion collector: GET_VAR ': .FlowCollector.onCompletion> declared in .onCompletion.' type=.FlowCollector.onCompletion> origin=null CALL 'public final fun invokeSafely (action: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.invokeSafely>, kotlin.Throwable?, kotlin.Unit>): kotlin.Unit [suspend] declared in ' type=kotlin.Unit origin=null : T of .onCompletion - $receiver: GET_VAR 'val safeCollector: .SafeCollector [val] declared in .onCompletion.' type=.SafeCollector.onCompletion> origin=null + $receiver: GET_VAR 'val safeCollector: .SafeCollector.onCompletion> [val] declared in .onCompletion.' type=.SafeCollector.onCompletion> origin=null action: GET_VAR 'action: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit> declared in .onCompletion' type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit> origin=null FUN name:invokeSafely visibility:public modality:FINAL ($receiver:.FlowCollector.invokeSafely>, action:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.invokeSafely>, kotlin.Throwable?, kotlin.Unit>) returnType:kotlin.Unit [suspend] TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] @@ -61,21 +61,25 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun unsafeFlow (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.unsafeFlow>, kotlin.Unit>): .Flow.unsafeFlow> [inline] declared in ' CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null - FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:kotlin.coroutines.SuspendFunction1) returnType:IrErrorType(null) + FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:kotlin.coroutines.SuspendFunction1) returnType:.Flow.onCompletion> annotations: Deprecated(message = 'binary compatibility with a version w/o FlowCollector receiver', replaceWith = , level = GET_ENUM 'ENUM_ENTRY IR_EXTERNAL_DECLARATION_STUB name:HIDDEN' type=kotlin.DeprecationLevel) TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] $receiver: VALUE_PARAMETER name: type:.Flow.onCompletion> VALUE_PARAMETER name:action index:0 type:kotlin.coroutines.SuspendFunction1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun onCompletion (action: kotlin.coroutines.SuspendFunction1): IrErrorType(null) declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType(null) - FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit + RETURN type=kotlin.Nothing from='public final fun onCompletion (action: kotlin.coroutines.SuspendFunction1): .Flow.onCompletion> declared in ' + CALL 'public final fun onCompletion (action: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit>): .Flow.onCompletion> declared in ' type=.Flow.onCompletion> origin=null + : T of .onCompletion + $receiver: GET_VAR ': .Flow.onCompletion> declared in .onCompletion' type=.Flow.onCompletion> origin=null + action: FUN_EXPR type=kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.FlowCollector.onCompletion>, it:kotlin.Throwable?) returnType:kotlin.Unit [suspend] + $receiver: VALUE_PARAMETER name: type:.FlowCollector.onCompletion> + VALUE_PARAMETER name:it index:0 type:kotlin.Throwable? BLOCK_BODY CALL 'public abstract fun invoke (p1: P1 of kotlin.coroutines.SuspendFunction1): R of kotlin.coroutines.SuspendFunction1 [suspend,operator] declared in kotlin.coroutines.SuspendFunction1' type=kotlin.Unit origin=null $this: GET_VAR 'action: kotlin.coroutines.SuspendFunction1 declared in .onCompletion' type=kotlin.coroutines.SuspendFunction1 origin=VARIABLE_AS_FUNCTION - p1: ERROR_CALL 'Unresolved reference: #' type=IrErrorType(null) + p1: GET_VAR 'it: kotlin.Throwable? declared in .onCompletion.' type=kotlin.Throwable? origin=null FUN name:asFairChannel visibility:private modality:FINAL <> ($receiver:.CoroutineScope, flow:.Flow<*>) returnType:.ReceiveChannel $receiver: VALUE_PARAMETER name: type:.CoroutineScope VALUE_PARAMETER name:flow index:0 type:.Flow<*> diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt index fd50ea79921..d308f898f3c 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // !LANGUAGE: +NewInference // WITH_RUNTIME @@ -84,4 +83,4 @@ interface ProducerScope : CoroutineScope, SendChannel { interface SendChannel { suspend fun send(e: E) -} \ No newline at end of file +}