FIR: support DefinitelyNotNull types

 #KT-49465 Fixed
diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt
index a5fc341..f736ba2 100644
--- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt
+++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt
@@ -20,6 +20,7 @@
 import org.jetbrains.kotlin.ir.types.IrType
 import org.jetbrains.kotlin.ir.types.IrTypeArgument
 import org.jetbrains.kotlin.ir.types.IrTypeProjection
+import org.jetbrains.kotlin.ir.types.impl.IrDefinitelyNotNullTypeImpl
 import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
 import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl
 import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
@@ -188,7 +189,7 @@
                 }
             }
             is ConeDefinitelyNotNullType -> {
-                original.toIrType(typeContext.definitelyNotNull())
+                IrDefinitelyNotNullTypeImpl(null, original.toIrType(typeContext))
             }
             is ConeIntersectionType -> {
                 // TODO: add intersectionTypeApproximation
diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt
index c45f851..0c9e0d8 100644
--- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt
+++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt
@@ -53,6 +53,7 @@
 import org.jetbrains.kotlin.fir.types.builder.*
 import org.jetbrains.kotlin.fir.types.impl.*
 import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
+import org.jetbrains.kotlin.lexer.KtTokens
 import org.jetbrains.kotlin.lexer.KtTokens.*
 import org.jetbrains.kotlin.name.*
 import org.jetbrains.kotlin.utils.addToStdlib.runIf
@@ -1937,11 +1938,7 @@
                     source = typeRefSource
                     isMarkedNullable = false
                 }
-                INTERSECTION_TYPE -> firType =
-                    buildErrorTypeRef {
-                        source = typeRefSource
-                        diagnostic = ConeSimpleDiagnostic("Intersection types are not supported yet", DiagnosticKind.Syntax)
-                    }
+                INTERSECTION_TYPE -> firType = convertIntersectionType(typeRefSource, it, false)
                 CONTEXT_RECEIVER_LIST, TokenType.ERROR_ELEMENT -> firType =
                     buildErrorTypeRef {
                         source = typeRefSource
@@ -1963,6 +1960,29 @@
 
     private fun Collection<TypeModifier>.hasSuspend() = any { it.hasSuspend() }
 
+    private fun convertIntersectionType(typeRefSource: KtSourceElement, intersectionType: LighterASTNode, isNullable: Boolean): FirTypeRef {
+        val children = arrayListOf<FirTypeRef>()
+        intersectionType.forEachChildren {
+            if (it.tokenType != KtTokens.AND) { //skip in forEachChildren?
+                children.add(convertType(it))
+            }
+        }
+
+        if (children.size != 2) {
+            return buildErrorTypeRef {
+                source = typeRefSource
+                diagnostic = ConeSimpleDiagnostic("Wrong code", DiagnosticKind.Syntax)
+            }
+        }
+
+        return buildIntersectionTypeRef {
+            source = typeRefSource
+            isMarkedNullable = isNullable
+            leftType = children[0]
+            rightType = children[1]
+        }
+    }
+
     /**
      * @see org.jetbrains.kotlin.parsing.KotlinParsing.parseTypeRefContents
      */
@@ -1997,11 +2017,7 @@
                     source = typeRefSource
                     isMarkedNullable = true
                 }
-                INTERSECTION_TYPE -> firType =
-                    buildErrorTypeRef {
-                        source = typeRefSource
-                        diagnostic = ConeSimpleDiagnostic("Intersection types are not supported yet", DiagnosticKind.Syntax)
-                    }
+                INTERSECTION_TYPE -> firType = convertIntersectionType(typeRefSource, it, isNullable)
             }
         }
 
diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt
index 8353b630..78e64fe 100644
--- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt
+++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt
@@ -1751,9 +1751,11 @@
                         }
                     }
                 }
-                is KtIntersectionType -> FirErrorTypeRefBuilder().apply {
+                is KtIntersectionType -> FirIntersectionTypeRefBuilder().apply {
                     this.source = source
-                    diagnostic = ConeSimpleDiagnostic("Intersection types are not supported yet", DiagnosticKind.Syntax)
+                    isMarkedNullable = isNullable
+                    leftType = unwrappedElement.getLeftTypeRef()?.toFirOrErrorType()
+                    rightType = unwrappedElement.getRightTypeRef()?.toFirOrErrorType()
                 }
                 null -> FirErrorTypeRefBuilder().apply {
                     this.source = source
diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt
index 611cf2a..3ccde00 100644
--- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt
+++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt
@@ -485,6 +485,33 @@
             }
             is FirFunctionTypeRef -> createFunctionalType(typeRef) to null
             is FirDynamicTypeRef -> ConeKotlinErrorType(ConeUnsupportedDynamicType()) to null
+            is FirIntersectionTypeRef -> {
+                val (leftType, leftDiagnostic) = resolveType(
+                    typeRef.leftType
+                        ?: return ConeKotlinErrorType(ConeSimpleDiagnostic("Problem during processing intersection type")) to null,
+                    scopeClassDeclaration,
+                    areBareTypesAllowed,
+                    isOperandOfIsOperator,
+                    useSiteFile,
+                    supertypeSupplier
+                )
+                val (rightType, _) = resolveType(
+                    typeRef.rightType
+                        ?: return ConeKotlinErrorType(ConeSimpleDiagnostic("Problem during processing intersection type")) to null,
+                    scopeClassDeclaration,
+                    areBareTypesAllowed,
+                    isOperandOfIsOperator,
+                    useSiteFile,
+                    supertypeSupplier
+                )
+
+                if (rightType.isAny && leftType is ConeTypeParameterType) {
+                    ConeDefinitelyNotNullType(leftType) to leftDiagnostic //how properly concat (leftDiagnostic + rightDiagnostic)?
+                } else {
+                    ConeKotlinErrorType(ConeUnsupported("Intersection types are not supported yet", typeRef.source)) to null
+                }
+
+            }
             else -> error(typeRef.render())
         }
     }
diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirIntersectionTypeRef.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirIntersectionTypeRef.kt
new file mode 100644
index 0000000..eb2da0f
--- /dev/null
+++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirIntersectionTypeRef.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
+ */
+
+package org.jetbrains.kotlin.fir.types
+
+import org.jetbrains.kotlin.KtSourceElement
+import org.jetbrains.kotlin.fir.FirElement
+import org.jetbrains.kotlin.fir.expressions.FirAnnotation
+import org.jetbrains.kotlin.fir.visitors.*
+
+/*
+ * This file was generated automatically
+ * DO NOT MODIFY IT MANUALLY
+ */
+
+abstract class FirIntersectionTypeRef : FirTypeRefWithNullability() {
+    abstract override val source: KtSourceElement?
+    abstract override val annotations: List<FirAnnotation>
+    abstract override val isMarkedNullable: Boolean
+    abstract val leftType: FirTypeRef?
+    abstract val rightType: FirTypeRef?
+
+    override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitIntersectionTypeRef(this, data)
+
+    @Suppress("UNCHECKED_CAST")
+    override fun <E: FirElement, D> transform(transformer: FirTransformer<D>, data: D): E = 
+        transformer.transformIntersectionTypeRef(this, data) as E
+
+    abstract override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirIntersectionTypeRef
+}
diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirIntersectionTypeRefBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirIntersectionTypeRefBuilder.kt
new file mode 100644
index 0000000..331b880
--- /dev/null
+++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirIntersectionTypeRefBuilder.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
+ */
+
+package org.jetbrains.kotlin.fir.types.builder
+
+import kotlin.contracts.*
+import org.jetbrains.kotlin.KtSourceElement
+import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
+import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
+import org.jetbrains.kotlin.fir.expressions.FirAnnotation
+import org.jetbrains.kotlin.fir.types.FirIntersectionTypeRef
+import org.jetbrains.kotlin.fir.types.FirTypeRef
+import org.jetbrains.kotlin.fir.types.impl.FirIntersectionTypeRefImpl
+import org.jetbrains.kotlin.fir.visitors.*
+
+/*
+ * This file was generated automatically
+ * DO NOT MODIFY IT MANUALLY
+ */
+
+@FirBuilderDsl
+class FirIntersectionTypeRefBuilder : FirAnnotationContainerBuilder {
+    override var source: KtSourceElement? = null
+    override val annotations: MutableList<FirAnnotation> = mutableListOf()
+    var isMarkedNullable: Boolean by kotlin.properties.Delegates.notNull<Boolean>()
+    var leftType: FirTypeRef? = null
+    var rightType: FirTypeRef? = null
+
+    override fun build(): FirIntersectionTypeRef {
+        return FirIntersectionTypeRefImpl(
+            source,
+            annotations,
+            isMarkedNullable,
+            leftType,
+            rightType,
+        )
+    }
+
+}
+
+@OptIn(ExperimentalContracts::class)
+inline fun buildIntersectionTypeRef(init: FirIntersectionTypeRefBuilder.() -> Unit): FirIntersectionTypeRef {
+    contract {
+        callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
+    }
+    return FirIntersectionTypeRefBuilder().apply(init).build()
+}
diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirIntersectionTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirIntersectionTypeRefImpl.kt
new file mode 100644
index 0000000..a727533
--- /dev/null
+++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirIntersectionTypeRefImpl.kt
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
+ */
+
+package org.jetbrains.kotlin.fir.types.impl
+
+import org.jetbrains.kotlin.KtSourceElement
+import org.jetbrains.kotlin.fir.expressions.FirAnnotation
+import org.jetbrains.kotlin.fir.types.FirIntersectionTypeRef
+import org.jetbrains.kotlin.fir.types.FirTypeRef
+import org.jetbrains.kotlin.fir.visitors.*
+
+/*
+ * This file was generated automatically
+ * DO NOT MODIFY IT MANUALLY
+ */
+
+internal class FirIntersectionTypeRefImpl(
+    override val source: KtSourceElement?,
+    override val annotations: MutableList<FirAnnotation>,
+    override val isMarkedNullable: Boolean,
+    override var leftType: FirTypeRef?,
+    override var rightType: FirTypeRef?,
+) : FirIntersectionTypeRef() {
+    override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
+        annotations.forEach { it.accept(visitor, data) }
+        leftType?.accept(visitor, data)
+        rightType?.accept(visitor, data)
+    }
+
+    override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirIntersectionTypeRefImpl {
+        transformAnnotations(transformer, data)
+        leftType = leftType?.transform(transformer, data)
+        rightType = rightType?.transform(transformer, data)
+        return this
+    }
+
+    override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirIntersectionTypeRefImpl {
+        annotations.transformInplace(transformer, data)
+        return this
+    }
+}
diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt
index fbdd78c..0909ddc3 100644
--- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt
+++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitor.kt
@@ -135,6 +135,7 @@
 import org.jetbrains.kotlin.fir.types.FirUserTypeRef
 import org.jetbrains.kotlin.fir.types.FirDynamicTypeRef
 import org.jetbrains.kotlin.fir.types.FirFunctionTypeRef
+import org.jetbrains.kotlin.fir.types.FirIntersectionTypeRef
 import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
 import org.jetbrains.kotlin.fir.contracts.FirEffectDeclaration
 import org.jetbrains.kotlin.fir.contracts.FirContractDescription
@@ -278,6 +279,8 @@
 
     override fun visitFunctionTypeRef(functionTypeRef: FirFunctionTypeRef, data: D): R  = visitTypeRefWithNullability(functionTypeRef, data)
 
+    override fun visitIntersectionTypeRef(intersectionTypeRef: FirIntersectionTypeRef, data: D): R  = visitTypeRefWithNullability(intersectionTypeRef, data)
+
     override fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef, data: D): R  = visitTypeRef(implicitTypeRef, data)
 
     override fun visitLegacyRawContractDescription(legacyRawContractDescription: FirLegacyRawContractDescription, data: D): R  = visitContractDescription(legacyRawContractDescription, data)
diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt
index fb8efa3..5d3a829 100644
--- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt
+++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirDefaultVisitorVoid.kt
@@ -135,6 +135,7 @@
 import org.jetbrains.kotlin.fir.types.FirUserTypeRef
 import org.jetbrains.kotlin.fir.types.FirDynamicTypeRef
 import org.jetbrains.kotlin.fir.types.FirFunctionTypeRef
+import org.jetbrains.kotlin.fir.types.FirIntersectionTypeRef
 import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
 import org.jetbrains.kotlin.fir.contracts.FirEffectDeclaration
 import org.jetbrains.kotlin.fir.contracts.FirContractDescription
@@ -278,6 +279,8 @@
 
     override fun visitFunctionTypeRef(functionTypeRef: FirFunctionTypeRef)  = visitTypeRefWithNullability(functionTypeRef)
 
+    override fun visitIntersectionTypeRef(intersectionTypeRef: FirIntersectionTypeRef)  = visitTypeRefWithNullability(intersectionTypeRef)
+
     override fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef)  = visitTypeRef(implicitTypeRef)
 
     override fun visitLegacyRawContractDescription(legacyRawContractDescription: FirLegacyRawContractDescription)  = visitContractDescription(legacyRawContractDescription)
diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt
index 3ff6dac..5def54f 100644
--- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt
+++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirTransformer.kt
@@ -135,6 +135,7 @@
 import org.jetbrains.kotlin.fir.types.FirUserTypeRef
 import org.jetbrains.kotlin.fir.types.FirDynamicTypeRef
 import org.jetbrains.kotlin.fir.types.FirFunctionTypeRef
+import org.jetbrains.kotlin.fir.types.FirIntersectionTypeRef
 import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
 import org.jetbrains.kotlin.fir.contracts.FirEffectDeclaration
 import org.jetbrains.kotlin.fir.contracts.FirContractDescription
@@ -667,6 +668,10 @@
         return transformElement(functionTypeRef, data)
     }
 
+    open fun transformIntersectionTypeRef(intersectionTypeRef: FirIntersectionTypeRef, data: D): FirTypeRef {
+        return transformElement(intersectionTypeRef, data)
+    }
+
     open fun transformImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef, data: D): FirTypeRef {
         return transformElement(implicitTypeRef, data)
     }
@@ -1211,6 +1216,10 @@
         return transformFunctionTypeRef(functionTypeRef, data)
     }
 
+    final override fun visitIntersectionTypeRef(intersectionTypeRef: FirIntersectionTypeRef, data: D): FirTypeRef {
+        return transformIntersectionTypeRef(intersectionTypeRef, data)
+    }
+
     final override fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef, data: D): FirTypeRef {
         return transformImplicitTypeRef(implicitTypeRef, data)
     }
diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt
index 38d206b..cd288e6 100644
--- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt
+++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitor.kt
@@ -135,6 +135,7 @@
 import org.jetbrains.kotlin.fir.types.FirUserTypeRef
 import org.jetbrains.kotlin.fir.types.FirDynamicTypeRef
 import org.jetbrains.kotlin.fir.types.FirFunctionTypeRef
+import org.jetbrains.kotlin.fir.types.FirIntersectionTypeRef
 import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
 import org.jetbrains.kotlin.fir.contracts.FirEffectDeclaration
 import org.jetbrains.kotlin.fir.contracts.FirContractDescription
@@ -408,6 +409,8 @@
 
     open fun visitFunctionTypeRef(functionTypeRef: FirFunctionTypeRef, data: D): R  = visitElement(functionTypeRef, data)
 
+    open fun visitIntersectionTypeRef(intersectionTypeRef: FirIntersectionTypeRef, data: D): R  = visitElement(intersectionTypeRef, data)
+
     open fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef, data: D): R  = visitElement(implicitTypeRef, data)
 
     open fun visitEffectDeclaration(effectDeclaration: FirEffectDeclaration, data: D): R  = visitElement(effectDeclaration, data)
diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt
index 521641c..fb99d94 100644
--- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt
+++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/visitors/FirVisitorVoid.kt
@@ -135,6 +135,7 @@
 import org.jetbrains.kotlin.fir.types.FirUserTypeRef
 import org.jetbrains.kotlin.fir.types.FirDynamicTypeRef
 import org.jetbrains.kotlin.fir.types.FirFunctionTypeRef
+import org.jetbrains.kotlin.fir.types.FirIntersectionTypeRef
 import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
 import org.jetbrains.kotlin.fir.contracts.FirEffectDeclaration
 import org.jetbrains.kotlin.fir.contracts.FirContractDescription
@@ -666,6 +667,10 @@
         visitElement(functionTypeRef)
     }
 
+    open fun visitIntersectionTypeRef(intersectionTypeRef: FirIntersectionTypeRef) {
+        visitElement(intersectionTypeRef)
+    }
+
     open fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef) {
         visitElement(implicitTypeRef)
     }
@@ -1210,6 +1215,10 @@
         visitFunctionTypeRef(functionTypeRef)
     }
 
+    final override fun visitIntersectionTypeRef(intersectionTypeRef: FirIntersectionTypeRef, data: Nothing?) {
+        visitIntersectionTypeRef(intersectionTypeRef)
+    }
+
     final override fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef, data: Nothing?) {
         visitImplicitTypeRef(implicitTypeRef)
     }
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt
index 7b8d914..58e449e 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt
@@ -17,10 +17,7 @@
 import org.jetbrains.kotlin.fir.references.FirReference
 import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
 import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
-import org.jetbrains.kotlin.fir.types.FirDynamicTypeRef
-import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
-import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
-import org.jetbrains.kotlin.fir.types.FirTypeRef
+import org.jetbrains.kotlin.fir.types.*
 import org.jetbrains.kotlin.fir.types.builder.*
 import org.jetbrains.kotlin.fir.types.impl.*
 import org.jetbrains.kotlin.name.FqName
@@ -62,6 +59,12 @@
             annotations += typeRef.annotations
         }
         is FirImplicitBuiltinTypeRef -> typeRef.withFakeSource(newKind)
+        is FirIntersectionTypeRef -> buildIntersectionTypeRef {
+            source = newSource
+            isMarkedNullable = typeRef.isMarkedNullable
+            leftType = typeRef.leftType
+            rightType = typeRef.rightType
+        }
         else -> TODO("Not implemented for ${typeRef::class}")
     } as R
 }
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/visitors/FirDefaultTransformer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/visitors/FirDefaultTransformer.kt
index 23c76cc..c9a9c6f 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/visitors/FirDefaultTransformer.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/visitors/FirDefaultTransformer.kt
@@ -40,6 +40,10 @@
         return transformTypeRefWithNullability(userTypeRef, data)
     }
 
+    override fun transformIntersectionTypeRef(intersectionTypeRef: FirIntersectionTypeRef, data: D): FirTypeRef {
+        return transformTypeRef(intersectionTypeRef, data)
+    }
+
     override fun transformCallableReferenceAccess(
         callableReferenceAccess: FirCallableReferenceAccess,
         data: D
diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt
index b99ca74..f16fb8f 100644
--- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt
+++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FirTreeBuilder.kt
@@ -161,6 +161,7 @@
     val userTypeRef by element(TypeRef, typeRefWithNullability)
     val dynamicTypeRef by element(TypeRef, typeRefWithNullability)
     val functionTypeRef by element(TypeRef, typeRefWithNullability)
+    val intersectionTypeRef by element(TypeRef, typeRefWithNullability)
     val implicitTypeRef by element(TypeRef, typeRef)
 
     val effectDeclaration by element(Contracts)
diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt
index 83b5a5f..7bfb072 100644
--- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt
+++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt
@@ -643,6 +643,11 @@
             +booleanField("isSuspend")
         }
 
+        intersectionTypeRef.configure {
+            +field("leftType", typeRef, nullable = true)
+            +field("rightType", typeRef, nullable = true)
+        }
+
         thisReceiverExpression.configure {
             +field("calleeReference", thisReference)
             +booleanField("isImplicit")
diff --git a/compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt b/compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt
index 33ff8db..3737cda64 100644
--- a/compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt
+++ b/compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt
@@ -3,8 +3,6 @@
 // IGNORE_BACKEND: JS_IR
 // IGNORE_BACKEND: WASM
 // IGNORE_BACKEND: NATIVE
-// IGNORE_BACKEND_FIR: JVM_IR
-// FIR status: Syntax error at (T & Any)
 
 fun <T> test(t: T) = t as (T & Any)
 
diff --git a/compiler/testData/codegen/box/notNullAssertions/definitelyNotNullTypes.kt b/compiler/testData/codegen/box/notNullAssertions/definitelyNotNullTypes.kt
index 9fcc305..66c27aca 100644
--- a/compiler/testData/codegen/box/notNullAssertions/definitelyNotNullTypes.kt
+++ b/compiler/testData/codegen/box/notNullAssertions/definitelyNotNullTypes.kt
@@ -1,7 +1,5 @@
 // !LANGUAGE: +DefinitelyNonNullableTypes +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
 // TARGET_BACKEND: JVM
-// IGNORE_BACKEND_FIR: JVM_IR
-// FIR status: wrong NOTHING_TO_OVERRIDE at KDerived.foo
 // FILE: JClass.java
 
 import org.jetbrains.annotations.*;
diff --git a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/approximation.fir.kt b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/approximation.fir.kt
index 7116b2f..4731d49 100644
--- a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/approximation.fir.kt
+++ b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/approximation.fir.kt
@@ -4,11 +4,11 @@
 
 fun main() {
     foo<String>("", "").length
-    foo<String>("", null).length
+    foo<String>("", <!NULL_FOR_NONNULL_TYPE!>null<!>).length
     foo<String?>(null, "").length
     foo<String?>(null, null).length
 
     foo("", "").length
     foo("", null).length
-    foo(null, "").<!UNRESOLVED_REFERENCE!>length<!>
+    foo(null, "").length
 }
diff --git a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/bareTypes.fir.kt b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/bareTypes.fir.kt
index 1f0de03..f4ebe73 100644
--- a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/bareTypes.fir.kt
+++ b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/bareTypes.fir.kt
@@ -3,5 +3,5 @@
 fun main(x: Collection<String>) {
     if (x is List<!SYNTAX!><!> <!SYNTAX!><!SYNTAX!><!>& Any)<!> {}
 
-    val w: List & Any = null!!
+    val w: <!UNSUPPORTED!><!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>List<!> & Any<!> = null!!
 }
diff --git a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/inference.fir.kt b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/inference.fir.kt
index 948f2f2..33e47c3 100644
--- a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/inference.fir.kt
+++ b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/inference.fir.kt
@@ -28,6 +28,6 @@
     w1.foo()
     w2.foo()
 
-    <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>expectNN<!>(m)
-    <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>expectNN<!>(m!!)
+    expectNN(m)
+    expectNN(m!!)
 }
diff --git a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/notApplicable.fir.kt b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/notApplicable.fir.kt
index 089653e..1f9a6be 100644
--- a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/notApplicable.fir.kt
+++ b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/notApplicable.fir.kt
@@ -1,18 +1,18 @@
 // !LANGUAGE: +DefinitelyNonNullableTypes
 
-fun <T : Any> foo(x: T & Any, y: List<String & Any> & Any) {}
+fun <T : Any> foo(x: T & Any, y: <!UNSUPPORTED!>List<<!UNSUPPORTED!>String & Any<!>> & Any<!>) {}
 
 fun <F> bar1(x: F? & Any) {}
-fun <F> bar2(x: F & Any?) {}
+fun <F> bar2(x: <!UNSUPPORTED!>F & Any?<!>) {}
 fun <F> bar3(x: (F?) & Any) {}
 fun <F> bar4(x: (F & Any)?) {}
 
-fun <F> bar5(x: F & String) {}
+fun <F> bar5(x: <!UNSUPPORTED!>F & String<!>) {}
 
