K2: switch off useRefinedBoundsForTypeVariableInFlexiblePosition mode in 2.3

It's one of DNN-related hacks that is planned to remove in OSIP-456
#KT-76056 Fixed
diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt
index 3142f43..27a3236 100644
--- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt
+++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt
@@ -671,9 +671,11 @@
         return (this as? ConeIntersectionType)?.upperBoundForApproximation
     }
 
-    override fun useRefinedBoundsForTypeVariableInFlexiblePosition(): Boolean = session.languageVersionSettings.supportsFeature(
-        LanguageFeature.JavaTypeParameterDefaultRepresentationWithDNN
-    )
+    // TODO: Get rid of this function once KT-59138 is fixed and the relevant feature for disabling it will be removed
+    // Also we should get rid of it once LanguageFeature.DontMakeExplicitJavaTypeArgumentsFlexible is removed
+    override fun useRefinedBoundsForTypeVariableInFlexiblePosition(): Boolean =
+        session.languageVersionSettings.supportsFeature(LanguageFeature.DontMakeExplicitJavaTypeArgumentsFlexible) ||
+                session.languageVersionSettings.supportsFeature(LanguageFeature.JavaTypeParameterDefaultRepresentationWithDNN)
 
     override fun KotlinTypeMarker.convertToNonRaw(): KotlinTypeMarker {
         require(this is ConeKotlinType)
diff --git a/compiler/testData/diagnostics/tests/j+k/typeFromGenericFunWithAnnotationWithoutWrtHack.fir.kt b/compiler/testData/diagnostics/tests/j+k/typeFromGenericFunWithAnnotationWithoutWrtHack.fir.kt
index 2b238c9..bfb4221 100644
--- a/compiler/testData/diagnostics/tests/j+k/typeFromGenericFunWithAnnotationWithoutWrtHack.fir.kt
+++ b/compiler/testData/diagnostics/tests/j+k/typeFromGenericFunWithAnnotationWithoutWrtHack.fir.kt
@@ -114,13 +114,13 @@
     x.foo9<String>(null)
     x.foo9<String?>(null)
     x.foo9(JavaBox(null))
-    x.foo9<String>(<!ARGUMENT_TYPE_MISMATCH!>JavaBox(null)<!>)
+    x.foo9<String>(JavaBox(null))
     x.foo9<String?>(JavaBox(null))
     x.foo9(JavaBox(""))
     takeString(x.<!CANNOT_INFER_PARAMETER_TYPE, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>bar9<!>()?.a)
 
-    x.<!CANNOT_INFER_PARAMETER_TYPE!>foo10<!>(<!ARGUMENT_TYPE_MISMATCH!>JavaBox(null)<!>)
-    x.foo10<String>(<!ARGUMENT_TYPE_MISMATCH!>JavaBox(null)<!>)
+    x.foo10(JavaBox(null))
+    x.foo10<String>(JavaBox(null))
     x.foo10<<!UPPER_BOUND_VIOLATED!>String?<!>>(<!ARGUMENT_TYPE_MISMATCH!>JavaBox(null)<!>)
     x.<!CANNOT_INFER_PARAMETER_TYPE, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo10<!>(null)
     x.foo10<String>(null)
diff --git a/compiler/testData/diagnostics/tests/j+k/typeFromJavaGenericFunWithoutWrtHack.fir.kt b/compiler/testData/diagnostics/tests/j+k/typeFromJavaGenericFunWithoutWrtHack.fir.kt
index 5402fbb..68331ee 100644
--- a/compiler/testData/diagnostics/tests/j+k/typeFromJavaGenericFunWithoutWrtHack.fir.kt
+++ b/compiler/testData/diagnostics/tests/j+k/typeFromJavaGenericFunWithoutWrtHack.fir.kt
@@ -47,7 +47,7 @@
     takeString(JavaWithGenericFun.foo4(JavaBox(JavaBox(""))).a.a)
     takeString(JavaWithGenericFun.foo4<String>(JavaBox(JavaBox(""))).a.a)
     takeString(<!ARGUMENT_TYPE_MISMATCH!>JavaWithGenericFun.foo4<String?>(JavaBox(JavaBox(""))).a.a<!>)
-    takeString(<!ARGUMENT_TYPE_MISMATCH!>JavaWithGenericFun.foo4(JavaBox(JavaBox(null))).a.a<!>)
+    takeString(JavaWithGenericFun.foo4(JavaBox(JavaBox(null))).a.a)
     takeString(JavaWithGenericFun.foo4<String>(JavaBox(JavaBox(null))).a.a)
     takeString(<!ARGUMENT_TYPE_MISMATCH!>JavaWithGenericFun.foo4<String?>(JavaBox(JavaBox(null))).a.a<!>)
 
@@ -61,7 +61,7 @@
     takeString(JavaWithGenericFun.foo6(JavaBox("")).a)
     takeString(JavaWithGenericFun.foo6<String>(JavaBox("")).a)
     takeString(<!ARGUMENT_TYPE_MISMATCH!>JavaWithGenericFun.foo6<String?>(JavaBox("")).a<!>)
-    takeString(<!ARGUMENT_TYPE_MISMATCH!>JavaWithGenericFun.foo6(JavaBox(null)).a<!>)
+    takeString(JavaWithGenericFun.foo6(JavaBox(null)).a)
     takeString(JavaWithGenericFun.foo6<String>(JavaBox(null)).a)
     takeString(<!ARGUMENT_TYPE_MISMATCH!>JavaWithGenericFun.foo6<String?>(JavaBox(null)).a<!>)
 }
diff --git a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt
index 66a7539..91cc4eb 100644
--- a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt
+++ b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt
@@ -333,7 +333,6 @@
      * In K2 (with +JavaTypeParameterDefaultRepresentationWithDNN), we use UpperConstraint & Any..UpperConstraint?
      *
      * In future once we have only K2 (or FE 1.0 behavior is fixed) this method should be inlined to the use-site
-     * TODO: Get rid of this function once KT-59138 is fixed and the relevant feature for disabling it will be removed
      */
     fun useRefinedBoundsForTypeVariableInFlexiblePosition(): Boolean