[NI] Don't add type variables from other expression as constraints
diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeCheckerContextForConstraintSystem.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeCheckerContextForConstraintSystem.kt
index babcbb1..d477203 100644
--- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeCheckerContextForConstraintSystem.kt
+++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/TypeCheckerContextForConstraintSystem.kt
@@ -75,6 +75,11 @@
         }
 
         if (typeVariable.isMarkedNullable) {
+            if (subType is SimpleType && isMyTypeVariable(subType.asSimpleType())) {
+//                addLowerConstraint(typeVariable.constructor, intersectTypes(listOf(subType, subType.builtIns.anyType)))
+                return true
+            }
+
 //            val notNullSubType = if (subType is NewCapturedType) intersectTypes(listOf(subType, subType.builtIns.anyType)) else subType.makeNotNullable().unwrap()
             val notNullSubType = subType.makeNotNullable().unwrap()
             addLowerConstraint(typeVariable.constructor, notNullSubType)
diff --git a/compiler/testData/codegen/box/regressions/intersectionInsideConstraintSystem.kt b/compiler/testData/codegen/box/regressions/intersectionInsideConstraintSystem.kt
new file mode 100644
index 0000000..da321a2
--- /dev/null
+++ b/compiler/testData/codegen/box/regressions/intersectionInsideConstraintSystem.kt
@@ -0,0 +1,9 @@
+fun <K> id(k: K): K = k
+
+fun <V : Any> create(compute: V?): V  = compute!!
+
+fun test(f: String?) = create(id(f))
+
+fun box(): String {
+    return "OK"
+}
\ No newline at end of file
diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java
index f1f8e98..3b9be4d 100644
--- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java
+++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java
@@ -16628,6 +16628,12 @@
             doTest(fileName);
         }
 
+        @TestMetadata("intersectionInsideConstraintSystem.kt")
+        public void testIntersectionInsideConstraintSystem() throws Exception {
+            String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/intersectionInsideConstraintSystem.kt");
+            doTest(fileName);
+        }
+
         @TestMetadata("intersectionOfEqualTypes.kt")
         public void testIntersectionOfEqualTypes() throws Exception {
             String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/intersectionOfEqualTypes.kt");
diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java
index 13f815e0..66f269b 100644
--- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java
+++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java
@@ -16628,6 +16628,12 @@
             doTest(fileName);
         }
 
+        @TestMetadata("intersectionInsideConstraintSystem.kt")
+        public void testIntersectionInsideConstraintSystem() throws Exception {
+            String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/intersectionInsideConstraintSystem.kt");
+            doTest(fileName);
+        }
+
         @TestMetadata("intersectionOfEqualTypes.kt")
         public void testIntersectionOfEqualTypes() throws Exception {
             String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/intersectionOfEqualTypes.kt");
diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java
index f550eb6..c995c1d 100644
--- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java
+++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java
@@ -16628,6 +16628,12 @@
             doTest(fileName);
         }
 
+        @TestMetadata("intersectionInsideConstraintSystem.kt")
+        public void testIntersectionInsideConstraintSystem() throws Exception {
+            String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/intersectionInsideConstraintSystem.kt");
+            doTest(fileName);
+        }
+
         @TestMetadata("intersectionOfEqualTypes.kt")
         public void testIntersectionOfEqualTypes() throws Exception {
             String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/intersectionOfEqualTypes.kt");
diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java
index 185dd7c..eea59d2 100644
--- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java
+++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java
@@ -20288,6 +20288,12 @@
             doTest(fileName);
         }
 
+        @TestMetadata("intersectionInsideConstraintSystem.kt")
+        public void testIntersectionInsideConstraintSystem() throws Exception {
+            String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/intersectionInsideConstraintSystem.kt");
+            doTest(fileName);
+        }
+
         @TestMetadata("intersectionOfEqualTypes.kt")
         public void testIntersectionOfEqualTypes() throws Exception {
             String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/regressions/intersectionOfEqualTypes.kt");