-fun <F> bar6(x: F & (F & Any)) {}
-fun <F> bar7(x: (F & Any) & Any) {}
+fun <F> bar6(x: <!UNSUPPORTED!>F & (F & Any)<!>) {}
+fun <F> bar7(x: <!UNSUPPORTED!>(F & Any) & Any<!>) {}
 fun <F> bar8(x: (F & Any).() -> Unit) {}
 fun <F> (F & Any).bar9(x: () -> Unit) {}
 
-fun <F> bar10(x: F & Any & String) {}
-fun <F> bar11(x: Double & Any & String) {}
+fun <F> bar10(x: <!UNSUPPORTED!>F & <!UNSUPPORTED!>Any & String<!><!>) {}
+fun <F> bar11(x: <!UNSUPPORTED!>Double & <!UNSUPPORTED!>Any & String<!><!>) {}
diff --git a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overrides.fir.kt b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overrides.fir.kt
deleted file mode 100644
index 407d6f6..0000000
--- a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overrides.fir.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-// !LANGUAGE: +DefinitelyNonNullableTypes
-
-interface A<T> {
-    fun foo(x: T): T
-    fun bar(x: T & Any): T & Any
-}
-
-interface B<T1> : A<T1> {
-    override fun foo(x: T1): T1
-    <!NOTHING_TO_OVERRIDE!>override<!> fun bar(x: T1 & Any): T1 & Any
-}
-
-interface C<T2> : A<T2> {
-    <!NOTHING_TO_OVERRIDE!>override<!> fun foo(x: T2 & Any): T2 & Any
-    <!NOTHING_TO_OVERRIDE!>override<!> fun bar(x: T2): T2
-}
-
-interface D : A<String?> {
-    override fun foo(x: String?): String?
-    <!NOTHING_TO_OVERRIDE!>override<!> fun bar(x: String): String
-}
-
-interface E : A<String> {
-    override fun foo(x: String): String
-    <!NOTHING_TO_OVERRIDE!>override<!> fun bar(x: String): String
-}
-
-interface F : A<String?> {
-    <!NOTHING_TO_OVERRIDE!>override<!> fun foo(x: String): String
-    <!NOTHING_TO_OVERRIDE!>override<!> fun bar(x: String?): String?
-}
-
-interface G<T3 : Any> : A<T3> {
-    override fun foo(x: T3): T3
-    <!NOTHING_TO_OVERRIDE!>override<!> fun bar(x: T3): T3
-}
diff --git a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overrides.kt b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overrides.kt
index 49ff6544..c958aeb 100644
--- a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overrides.kt
+++ b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overrides.kt
@@ -1,3 +1,4 @@
+// FIR_IDENTICAL
 // !LANGUAGE: +DefinitelyNonNullableTypes
 
 interface A<T> {
diff --git a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overridesJavaAnnotated.fir.kt b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overridesJavaAnnotated.fir.kt
deleted file mode 100644
index e6c24d7..0000000
--- a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overridesJavaAnnotated.fir.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-// !LANGUAGE: +DefinitelyNonNullableTypes +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
-
-// FILE: A.java
-import org.jetbrains.annotations.*;
-
-public interface A<T> {
-    public T foo(T x) { return x; }
-    @NotNull
-    public T bar(@NotNull T x) {}
-}
-
-// FILE: main.kt
-
-interface B<T1> : A<T1> {
-    override fun foo(x: T1): T1
-    <!NOTHING_TO_OVERRIDE!>override<!> fun bar(x: T1 & Any): T1 & Any
-}
-
-interface C<T2> : A<T2> {
-    override fun foo(x: T2 & Any): T2 & Any
-    <!NOTHING_TO_OVERRIDE!>override<!> fun bar(x: T2): T2
-}
-
-interface D : A<String?> {
-    override fun foo(x: String?): String?
-    override fun bar(x: String): String
-}
-
-interface E : A<String> {
-    override fun foo(x: String): String
-    override fun bar(x: String): String
-}
-
-interface F : A<String?> {
-    <!NOTHING_TO_OVERRIDE!>override<!> fun foo(x: String): String
-    <!NOTHING_TO_OVERRIDE!>override<!> fun bar(x: String?): String?
-}
-
-interface G<T3 : Any> : A<T3> {
-    override fun foo(x: T3): T3
-    override fun bar(x: T3): T3
-}
diff --git a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overridesJavaAnnotated.kt b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overridesJavaAnnotated.kt
index 4d0839a..8fc72d5 100644
--- a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overridesJavaAnnotated.kt
+++ b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/overridesJavaAnnotated.kt
@@ -1,3 +1,4 @@
+// FIR_IDENTICAL
 // !LANGUAGE: +DefinitelyNonNullableTypes +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
 
 // FILE: A.java
diff --git a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/simple.fir.kt b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/simple.fir.kt
index 46dce46..748219c 100644
--- a/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/simple.fir.kt
+++ b/compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/simple.fir.kt
@@ -3,12 +3,12 @@
 fun <T> foo(x: T, y: T & Any): T & Any = x ?: y
 
 fun main() {
-    foo<String>("", "").<!UNRESOLVED_REFERENCE!>length<!>
-    foo<String>("", null).<!UNRESOLVED_REFERENCE!>length<!>
-    foo<String?>(null, "").<!UNRESOLVED_REFERENCE!>length<!>
-    foo<String?>(null, null).<!UNRESOLVED_REFERENCE!>length<!>
+    foo<String>("", "").length
+    foo<String>("", <!NULL_FOR_NONNULL_TYPE!>null<!>).length
+    foo<String?>(null, "").length
+    foo<String?>(null, null).length
 
-    foo("", "").<!UNRESOLVED_REFERENCE!>length<!>
-    foo("", null).<!UNRESOLVED_REFERENCE!>length<!>
-    foo(null, "").<!UNRESOLVED_REFERENCE!>length<!>
+    foo("", "").length
+    foo("", null).length
+    foo(null, "").length
 }
diff --git a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinOverridesDefinitelyNonNullable.fir.kt b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinOverridesDefinitelyNonNullable.fir.kt
index 79cb673..0f3e5cb 100644
--- a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinOverridesDefinitelyNonNullable.fir.kt
+++ b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinOverridesDefinitelyNonNullable.fir.kt
@@ -30,8 +30,8 @@
 }
 
 interface Q2<X> : SLRUMap<X> {
-    <!NOTHING_TO_OVERRIDE!>override<!> fun takeV(x: X & Any)
-    <!NOTHING_TO_OVERRIDE!>override<!> fun <E1> takeE(e: E1 & Any)
+    override fun takeV(x: X & Any)
+    override fun <E1> takeE(e: E1 & Any)
 
     override fun takeVList(l: List<X & Any>)
     override fun <E2> takeEList(l2: List<E2 & Any>)
diff --git a/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt b/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt
index cca5d16..68aa0fd 100644
--- a/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt
+++ b/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt
@@ -30,7 +30,7 @@
     VALUE_PARAMETER name:a index:0 type:X of <root>.test3
     BLOCK_BODY
       RETURN type=kotlin.Nothing from='public final fun test3 <X> (a: X of <root>.test3): X of <root>.test3 declared in <root>'
-        CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=X of <root>.test3 origin=EXCLEXCL
+        CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type={X of <root>.test3 & Any} origin=EXCLEXCL
           <T0>: X of <root>.test3
           arg0: GET_VAR 'a: X of <root>.test3 declared in <root>.test3' type=X of <root>.test3 origin=null
   FUN name:useString visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit
diff --git a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.ir.txt b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.ir.txt
new file mode 100644
index 0000000..1fd1e70
--- /dev/null
+++ b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.ir.txt
@@ -0,0 +1,75 @@
+FILE fqName:<root> fileName:/implicitCastToNonNull.kt
+  FUN name:test1 visibility:public modality:FINAL <> (x:kotlin.String?) returnType:kotlin.Int
+    VALUE_PARAMETER name:x index:0 type:kotlin.String?
+    BLOCK_BODY
+      RETURN type=kotlin.Nothing from='public final fun test1 (x: kotlin.String?): kotlin.Int declared in <root>'
+        WHEN type=kotlin.Int origin=IF
+          BRANCH
+            if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
+              arg0: GET_VAR 'x: kotlin.String? declared in <root>.test1' type=kotlin.String? origin=null
+              arg1: CONST Null type=kotlin.Nothing? value=null
+            then: CONST Int type=kotlin.Int value=0
+          BRANCH
+            if: CONST Boolean type=kotlin.Boolean value=true
+            then: CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
+              $this: GET_VAR 'x: kotlin.String? declared in <root>.test1' type=kotlin.String? origin=null
+  FUN name:test2 visibility:public modality:FINAL <T> (x:T of <root>.test2) returnType:kotlin.Int
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.CharSequence?]
+    VALUE_PARAMETER name:x index:0 type:T of <root>.test2
+    BLOCK_BODY
+      RETURN type=kotlin.Nothing from='public final fun test2 <T> (x: T of <root>.test2): kotlin.Int declared in <root>'
+        WHEN type=kotlin.Int origin=IF
+          BRANCH
+            if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
+              arg0: GET_VAR 'x: T of <root>.test2 declared in <root>.test2' type=T of <root>.test2 origin=null
+              arg1: CONST Null type=kotlin.Nothing? value=null
+            then: CONST Int type=kotlin.Int value=0
+          BRANCH
+            if: CONST Boolean type=kotlin.Boolean value=true
+            then: CALL 'public abstract fun <get-length> (): kotlin.Int declared in kotlin.CharSequence' type=kotlin.Int origin=GET_PROPERTY
+              $this: GET_VAR 'x: T of <root>.test2 declared in <root>.test2' type=T of <root>.test2 origin=null
+  FUN name:test3 visibility:public modality:FINAL <T> (x:kotlin.Any) returnType:kotlin.Int [inline]
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.CharSequence?]
+    VALUE_PARAMETER name:x index:0 type:kotlin.Any
+    BLOCK_BODY
+      RETURN type=kotlin.Nothing from='public final fun test3 <T> (x: kotlin.Any): kotlin.Int [inline] declared in <root>'
+        WHEN type=kotlin.Int origin=IF
+          BRANCH
+            if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=T of <root>.test3
+              GET_VAR 'x: kotlin.Any declared in <root>.test3' type=kotlin.Any origin=null
+            then: CONST Int type=kotlin.Int value=0
+          BRANCH
+            if: CONST Boolean type=kotlin.Boolean value=true
+            then: CALL 'public abstract fun <get-length> (): kotlin.Int declared in kotlin.CharSequence' type=kotlin.Int origin=GET_PROPERTY
+              $this: TYPE_OP type={T of <root>.test3 & Any} origin=IMPLICIT_CAST typeOperand={T of <root>.test3 & Any}
+                GET_VAR 'x: kotlin.Any declared in <root>.test3' type=kotlin.Any origin=null
+  FUN name:test4 visibility:public modality:FINAL <T> (x:kotlin.Any?) returnType:kotlin.Int [inline]
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.CharSequence]
+    VALUE_PARAMETER name:x index:0 type:kotlin.Any?
+    BLOCK_BODY
+      RETURN type=kotlin.Nothing from='public final fun test4 <T> (x: kotlin.Any?): kotlin.Int [inline] declared in <root>'
+        WHEN type=kotlin.Int origin=IF
+          BRANCH
+            if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=T of <root>.test4
+              GET_VAR 'x: kotlin.Any? declared in <root>.test4' type=kotlin.Any? origin=null
+            then: CONST Int type=kotlin.Int value=0
+          BRANCH
+            if: CONST Boolean type=kotlin.Boolean value=true
+            then: CALL 'public abstract fun <get-length> (): kotlin.Int declared in kotlin.CharSequence' type=kotlin.Int origin=GET_PROPERTY
+              $this: TYPE_OP type=T of <root>.test4 origin=IMPLICIT_CAST typeOperand=T of <root>.test4
+                GET_VAR 'x: kotlin.Any? declared in <root>.test4' type=kotlin.Any? origin=null
+  FUN name:test5 visibility:public modality:FINAL <T, S> (x:T of <root>.test5, fn:kotlin.Function1<S of <root>.test5, kotlin.Unit>) returnType:kotlin.Unit
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[S of <root>.test5?]
+    TYPE_PARAMETER name:S index:1 variance: superTypes:[kotlin.Any?]
+    VALUE_PARAMETER name:x index:0 type:T of <root>.test5
+    VALUE_PARAMETER name:fn index:1 type:kotlin.Function1<S of <root>.test5, kotlin.Unit>
+    BLOCK_BODY
+      WHEN type=kotlin.Unit origin=IF
+        BRANCH
+          if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
+            $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
+              arg0: GET_VAR 'x: T of <root>.test5 declared in <root>.test5' type=T of <root>.test5 origin=null
+              arg1: CONST Null type=kotlin.Nothing? value=null
+          then: CALL 'public abstract fun invoke (p1: P1 of kotlin.Function1): R of kotlin.Function1 [operator] declared in kotlin.Function1' type=kotlin.Unit origin=INVOKE
+            $this: GET_VAR 'fn: kotlin.Function1<S of <root>.test5, kotlin.Unit> declared in <root>.test5' type=kotlin.Function1<S of <root>.test5, kotlin.Unit> origin=VARIABLE_AS_FUNCTION
+            p1: GET_VAR 'x: T of <root>.test5 declared in <root>.test5' type=T of <root>.test5 origin=null
diff --git a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.kt.txt b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.kt.txt
new file mode 100644
index 0000000..38c2798
--- /dev/null
+++ b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.kt.txt
@@ -0,0 +1,33 @@
+fun test1(x: String?): Int {
+  return when {
+    EQEQ(arg0 = x, arg1 = null) -> 0
+    else -> x.<get-length>()
+  }
+}
+
+fun <T : CharSequence?> test2(x: T): Int {
+  return when {
+    EQEQ(arg0 = x, arg1 = null) -> 0
+    else -> x.<get-length>()
+  }
+}
+
+inline fun <reified T : CharSequence?> test3(x: Any): Int {
+  return when {
+    x !is T -> 0
+    else -> x /*as (T & Any) */.<get-length>()
+  }
+}
+
+inline fun <reified T : CharSequence> test4(x: Any?): Int {
+  return when {
+    x !is T -> 0
+    else -> x /*as T */.<get-length>()
+  }
+}
+
+fun <T : S?, S : Any?> test5(x: T, fn: Function1<S, Unit>) {
+  when {
+    EQEQ(arg0 = x, arg1 = null).not() -> fn.invoke(p1 = x)
+  }
+}
diff --git a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.kt b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.kt
index 1e8ea10..fa48295 100644
--- a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.kt
+++ b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.kt
@@ -1,4 +1,3 @@
-// FIR_IDENTICAL
 fun test1(x: String?) =
     if (x == null) 0 else x.length
 
diff --git a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.ir.txt b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.ir.txt
new file mode 100644
index 0000000..a51bae8
--- /dev/null
+++ b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.ir.txt
@@ -0,0 +1,82 @@
+FILE fqName:<root> fileName:/implicitCastToTypeParameter.kt
+  FUN name:test1 visibility:public modality:FINAL <T> ($receiver:kotlin.Any) returnType:T of <root>.test1? [inline]
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any]
+    $receiver: VALUE_PARAMETER name:<this> type:kotlin.Any
+    BLOCK_BODY
+      RETURN type=kotlin.Nothing from='public final fun test1 <T> (): T of <root>.test1? [inline] declared in <root>'
+        WHEN type=T of <root>.test1? origin=IF
+          BRANCH
+            if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=T of <root>.test1
+              GET_VAR '<this>: kotlin.Any declared in <root>.test1' type=kotlin.Any origin=null
+            then: TYPE_OP type=T of <root>.test1 origin=IMPLICIT_CAST typeOperand=T of <root>.test1
+              GET_VAR '<this>: kotlin.Any declared in <root>.test1' type=kotlin.Any origin=null
+          BRANCH
+            if: CONST Boolean type=kotlin.Boolean value=true
+            then: CONST Null type=kotlin.Nothing? value=null
+  CLASS INTERFACE name:Foo modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Foo<T of <root>.Foo>
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+  PROPERTY name:asT visibility:public modality:FINAL [val]
+    FUN name:<get-asT> visibility:public modality:FINAL <T> ($receiver:<root>.Foo<T of <root>.<get-asT>>) returnType:T of <root>.<get-asT>? [inline]
+      correspondingProperty: PROPERTY name:asT visibility:public modality:FINAL [val]
+      TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any]
+      $receiver: VALUE_PARAMETER name:<this> type:<root>.Foo<T of <root>.<get-asT>>
+      BLOCK_BODY
+        RETURN type=kotlin.Nothing from='public final fun <get-asT> <T> (): T of <root>.<get-asT>? [inline] declared in <root>'
+          WHEN type=T of <root>.<get-asT>? origin=IF
+            BRANCH
+              if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=T of <root>.<get-asT>
+                GET_VAR '<this>: <root>.Foo<T of <root>.<get-asT>> declared in <root>.<get-asT>' type=<root>.Foo<T of <root>.<get-asT>> origin=null
+              then: TYPE_OP type=T of <root>.<get-asT> origin=IMPLICIT_CAST typeOperand=T of <root>.<get-asT>
+                GET_VAR '<this>: <root>.Foo<T of <root>.<get-asT>> declared in <root>.<get-asT>' type=<root>.Foo<T of <root>.<get-asT>> origin=null
+            BRANCH
+              if: CONST Boolean type=kotlin.Boolean value=true
+              then: CONST Null type=kotlin.Nothing? value=null
+  CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Bar<T of <root>.Bar>
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    CONSTRUCTOR visibility:public <> () returnType:<root>.Bar<T of <root>.Bar> [primary]
+      BLOCK_BODY
+        DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
+        INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]'
+    FUN name:test visibility:public modality:FINAL <> ($this:<root>.Bar<T of <root>.Bar>, arg:kotlin.Any) returnType:kotlin.Unit
+      $this: VALUE_PARAMETER name:<this> type:<root>.Bar<T of <root>.Bar>
+      VALUE_PARAMETER name:arg index:0 type:kotlin.Any
+      BLOCK_BODY
+        TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
+          TYPE_OP type=T of <root>.Bar origin=CAST typeOperand=T of <root>.Bar
+            GET_VAR 'arg: kotlin.Any declared in <root>.Bar.test' type=kotlin.Any origin=null
+        CALL 'public final fun useT (t: T of <root>.Bar): kotlin.Unit declared in <root>.Bar' type=kotlin.Unit origin=null
+          $this: GET_VAR '<this>: <root>.Bar<T of <root>.Bar> declared in <root>.Bar.test' type=<root>.Bar<T of <root>.Bar> origin=null
+          t: TYPE_OP type={T of <root>.Bar & Any} origin=IMPLICIT_CAST typeOperand={T of <root>.Bar & Any}
+            GET_VAR 'arg: kotlin.Any declared in <root>.Bar.test' type=kotlin.Any origin=null
+    FUN name:useT visibility:public modality:FINAL <> ($this:<root>.Bar<T of <root>.Bar>, t:T of <root>.Bar) returnType:kotlin.Unit
+      $this: VALUE_PARAMETER name:<this> type:<root>.Bar<T of <root>.Bar>
+      VALUE_PARAMETER name:t index:0 type:T of <root>.Bar
+      BLOCK_BODY
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
diff --git a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.kt.txt b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.kt.txt
new file mode 100644
index 0000000..19fce2f
--- /dev/null
+++ b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.kt.txt
@@ -0,0 +1,35 @@
+inline fun <reified T : Any> Any.test1(): T? {
+  return when {
+    <this> is T -> <this> /*as T */
+    else -> null
+  }
+}
+
+interface Foo<T : Any?> {
+
+}
+
+val <reified T : Any> Foo<T>.asT: T?
+  inline get(): T? {
+    return when {
+      <this> is T -> <this> /*as T */
+      else -> null
+    }
+  }
+
+class Bar<T : Any?> {
+  constructor() /* primary */ {
+    super/*Any*/()
+    /* <init>() */
+
+  }
+
+  fun test(arg: Any) {
+    arg as T /*~> Unit */
+    <this>.useT(t = arg /*as (T & Any) */)
+  }
+
+  fun useT(t: T) {
+  }
+
+}
diff --git a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt
index 3c87e7b..5e9a09e 100644
--- a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt
+++ b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt
@@ -1,4 +1,3 @@
-// FIR_IDENTICAL
 inline fun <reified T : Any> Any.test1(): T? =
     if (this is T) this else null
 
diff --git a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.ir.txt b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.ir.txt
index 92b291f..308100f 100644
--- a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.ir.txt
+++ b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.ir.txt
@@ -77,14 +77,14 @@
       VALUE_PARAMETER name:p0 index:0 type:@[EnhancedNullability] java.util.function.BiFunction<in @[EnhancedNullability] K of <root>.MyMap, in @[EnhancedNullability] V of <root>.MyMap, out @[EnhancedNullability] V of <root>.MyMap>
     FUN FAKE_OVERRIDE name:merge visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap<K of kotlin.collections.MutableMap, V of kotlin.collections.MutableMap>, p0:@[EnhancedNullability] K of <root>.MyMap, p1:@[EnhancedNullability] V of <root>.MyMap, p2:@[EnhancedNullability] java.util.function.BiFunction<in @[EnhancedNullability] V of <root>.MyMap, in @[EnhancedNullability] V of <root>.MyMap, out V of <root>.MyMap?>) returnType:V of <root>.MyMap? [fake_override]
       overridden:
-        public open fun merge (p0: @[EnhancedNullability] K of kotlin.collections.AbstractMutableMap, p1: @[EnhancedNullability] V of kotlin.collections.AbstractMutableMap, p2: @[EnhancedNullability] java.util.function.BiFunction<in @[EnhancedNullability] V of kotlin.collections.AbstractMutableMap, in @[EnhancedNullability] V of kotlin.collections.AbstractMutableMap, out V of kotlin.collections.AbstractMutableMap?>): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap
+        public open fun merge (p0: @[EnhancedNullability] K of kotlin.collections.AbstractMutableMap, p1: @[EnhancedNullability] {@[EnhancedNullability] V of kotlin.collections.AbstractMutableMap & Any}, p2: @[EnhancedNullability] java.util.function.BiFunction<in @[EnhancedNullability] {@[EnhancedNullability] V of kotlin.collections.AbstractMutableMap & Any}, in @[EnhancedNullability] {@[EnhancedNullability] V of kotlin.collections.AbstractMutableMap & Any}, out V of kotlin.collections.AbstractMutableMap?>): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap
       $this: VALUE_PARAMETER name:<this> type:kotlin.collections.MutableMap<K of kotlin.collections.MutableMap, V of kotlin.collections.MutableMap>
       VALUE_PARAMETER name:p0 index:0 type:@[EnhancedNullability] K of <root>.MyMap
       VALUE_PARAMETER name:p1 index:1 type:@[EnhancedNullability] V of <root>.MyMap
       VALUE_PARAMETER name:p2 index:2 type:@[EnhancedNullability] java.util.function.BiFunction<in @[EnhancedNullability] V of <root>.MyMap, in @[EnhancedNullability] V of <root>.MyMap, out V of <root>.MyMap?>
     FUN FAKE_OVERRIDE name:computeIfPresent visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap<K of kotlin.collections.MutableMap, V of kotlin.collections.MutableMap>, p0:@[EnhancedNullability] K of <root>.MyMap, p1:@[EnhancedNullability] java.util.function.BiFunction<in @[EnhancedNullability] K of <root>.MyMap, in @[EnhancedNullability] V of <root>.MyMap, out V of <root>.MyMap?>) returnType:V of <root>.MyMap? [fake_override]
       overridden:
-        public open fun computeIfPresent (p0: @[EnhancedNullability] K of kotlin.collections.AbstractMutableMap, p1: @[EnhancedNullability] java.util.function.BiFunction<in @[EnhancedNullability] K of kotlin.collections.AbstractMutableMap, in @[EnhancedNullability] V of kotlin.collections.AbstractMutableMap, out V of kotlin.collections.AbstractMutableMap?>): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap
+        public open fun computeIfPresent (p0: @[EnhancedNullability] K of kotlin.collections.AbstractMutableMap, p1: @[EnhancedNullability] java.util.function.BiFunction<in @[EnhancedNullability] K of kotlin.collections.AbstractMutableMap, in @[EnhancedNullability] {@[EnhancedNullability] V of kotlin.collections.AbstractMutableMap & Any}, out V of kotlin.collections.AbstractMutableMap?>): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap
       $this: VALUE_PARAMETER name:<this> type:kotlin.collections.MutableMap<K of kotlin.collections.MutableMap, V of kotlin.collections.MutableMap>
       VALUE_PARAMETER name:p0 index:0 type:@[EnhancedNullability] K of <root>.MyMap
       VALUE_PARAMETER name:p1 index:1 type:@[EnhancedNullability] java.util.function.BiFunction<in @[EnhancedNullability] K of <root>.MyMap, in @[EnhancedNullability] V of <root>.MyMap, out V of <root>.MyMap?>
diff --git a/compiler/testData/ir/irText/types/definitelyNonNull.fir.ir.txt b/compiler/testData/ir/irText/types/definitelyNonNull.fir.ir.txt
new file mode 100644
index 0000000..802ae35
--- /dev/null
+++ b/compiler/testData/ir/irText/types/definitelyNonNull.fir.ir.txt
@@ -0,0 +1,45 @@
+FILE fqName:<root> fileName:/definitelyNonNull.kt
+  FUN name:elvisLike visibility:public modality:FINAL <T> (x:T of <root>.elvisLike, y:{T of <root>.elvisLike & Any}) returnType:{T of <root>.elvisLike & Any}
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    VALUE_PARAMETER name:x index:0 type:T of <root>.elvisLike
+    VALUE_PARAMETER name:y index:1 type:{T of <root>.elvisLike & Any}
+    BLOCK_BODY
+      RETURN type=kotlin.Nothing from='public final fun elvisLike <T> (x: T of <root>.elvisLike, y: {T of <root>.elvisLike & Any}): {T of <root>.elvisLike & Any} declared in <root>'
+        BLOCK type={T of <root>.elvisLike & Any} origin=ELVIS
+          VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:T of <root>.elvisLike [val]
+            GET_VAR 'x: T of <root>.elvisLike declared in <root>.elvisLike' type=T of <root>.elvisLike origin=null
+          WHEN type={T of <root>.elvisLike & Any} origin=ELVIS
+            BRANCH
+              if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
+                arg0: GET_VAR 'val tmp_0: T of <root>.elvisLike [val] declared in <root>.elvisLike' type=T of <root>.elvisLike origin=null
+                arg1: CONST Null type=kotlin.Nothing? value=null
+              then: GET_VAR 'y: {T of <root>.elvisLike & Any} declared in <root>.elvisLike' type={T of <root>.elvisLike & Any} origin=null
+            BRANCH
+              if: CONST Boolean type=kotlin.Boolean value=true
+              then: GET_VAR 'val tmp_0: T of <root>.elvisLike [val] declared in <root>.elvisLike' type=T of <root>.elvisLike origin=null
+  FUN name:main visibility:public modality:FINAL <> () returnType:kotlin.Unit
+    BLOCK_BODY
+      TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
+        CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
+          $this: CALL 'public final fun elvisLike <T> (x: T of <root>.elvisLike, y: {T of <root>.elvisLike & Any}): {T of <root>.elvisLike & Any} declared in <root>' type=kotlin.String origin=null
+            <T>: kotlin.String
+            x: CONST String type=kotlin.String value=""
+            y: CONST String type=kotlin.String value=""
+      TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
+        CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
+          $this: CALL 'public final fun elvisLike <T> (x: T of <root>.elvisLike, y: {T of <root>.elvisLike & Any}): {T of <root>.elvisLike & Any} declared in <root>' type=kotlin.String origin=null
+            <T>: kotlin.String?
+            x: CONST Null type=kotlin.Nothing? value=null
+            y: CONST String type=kotlin.String value=""
+      TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
+        CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
+          $this: CALL 'public final fun elvisLike <T> (x: T of <root>.elvisLike, y: {T of <root>.elvisLike & Any}): {T of <root>.elvisLike & Any} declared in <root>' type=kotlin.String origin=null
+            <T>: kotlin.String
+            x: CONST String type=kotlin.String value=""
+            y: CONST String type=kotlin.String value=""
+      TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
+        CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
+          $this: CALL 'public final fun elvisLike <T> (x: T of <root>.elvisLike, y: {T of <root>.elvisLike & Any}): {T of <root>.elvisLike & Any} declared in <root>' type=kotlin.String origin=null
+            <T>: kotlin.String?
+            x: CONST Null type=kotlin.Nothing? value=null
+            y: CONST String type=kotlin.String value=""
diff --git a/compiler/testData/ir/irText/types/definitelyNonNull.fir.kt.txt b/compiler/testData/ir/irText/types/definitelyNonNull.fir.kt.txt
new file mode 100644
index 0000000..d44e7cc
--- /dev/null
+++ b/compiler/testData/ir/irText/types/definitelyNonNull.fir.kt.txt
@@ -0,0 +1,17 @@
+fun <T : Any?> elvisLike(x: T, y: (T & Any)): (T & Any) {
+  return { // BLOCK
+    val <elvis>: T = x
+    when {
+      EQEQ(arg0 = <elvis>, arg1 = null) -> y
+      else -> <elvis>
+    }
+  }
+}
+
+fun main() {
+  elvisLike<String>(x = "", y = "").<get-length>() /*~> Unit */
+  elvisLike<String?>(x = null, y = "").<get-length>() /*~> Unit */
+  elvisLike<String>(x = "", y = "").<get-length>() /*~> Unit */
+  elvisLike<String?>(x = null, y = "").<get-length>() /*~> Unit */
+}
+
diff --git a/compiler/testData/ir/irText/types/definitelyNonNull.kt b/compiler/testData/ir/irText/types/definitelyNonNull.kt
index 7ea0762..32abde4 100644
--- a/compiler/testData/ir/irText/types/definitelyNonNull.kt
+++ b/compiler/testData/ir/irText/types/definitelyNonNull.kt
@@ -1,5 +1,4 @@
 //!LANGUAGE: +DefinitelyNonNullableTypes
-// IGNORE_BACKEND_FIR: ANY
 
 fun <T> elvisLike(x: T, y: T & Any): T & Any = x ?: y
 
diff --git a/compiler/testData/ir/irText/types/definitelyNonNullOverride.fir.ir.txt b/compiler/testData/ir/irText/types/definitelyNonNullOverride.fir.ir.txt
new file mode 100644
index 0000000..ebeb170
--- /dev/null
+++ b/compiler/testData/ir/irText/types/definitelyNonNullOverride.fir.ir.txt
@@ -0,0 +1,83 @@
+FILE fqName:<root> fileName:/definitelyNonNullOverride.kt
+  CLASS CLASS name:B modality:OPEN visibility:public superTypes:[kotlin.Any]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B<T of <root>.B>
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    CONSTRUCTOR visibility:public <> () returnType:<root>.B<T of <root>.B> [primary]
+      BLOCK_BODY
+        DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
+        INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:OPEN visibility:public superTypes:[kotlin.Any]'
+    FUN name:foo visibility:public modality:OPEN <> ($this:<root>.B<T of <root>.B>, t:T of <root>.B) returnType:kotlin.Unit
+      $this: VALUE_PARAMETER name:<this> type:<root>.B<T of <root>.B>
+      VALUE_PARAMETER name:t index:0 type:T of <root>.B
+      BLOCK_BODY
+    FUN name:bar visibility:public modality:OPEN <> ($this:<root>.B<T of <root>.B>, t:T of <root>.B) returnType:kotlin.Unit
+      $this: VALUE_PARAMETER name:<this> type:<root>.B<T of <root>.B>
+      VALUE_PARAMETER name:t index:0 type:T of <root>.B
+      BLOCK_BODY
+    FUN name:qux visibility:public modality:OPEN <> ($this:<root>.B<T of <root>.B>, b:<root>.B<T of <root>.B>) returnType:kotlin.Unit
+      $this: VALUE_PARAMETER name:<this> type:<root>.B<T of <root>.B>
+      VALUE_PARAMETER name:b index:0 type:<root>.B<T of <root>.B>
+      BLOCK_BODY
+    FUN name:six visibility:public modality:OPEN <F> ($this:<root>.B<T of <root>.B>, t:T of <root>.B, q:F of <root>.B.six) returnType:kotlin.Unit
+      TYPE_PARAMETER name:F index:0 variance: superTypes:[kotlin.Any?]
+      $this: VALUE_PARAMETER name:<this> type:<root>.B<T of <root>.B>
+      VALUE_PARAMETER name:t index:0 type:T of <root>.B
+      VALUE_PARAMETER name:q index:1 type:F of <root>.B.six
+      BLOCK_BODY
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+  CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.B<{T of <root>.D & Any}>]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D<T of <root>.D>
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    CONSTRUCTOR visibility:public <> () returnType:<root>.D<T of <root>.D> [primary]
+      BLOCK_BODY
+        DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.B'
+          <T>: {T of <root>.D & Any}
+        INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.B<{T of <root>.D & Any}>]'
+    FUN name:foo visibility:public modality:FINAL <> ($this:<root>.D<T of <root>.D>, t:{T of <root>.D & Any}) returnType:kotlin.Unit
+      overridden:
+        public open fun foo (t: T of <root>.B): kotlin.Unit declared in <root>.B
+      $this: VALUE_PARAMETER name:<this> type:<root>.D<T of <root>.D>
+      VALUE_PARAMETER name:t index:0 type:{T of <root>.D & Any}
+      BLOCK_BODY
+    FUN FAKE_OVERRIDE name:bar visibility:public modality:OPEN <> ($this:<root>.B<T of <root>.B>, t:{T of <root>.D & Any}) returnType:kotlin.Unit [fake_override]
+      overridden:
+        public open fun bar (t: T of <root>.B): kotlin.Unit declared in <root>.B
+      $this: VALUE_PARAMETER name:<this> type:<root>.B<T of <root>.B>
+      VALUE_PARAMETER name:t index:0 type:{T of <root>.D & Any}
+    FUN FAKE_OVERRIDE name:qux visibility:public modality:OPEN <> ($this:<root>.B<T of <root>.B>, b:<root>.B<{T of <root>.D & Any}>) returnType:kotlin.Unit [fake_override]
+      overridden:
+        public open fun qux (b: <root>.B<T of <root>.B>): kotlin.Unit declared in <root>.B
+      $this: VALUE_PARAMETER name:<this> type:<root>.B<T of <root>.B>
+      VALUE_PARAMETER name:b index:0 type:<root>.B<{T of <root>.D & Any}>
+    FUN FAKE_OVERRIDE name:six visibility:public modality:OPEN <F> ($this:<root>.B<T of <root>.B>, t:{T of <root>.D & Any}, q:F of <root>.D.six) returnType:kotlin.Unit [fake_override]
+      overridden:
+        public open fun six <F> (t: T of <root>.B, q: F of <root>.B.six): kotlin.Unit declared in <root>.B
+      TYPE_PARAMETER name:F index:0 variance: superTypes:[kotlin.Any?]
+      $this: VALUE_PARAMETER name:<this> type:<root>.B<T of <root>.B>
+      VALUE_PARAMETER name:t index:0 type:{T of <root>.D & Any}
+      VALUE_PARAMETER name:q index:1 type:F of <root>.D.six
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.B
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.B
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String [fake_override] declared in <root>.B
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
diff --git a/compiler/testData/ir/irText/types/definitelyNonNullOverride.kt b/compiler/testData/ir/irText/types/definitelyNonNullOverride.kt
index d7c4e29..c1b5894 100644
--- a/compiler/testData/ir/irText/types/definitelyNonNullOverride.kt
+++ b/compiler/testData/ir/irText/types/definitelyNonNullOverride.kt
@@ -1,5 +1,4 @@
 //!LANGUAGE: +DefinitelyNonNullableTypes
-// IGNORE_BACKEND_FIR: ANY
 // SKIP_KT_DUMP
 
 open class B<T> {
diff --git a/compiler/testData/ir/irText/types/definitelyNonNullSAM.fir.ir.txt b/compiler/testData/ir/irText/types/definitelyNonNullSAM.fir.ir.txt
new file mode 100644
index 0000000..63d6a72
--- /dev/null
+++ b/compiler/testData/ir/irText/types/definitelyNonNullSAM.fir.ir.txt
@@ -0,0 +1,223 @@
+FILE fqName:<root> fileName:/definitelyNonNullSAM.kt
+  CLASS INTERFACE name:FIn modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.FIn<T of <root>.FIn>
+    TYPE_PARAMETER name:T index:0 variance:in superTypes:[kotlin.Any?]
+    FUN name:f visibility:public modality:ABSTRACT <> ($this:<root>.FIn<T of <root>.FIn>, x:T of <root>.FIn) returnType:kotlin.Unit
+      $this: VALUE_PARAMETER name:<this> type:<root>.FIn<T of <root>.FIn>
+      VALUE_PARAMETER name:x index:0 type:T of <root>.FIn
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+  CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test<S of <root>.Test>
+    TYPE_PARAMETER name:S index:0 variance: superTypes:[kotlin.Any?]
+    CONSTRUCTOR visibility:public <> () returnType:<root>.Test<S of <root>.Test> [primary]
+      BLOCK_BODY
+        DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
+        INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any]'
+    FUN name:foo visibility:public modality:FINAL <> ($this:<root>.Test<S of <root>.Test>) returnType:<root>.FIn<{S of <root>.Test & Any}>
+      $this: VALUE_PARAMETER name:<this> type:<root>.Test<S of <root>.Test>
+      BLOCK_BODY
+        RETURN type=kotlin.Nothing from='public final fun foo (): <root>.FIn<{S of <root>.Test & Any}> declared in <root>.Test'
+          TYPE_OP type=<root>.FIn<{S of <root>.Test & Any}> origin=SAM_CONVERSION typeOperand=<root>.FIn<{S of <root>.Test & Any}>
+            FUN_EXPR type=kotlin.Function1<{S of <root>.Test & Any}, kotlin.Unit> origin=LAMBDA
+              FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (sx:{S of <root>.Test & Any}) returnType:kotlin.Unit
+                VALUE_PARAMETER name:sx index:0 type:{S of <root>.Test & Any}
+                BLOCK_BODY
+                  TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
+                    CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
+                      $this: GET_VAR 'sx: {S of <root>.Test & Any} declared in <root>.Test.foo.<anonymous>' type={S of <root>.Test & Any} origin=null
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+  FUN name:bar visibility:public modality:FINAL <T> () returnType:kotlin.Unit
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    BLOCK_BODY
+      TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
+        BLOCK type=<root>.bar.<no name provided><T of <root>.bar> origin=OBJECT_LITERAL
+          CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.FIn<{T of <root>.bar & Any}>]
+            $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.bar.<no name provided><T of <root>.bar>
+            CONSTRUCTOR visibility:private <> () returnType:<root>.bar.<no name provided><T of <root>.bar> [primary]
+              BLOCK_BODY
+                DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
+                INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.FIn<{T of <root>.bar & Any}>]'
+            FUN name:f visibility:public modality:FINAL <> ($this:<root>.bar.<no name provided><T of <root>.bar>, sx:{T of <root>.bar & Any}) returnType:kotlin.Unit
+              overridden:
+                public abstract fun f (x: T of <root>.FIn): kotlin.Unit declared in <root>.FIn
+              $this: VALUE_PARAMETER name:<this> type:<root>.bar.<no name provided><T of <root>.bar>
+              VALUE_PARAMETER name:sx index:0 type:{T of <root>.bar & Any}
+              BLOCK_BODY
+                TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
+                  CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
+                    $this: GET_VAR 'sx: {T of <root>.bar & Any} declared in <root>.bar.<no name provided>.f' type={T of <root>.bar & Any} origin=null
+            FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+              overridden:
+                public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.FIn
+              $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+              VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+            FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+              overridden:
+                public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.FIn
+              $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+            FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+              overridden:
+                public open fun toString (): kotlin.String [fake_override] declared in <root>.FIn
+              $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+          CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.bar.<no name provided>' type=<root>.bar.<no name provided><T of <root>.bar> origin=OBJECT_LITERAL
+  CLASS INTERFACE name:I1 modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.I1<T of <root>.I1>
+    TYPE_PARAMETER name:T index:0 variance:in superTypes:[kotlin.Any?]
+    PROPERTY name:l visibility:public modality:ABSTRACT [val]
+      FUN DEFAULT_PROPERTY_ACCESSOR name:<get-l> visibility:public modality:ABSTRACT <> ($this:<root>.I1<T of <root>.I1>) returnType:@[ExtensionFunctionType] kotlin.Function1<T of <root>.I1, kotlin.Unit>
+        correspondingProperty: PROPERTY name:l visibility:public modality:ABSTRACT [val]
+        $this: VALUE_PARAMETER name:<this> type:<root>.I1<T of <root>.I1>
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+  CLASS INTERFACE name:I2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.I2<T of <root>.I2>
+    TYPE_PARAMETER name:T index:0 variance:in superTypes:[kotlin.Any?]
+    PROPERTY name:sam visibility:public modality:ABSTRACT [val]
+      FUN DEFAULT_PROPERTY_ACCESSOR name:<get-sam> visibility:public modality:ABSTRACT <> ($this:<root>.I2<T of <root>.I2>) returnType:<root>.FIn<T of <root>.I2>
+        correspondingProperty: PROPERTY name:sam visibility:public modality:ABSTRACT [val]
+        $this: VALUE_PARAMETER name:<this> type:<root>.I2<T of <root>.I2>
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+  CLASS CLASS name:AC modality:ABSTRACT visibility:public superTypes:[<root>.I1<T of <root>.AC>; <root>.I2<T of <root>.AC>]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.AC<T of <root>.AC>
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    CONSTRUCTOR visibility:public <> () returnType:<root>.AC<T of <root>.AC> [primary]
+      BLOCK_BODY
+        DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
+        INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:AC modality:ABSTRACT visibility:public superTypes:[<root>.I1<T of <root>.AC>; <root>.I2<T of <root>.AC>]'
+    PROPERTY name:sam visibility:public modality:OPEN [val]
+      overridden:
+        public abstract sam: <root>.FIn<T of <root>.I2> [val]
+      FIELD PROPERTY_BACKING_FIELD name:sam type:<root>.FIn<T of <root>.AC> visibility:private [final]
+        EXPRESSION_BODY
+          TYPE_OP type=<root>.FIn<T of <root>.AC> origin=SAM_CONVERSION typeOperand=<root>.FIn<T of <root>.AC>
+            CALL 'public abstract fun <get-l> (): @[ExtensionFunctionType] kotlin.Function1<T of <root>.AC, kotlin.Unit> [fake_override] declared in <root>.AC' type=@[ExtensionFunctionType] kotlin.Function1<T of <root>.AC, kotlin.Unit> origin=GET_PROPERTY
+              $this: GET_VAR '<this>: <root>.AC<T of <root>.AC> declared in <root>.AC' type=<root>.AC<T of <root>.AC> origin=null
+      FUN DEFAULT_PROPERTY_ACCESSOR name:<get-sam> visibility:public modality:OPEN <> ($this:<root>.AC<T of <root>.AC>) returnType:<root>.FIn<T of <root>.AC>
+        correspondingProperty: PROPERTY name:sam visibility:public modality:OPEN [val]
+        overridden:
+          public abstract fun <get-sam> (): <root>.FIn<T of <root>.I2> declared in <root>.I2
+        $this: VALUE_PARAMETER name:<this> type:<root>.AC<T of <root>.AC>
+        BLOCK_BODY
+          RETURN type=kotlin.Nothing from='public open fun <get-sam> (): <root>.FIn<T of <root>.AC> declared in <root>.AC'
+            GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:sam type:<root>.FIn<T of <root>.AC> visibility:private [final]' type=<root>.FIn<T of <root>.AC> origin=null
+              receiver: GET_VAR '<this>: <root>.AC<T of <root>.AC> declared in <root>.AC.<get-sam>' type=<root>.AC<T of <root>.AC> origin=null
+    PROPERTY FAKE_OVERRIDE name:l visibility:public modality:ABSTRACT [fake_override,val]
+      overridden:
+        public abstract l: @[ExtensionFunctionType] kotlin.Function1<T of <root>.I1, kotlin.Unit> [val]
+      FUN FAKE_OVERRIDE name:<get-l> visibility:public modality:ABSTRACT <> ($this:<root>.I1<T of <root>.I1>) returnType:@[ExtensionFunctionType] kotlin.Function1<T of <root>.AC, kotlin.Unit> [fake_override]
+        correspondingProperty: PROPERTY FAKE_OVERRIDE name:l visibility:public modality:ABSTRACT [fake_override,val]
+        overridden:
+          public abstract fun <get-l> (): @[ExtensionFunctionType] kotlin.Function1<T of <root>.I1, kotlin.Unit> declared in <root>.I1
+        $this: VALUE_PARAMETER name:<this> type:<root>.I1<T of <root>.I1>
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.I1
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.I2
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.I1
+        public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.I2
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String [fake_override] declared in <root>.I1
+        public open fun toString (): kotlin.String [fake_override] declared in <root>.I2
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+  CLASS CLASS name:AD modality:ABSTRACT visibility:public superTypes:[<root>.AC<{T of <root>.AD & Any}>]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.AD<T of <root>.AD>
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    CONSTRUCTOR visibility:public <> () returnType:<root>.AD<T of <root>.AD> [primary]
+      BLOCK_BODY
+        DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.AC'
+          <T>: {T of <root>.AD & Any}
+        INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:AD modality:ABSTRACT visibility:public superTypes:[<root>.AC<{T of <root>.AD & Any}>]'
+    PROPERTY name:l visibility:public modality:OPEN [val]
+      overridden:
+        public abstract l: @[ExtensionFunctionType] kotlin.Function1<T of <root>.AC, kotlin.Unit> [fake_override,val]
+      FIELD PROPERTY_BACKING_FIELD name:l type:@[ExtensionFunctionType] kotlin.Function1<{T of <root>.AD & Any}, kotlin.Unit> visibility:private [final]
+        EXPRESSION_BODY
+          FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<{T of <root>.AD & Any}, kotlin.Unit> origin=LAMBDA
+            FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:{T of <root>.AD & Any}) returnType:kotlin.Unit
+              $receiver: VALUE_PARAMETER name:<this> type:{T of <root>.AD & Any}
+              BLOCK_BODY
+                RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Unit declared in <root>.AD.l'
+                  GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
+      FUN DEFAULT_PROPERTY_ACCESSOR name:<get-l> visibility:public modality:OPEN <> ($this:<root>.AD<T of <root>.AD>) returnType:@[ExtensionFunctionType] kotlin.Function1<{T of <root>.AD & Any}, kotlin.Unit>
+        correspondingProperty: PROPERTY name:l visibility:public modality:OPEN [val]
+        overridden:
+          public abstract fun <get-l> (): @[ExtensionFunctionType] kotlin.Function1<T of <root>.AC, kotlin.Unit> [fake_override] declared in <root>.AC
+        $this: VALUE_PARAMETER name:<this> type:<root>.AD<T of <root>.AD>
+        BLOCK_BODY
+          RETURN type=kotlin.Nothing from='public open fun <get-l> (): @[ExtensionFunctionType] kotlin.Function1<{T of <root>.AD & Any}, kotlin.Unit> declared in <root>.AD'
+            GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:l type:@[ExtensionFunctionType] kotlin.Function1<{T of <root>.AD & Any}, kotlin.Unit> visibility:private [final]' type=@[ExtensionFunctionType] kotlin.Function1<{T of <root>.AD & Any}, kotlin.Unit> origin=null
+              receiver: GET_VAR '<this>: <root>.AD<T of <root>.AD> declared in <root>.AD.<get-l>' type=<root>.AD<T of <root>.AD> origin=null
+    PROPERTY FAKE_OVERRIDE name:sam visibility:public modality:OPEN [fake_override,val]
+      overridden:
+        public open sam: <root>.FIn<T of <root>.AC> [val]
+      FUN FAKE_OVERRIDE name:<get-sam> visibility:public modality:OPEN <> ($this:<root>.AC<T of <root>.AC>) returnType:<root>.FIn<{T of <root>.AD & Any}> [fake_override]
+        correspondingProperty: PROPERTY FAKE_OVERRIDE name:sam visibility:public modality:OPEN [fake_override,val]
+        overridden:
+          public open fun <get-sam> (): <root>.FIn<T of <root>.AC> declared in <root>.AC
+        $this: VALUE_PARAMETER name:<this> type:<root>.AC<T of <root>.AC>
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.AC
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.AC
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String [fake_override] declared in <root>.AC
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
diff --git a/compiler/testData/ir/irText/types/definitelyNonNullSAM.kt b/compiler/testData/ir/irText/types/definitelyNonNullSAM.kt
index 1d93c4c..86d3aa7 100644
--- a/compiler/testData/ir/irText/types/definitelyNonNullSAM.kt
+++ b/compiler/testData/ir/irText/types/definitelyNonNullSAM.kt
@@ -1,5 +1,4 @@
 //!LANGUAGE: +DefinitelyNonNullableTypes
-// IGNORE_BACKEND_FIR: ANY
 // SKIP_KT_DUMP
 
 fun interface FIn<in T> {
diff --git a/compiler/testData/ir/irText/types/definitelyNonNullWithJava.fir.ir.txt b/compiler/testData/ir/irText/types/definitelyNonNullWithJava.fir.ir.txt
new file mode 100644
index 0000000..e776882
--- /dev/null
+++ b/compiler/testData/ir/irText/types/definitelyNonNullWithJava.fir.ir.txt
@@ -0,0 +1,27 @@
+FILE fqName:<root> fileName:/main.kt
+  CLASS INTERFACE name:B modality:ABSTRACT visibility:public superTypes:[<root>.A<T1 of <root>.B>]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B<T1 of <root>.B>
+    TYPE_PARAMETER name:T1 index:0 variance: superTypes:[kotlin.Any?]
+    FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.B<T1 of <root>.B>, x:T1 of <root>.B) returnType:T1 of <root>.B
+      overridden:
+        public abstract fun foo (x: @[FlexibleNullability] T of <root>.A?): @[FlexibleNullability] T of <root>.A? declared in <root>.A
+      $this: VALUE_PARAMETER name:<this> type:<root>.B<T1 of <root>.B>
+      VALUE_PARAMETER name:x index:0 type:T1 of <root>.B
+    FUN name:bar visibility:public modality:ABSTRACT <> ($this:<root>.B<T1 of <root>.B>, x:{T1 of <root>.B & Any}) returnType:{T1 of <root>.B & Any}
+      overridden:
+        public abstract fun bar (x: @[EnhancedNullability] {@[EnhancedNullability] T of <root>.A & Any}): @[EnhancedNullability] {@[EnhancedNullability] T of <root>.A & Any} declared in <root>.A
+      $this: VALUE_PARAMETER name:<this> type:<root>.B<T1 of <root>.B>
+      VALUE_PARAMETER name:x index:0 type:{T1 of <root>.B & Any}
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.A
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.A
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String [fake_override] declared in <root>.A
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
diff --git a/compiler/testData/ir/irText/types/definitelyNonNullWithJava.fir.kt.txt b/compiler/testData/ir/irText/types/definitelyNonNullWithJava.fir.kt.txt
new file mode 100644
index 0000000..2e4d12b
--- /dev/null
+++ b/compiler/testData/ir/irText/types/definitelyNonNullWithJava.fir.kt.txt
@@ -0,0 +1,5 @@
+interface B<T1 : Any?> : A<T1> {
+  abstract override fun foo(x: T1): T1
+  abstract override fun bar(x: (T1 & Any)): (T1 & Any)
+
+}
diff --git a/compiler/testData/ir/irText/types/definitelyNonNullWithJava.kt b/compiler/testData/ir/irText/types/definitelyNonNullWithJava.kt
index 1732d95..5540319 100644
--- a/compiler/testData/ir/irText/types/definitelyNonNullWithJava.kt
+++ b/compiler/testData/ir/irText/types/definitelyNonNullWithJava.kt
@@ -1,6 +1,5 @@
 //!LANGUAGE: +DefinitelyNonNullableTypes
 // TARGET_BACKEND: JVM
-// IGNORE_BACKEND_FIR: ANY
 
 // FILE: A.java
 import org.jetbrains.annotations.*;
diff --git a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.ir.txt b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.ir.txt
new file mode 100644
index 0000000..abf8b65
--- /dev/null
+++ b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.ir.txt
@@ -0,0 +1,95 @@
+FILE fqName:<root> fileName:/definitelyNotNullAsArgument.kt
+  CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.I<T of <root>.I>
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    FUN name:input visibility:public modality:ABSTRACT <> ($this:<root>.I<T of <root>.I>, t:T of <root>.I) returnType:kotlin.Unit
+      $this: VALUE_PARAMETER name:<this> type:<root>.I<T of <root>.I>
+      VALUE_PARAMETER name:t index:0 type:T of <root>.I
+    FUN name:output visibility:public modality:ABSTRACT <> ($this:<root>.I<T of <root>.I>) returnType:T of <root>.I
+      $this: VALUE_PARAMETER name:<this> type:<root>.I<T of <root>.I>
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+  FUN name:foo visibility:public modality:FINAL <T> (i:<root>.I<{T of <root>.foo & Any}>) returnType:kotlin.Unit
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    VALUE_PARAMETER name:i index:0 type:<root>.I<{T of <root>.foo & Any}>
+    BLOCK_BODY
+      CALL 'public abstract fun input (t: T of <root>.I): kotlin.Unit declared in <root>.I' type=kotlin.Unit origin=null
+        $this: GET_VAR 'i: <root>.I<{T of <root>.foo & Any}> declared in <root>.foo' type=<root>.I<{T of <root>.foo & Any}> origin=null
+        t: CALL 'public abstract fun output (): T of <root>.I declared in <root>.I' type={T of <root>.foo & Any} origin=null
+          $this: GET_VAR 'i: <root>.I<{T of <root>.foo & Any}> declared in <root>.foo' type=<root>.I<{T of <root>.foo & Any}> origin=null
+  FUN name:bar visibility:public modality:FINAL <T> (i:<root>.I<out {T of <root>.bar & Any}>) returnType:{T of <root>.bar & Any}
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    VALUE_PARAMETER name:i index:0 type:<root>.I<out {T of <root>.bar & Any}>
+    BLOCK_BODY
+      RETURN type=kotlin.Nothing from='public final fun bar <T> (i: <root>.I<out {T of <root>.bar & Any}>): {T of <root>.bar & Any} declared in <root>'
+        CALL 'public abstract fun output (): T of <root>.I declared in <root>.I' type={T of <root>.bar & Any} origin=null
+          $this: GET_VAR 'i: <root>.I<out {T of <root>.bar & Any}> declared in <root>.bar' type=<root>.I<out {T of <root>.bar & Any}> origin=null
+  FUN name:qux visibility:public modality:FINAL <T> (t:T of <root>.qux, i:<root>.I<in {T of <root>.qux & Any}>) returnType:kotlin.Unit
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    VALUE_PARAMETER name:t index:0 type:T of <root>.qux
+    VALUE_PARAMETER name:i index:1 type:<root>.I<in {T of <root>.qux & Any}>
+    BLOCK_BODY
+      CALL 'public abstract fun input (t: T of <root>.I): kotlin.Unit declared in <root>.I' type=kotlin.Unit origin=null
+        $this: GET_VAR 'i: <root>.I<in {T of <root>.qux & Any}> declared in <root>.qux' type=<root>.I<in {T of <root>.qux & Any}> origin=null
+        t: CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type={T of <root>.qux & Any} origin=EXCLEXCL
+          <T0>: T of <root>.qux
+          arg0: GET_VAR 't: T of <root>.qux declared in <root>.qux' type=T of <root>.qux origin=null
+  CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.I<{TT of <root>.C & Any}>]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C<TT of <root>.C>
+    TYPE_PARAMETER name:TT index:0 variance: superTypes:[kotlin.Any?]
+    CONSTRUCTOR visibility:public <> (t:TT of <root>.C) returnType:<root>.C<TT of <root>.C> [primary]
+      VALUE_PARAMETER name:t index:0 type:TT of <root>.C
+      BLOCK_BODY
+        DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
+        INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.I<{TT of <root>.C & Any}>]'
+    PROPERTY name:t visibility:public modality:FINAL [val]
+      FIELD PROPERTY_BACKING_FIELD name:t type:TT of <root>.C visibility:private [final]
+        EXPRESSION_BODY
+          GET_VAR 't: TT of <root>.C declared in <root>.C.<init>' type=TT of <root>.C origin=INITIALIZE_PROPERTY_FROM_PARAMETER
+      FUN DEFAULT_PROPERTY_ACCESSOR name:<get-t> visibility:public modality:FINAL <> ($this:<root>.C<TT of <root>.C>) returnType:TT of <root>.C
+        correspondingProperty: PROPERTY name:t visibility:public modality:FINAL [val]
+        $this: VALUE_PARAMETER name:<this> type:<root>.C<TT of <root>.C>
+        BLOCK_BODY
+          RETURN type=kotlin.Nothing from='public final fun <get-t> (): TT of <root>.C declared in <root>.C'
+            GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:t type:TT of <root>.C visibility:private [final]' type=TT of <root>.C origin=null
+              receiver: GET_VAR '<this>: <root>.C<TT of <root>.C> declared in <root>.C.<get-t>' type=<root>.C<TT of <root>.C> origin=null
+    FUN name:input visibility:public modality:FINAL <> ($this:<root>.C<TT of <root>.C>, t:{TT of <root>.C & Any}) returnType:kotlin.Unit
+      overridden:
+        public abstract fun input (t: T of <root>.I): kotlin.Unit declared in <root>.I
+      $this: VALUE_PARAMETER name:<this> type:<root>.C<TT of <root>.C>
+      VALUE_PARAMETER name:t index:0 type:{TT of <root>.C & Any}
+      BLOCK_BODY
+    FUN name:output visibility:public modality:FINAL <> ($this:<root>.C<TT of <root>.C>) returnType:{TT of <root>.C & Any}
+      overridden:
+        public abstract fun output (): T of <root>.I declared in <root>.I
+      $this: VALUE_PARAMETER name:<this> type:<root>.C<TT of <root>.C>
+      BLOCK_BODY
+        RETURN type=kotlin.Nothing from='public final fun output (): {TT of <root>.C & Any} declared in <root>.C'
+          CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type={TT of <root>.C & Any} origin=EXCLEXCL
+            <T0>: TT of <root>.C
+            arg0: CALL 'public final fun <get-t> (): TT of <root>.C declared in <root>.C' type=TT of <root>.C origin=GET_PROPERTY
+              $this: GET_VAR '<this>: <root>.C<TT of <root>.C> declared in <root>.C.output' type=<root>.C<TT of <root>.C> origin=null
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.I
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.I
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String [fake_override] declared in <root>.I
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
diff --git a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.kt.txt b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.kt.txt
new file mode 100644
index 0000000..d10d623
--- /dev/null
+++ b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.kt.txt
@@ -0,0 +1,37 @@
+interface I<T : Any?> {
+  abstract fun input(t: T)
+  abstract fun output(): T
+
+}
+
+fun <T : Any?> foo(i: I<(T & Any)>) {
+  i.input(t = i.output())
+}
+
+fun <T : Any?> bar(i: I<out (T & Any)>): (T & Any) {
+  return i.output()
+}
+
+fun <T : Any?> qux(t: T, i: I<in (T & Any)>) {
+  i.input(t = CHECK_NOT_NULL<T>(arg0 = t))
+}
+
+class C<TT : Any?> : I<(TT & Any)> {
+  constructor(t: TT) /* primary */ {
+    super/*Any*/()
+    /* <init>() */
+
+  }
+
+  val t: TT
+    field = t
+    get
+
+  override fun input(t: (TT & Any)) {
+  }
+
+  override fun output(): (TT & Any) {
+    return CHECK_NOT_NULL<TT>(arg0 = <this>.<get-t>())
+  }
+
+}
diff --git a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.kt b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.kt
index 79d74cf..9ea8017 100644
--- a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.kt
+++ b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.kt
@@ -1,5 +1,4 @@
 //!LANGUAGE: +DefinitelyNonNullableTypes
-// IGNORE_BACKEND_FIR: ANY
 
 interface I<T> {
     fun input(t: T)
diff --git a/compiler/testData/ir/irText/types/definitelyNotNullAsReceiver.kt b/compiler/testData/ir/irText/types/definitelyNotNullAsReceiver.kt
index 3e60fac..50020b8 100644
--- a/compiler/testData/ir/irText/types/definitelyNotNullAsReceiver.kt
+++ b/compiler/testData/ir/irText/types/definitelyNotNullAsReceiver.kt
@@ -1,5 +1,5 @@
+// FIR_IDENTICAL
 //!LANGUAGE: +DefinitelyNonNullableTypes
-// IGNORE_BACKEND_FIR: ANY
 
 fun <T> (T & Any).foo() {}
 fun <T> foo(l: (T & Any) -> Unit) {}
diff --git a/compiler/testData/ir/irText/types/definitelyNotNullWithIntersection1.fir.ir.txt b/compiler/testData/ir/irText/types/definitelyNotNullWithIntersection1.fir.ir.txt
new file mode 100644
index 0000000..b660d11
--- /dev/null
+++ b/compiler/testData/ir/irText/types/definitelyNotNullWithIntersection1.fir.ir.txt
@@ -0,0 +1,80 @@
+FILE fqName:<root> fileName:/definitelyNotNullWithIntersection1.kt
+  CLASS CLASS name:In modality:FINAL visibility:public superTypes:[kotlin.Any]
+    $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.In<I of <root>.In>
+    TYPE_PARAMETER name:I index:0 variance:in superTypes:[kotlin.Any?]
+    CONSTRUCTOR visibility:public <> () returnType:<root>.In<I of <root>.In> [primary]
+      BLOCK_BODY
+        DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
+        INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:In modality:FINAL visibility:public superTypes:[kotlin.Any]'
+    FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
+      overridden:
+        public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+      VALUE_PARAMETER name:other index:0 type:kotlin.Any?
+    FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
+      overridden:
+        public open fun hashCode (): kotlin.Int declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+    FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
+      overridden:
+        public open fun toString (): kotlin.String declared in kotlin.Any
+      $this: VALUE_PARAMETER name:<this> type:kotlin.Any
+  FUN name:select visibility:public modality:FINAL <S> (x:S of <root>.select, y:S of <root>.select, z:S of <root>.select) returnType:S of <root>.select
+    TYPE_PARAMETER name:S index:0 variance: superTypes:[kotlin.Any?]
+    VALUE_PARAMETER name:x index:0 type:S of <root>.select
+    VALUE_PARAMETER name:y index:1 type:S of <root>.select
+    VALUE_PARAMETER name:z index:2 type:S of <root>.select
+    BLOCK_BODY
+      RETURN type=kotlin.Nothing from='public final fun select <S> (x: S of <root>.select, y: S of <root>.select, z: S of <root>.select): S of <root>.select declared in <root>'
+        GET_VAR 'x: S of <root>.select declared in <root>.select' type=S of <root>.select origin=null
+  FUN name:foo visibility:public modality:FINAL <T> (a:kotlin.Array<<root>.In<{T of <root>.foo & Any}>>, b:kotlin.Array<<root>.In<kotlin.String>>, c:kotlin.Array<<root>.In<T of <root>.foo>>) returnType:kotlin.Boolean
+    TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
+    VALUE_PARAMETER name:a index:0 type:kotlin.Array<<root>.In<{T of <root>.foo & Any}>>
+    VALUE_PARAMETER name:b index:1 type:kotlin.Array<<root>.In<kotlin.String>>
+    VALUE_PARAMETER name:c index:2 type:kotlin.Array<<root>.In<T of <root>.foo>>
+    BLOCK_BODY
+      RETURN type=kotlin.Nothing from='public final fun foo <T> (a: kotlin.Array<<root>.In<{T of <root>.foo & Any}>>, b: kotlin.Array<<root>.In<kotlin.String>>, c: kotlin.Array<<root>.In<T of <root>.foo>>): kotlin.Boolean declared in <root>'
+        CALL 'public final fun ofType <K> (y: kotlin.Any?): kotlin.Boolean [inline] declared in <root>' type=kotlin.Boolean origin=null
+          <K>: kotlin.Any
+          $receiver: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=<root>.In<kotlin.Nothing> origin=null
+            $this: CALL 'public final fun select <S> (x: S of <root>.select, y: S of <root>.select, z: S of <root>.select): S of <root>.select declared in <root>' type=kotlin.Array<out <root>.In<kotlin.Nothing>> origin=null
+              <S>: kotlin.Array<out <root>.In<kotlin.Nothing>>
+              x: GET_VAR 'a: kotlin.Array<<root>.In<{T of <root>.foo & Any}>> declared in <root>.foo' type=kotlin.Array<<root>.In<{T of <root>.foo & Any}>> origin=null
+              y: GET_VAR 'b: kotlin.Array<<root>.In<kotlin.String>> declared in <root>.foo' type=kotlin.Array<<root>.In<kotlin.String>> origin=null
+              z: GET_VAR 'c: kotlin.Array<<root>.In<T of <root>.foo>> declared in <root>.foo' type=kotlin.Array<<root>.In<T of <root>.foo>> origin=null
+            index: CONST Int type=kotlin.Int value=0
+          y: CONST Boolean type=kotlin.Boolean value=true
+  FUN name:ofType visibility:public modality:FINAL <K> ($receiver:<root>.In<K of <root>.ofType>, y:kotlin.Any?) returnType:kotlin.Boolean [inline]
+    TYPE_PARAMETER name:K index:0 variance: superTypes:[kotlin.Any?]
+    $receiver: VALUE_PARAMETER name:<this> type:<root>.In<K of <root>.ofType>
+    VALUE_PARAMETER name:y index:0 type:kotlin.Any?
+    BLOCK_BODY
+      RETURN type=kotlin.Nothing from='public final fun ofType <K> (y: kotlin.Any?): kotlin.Boolean [inline] declared in <root>'
+        TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=K of <root>.ofType
+          GET_VAR 'y: kotlin.Any? declared in <root>.ofType' type=kotlin.Any? origin=null
+  FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
+    BLOCK_BODY
+      VAR name:a1 type:kotlin.Array<<root>.In<kotlin.Int>> [val]
+        CALL 'public final fun arrayOf <T> (vararg elements: T of kotlin.arrayOf): kotlin.Array<T of kotlin.arrayOf> [inline] declared in kotlin' type=kotlin.Array<<root>.In<kotlin.Int>> origin=null
+          <T>: <root>.In<kotlin.Int>
+          elements: VARARG type=kotlin.Array<out <root>.In<kotlin.Int>> varargElementType=<root>.In<kotlin.Int>
+            CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.In' type=<root>.In<kotlin.Int> origin=null
+              <class: I>: kotlin.Int
+      VAR name:a2 type:kotlin.Array<<root>.In<kotlin.String>> [val]
+        CALL 'public final fun arrayOf <T> (vararg elements: T of kotlin.arrayOf): kotlin.Array<T of kotlin.arrayOf> [inline] declared in kotlin' type=kotlin.Array<<root>.In<kotlin.String>> origin=null
+          <T>: <root>.In<kotlin.String>
+          elements: VARARG type=kotlin.Array<out <root>.In<kotlin.String>> varargElementType=<root>.In<kotlin.String>
+            CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.In' type=<root>.In<kotlin.String> origin=null
+              <class: I>: kotlin.String
+      VAR name:a3 type:kotlin.Array<<root>.In<kotlin.Int>> [val]
+        CALL 'public final fun arrayOf <T> (vararg elements: T of kotlin.arrayOf): kotlin.Array<T of kotlin.arrayOf> [inline] declared in kotlin' type=kotlin.Array<<root>.In<kotlin.Int>> origin=null
+          <T>: <root>.In<kotlin.Int>
+          elements: VARARG type=kotlin.Array<out <root>.In<kotlin.Int>> varargElementType=<root>.In<kotlin.Int>
+            CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.In' type=<root>.In<kotlin.Int> origin=null
+              <class: I>: kotlin.Int
+      TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
+        CALL 'public final fun foo <T> (a: kotlin.Array<<root>.In<{T of <root>.foo & Any}>>, b: kotlin.Array<<root>.In<kotlin.String>>, c: kotlin.Array<<root>.In<T of <root>.foo>>): kotlin.Boolean declared in <root>' type=kotlin.Boolean origin=null
+          <T>: kotlin.Int
+          a: GET_VAR 'val a1: kotlin.Array<<root>.In<kotlin.Int>> [val] declared in <root>.test' type=kotlin.Array<<root>.In<kotlin.Int>> origin=null
+          b: GET_VAR 'val a2: kotlin.Array<<root>.In<kotlin.String>> [val] declared in <root>.test' type=kotlin.Array<<root>.In<kotlin.String>> origin=null
+          c: GET_VAR 'val a3: kotlin.Array<<root>.In<kotlin.Int>> [val] declared in <root>.test' type=kotlin.Array<<root>.In<kotlin.Int>> origin=null
diff --git a/compiler/testData/ir/irText/types/definitelyNotNullWithIntersection1.kt b/compiler/testData/ir/irText/types/definitelyNotNullWithIntersection1.kt
index ddbec06..f7d9adb 100644
--- a/compiler/testData/ir/irText/types/definitelyNotNullWithIntersection1.kt
+++ b/compiler/testData/ir/irText/types/definitelyNotNullWithIntersection1.kt
@@ -1,5 +1,4 @@
 //!LANGUAGE: +DefinitelyNonNullableTypes
-// IGNORE_BACKEND_FIR: ANY
 // SKIP_KT_DUMP
 
 class In<in I>
diff --git a/compiler/testData/ir/irText/types/typeCheckOnDefinitelyNotNull.kt b/compiler/testData/ir/irText/types/typeCheckOnDefinitelyNotNull.kt
index 2956883..0c8dbd5 100644
--- a/compiler/testData/ir/irText/types/typeCheckOnDefinitelyNotNull.kt
+++ b/compiler/testData/ir/irText/types/typeCheckOnDefinitelyNotNull.kt
@@ -1,5 +1,5 @@
+// FIR_IDENTICAL
 //!LANGUAGE: +DefinitelyNonNullableTypes
-// IGNORE_BACKEND_FIR: ANY
 
 fun <T> asFoo(t: T) = t as (T & Any)
 fun <T> safeAsFoo(t: T) = t as? (T & Any)