FIR tree: implement trivial expressions typing
This commit is contained in:
committed by
Mikhail Glukhikh
parent
c3632487d0
commit
9abf4062b1
+6
-3
@@ -6,12 +6,15 @@
|
||||
package org.jetbrains.kotlin.fir.expressions.impl
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.FirAbstractElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitUnitTypeRef
|
||||
|
||||
// Representation of "dummy" condition at else branch
|
||||
class FirElseIfTrueCondition(
|
||||
session: FirSession,
|
||||
psi: PsiElement?
|
||||
): FirAbstractExpression(session, psi)
|
||||
) : FirAbstractExpression(session, psi) {
|
||||
|
||||
override var typeRef: FirTypeRef = FirImplicitUnitTypeRef(session, psi)
|
||||
}
|
||||
+5
@@ -10,6 +10,9 @@ import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirReturnExpression
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitUnitTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
|
||||
class FirReturnExpressionImpl(
|
||||
@@ -23,4 +26,6 @@ class FirReturnExpressionImpl(
|
||||
result = result.transformSingle(transformer, data)
|
||||
return super<FirAbstractExpression>.transformChildren(transformer, data)
|
||||
}
|
||||
|
||||
override var typeRef: FirTypeRef = FirImplicitNothingTypeRef(session, psi)
|
||||
}
|
||||
+4
@@ -12,6 +12,8 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirThrowExpression
|
||||
import org.jetbrains.kotlin.fir.transformSingle
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitNothingTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
|
||||
class FirThrowExpressionImpl(
|
||||
@@ -23,4 +25,6 @@ class FirThrowExpressionImpl(
|
||||
exception = exception.transformSingle(transformer, data)
|
||||
return super<FirAbstractExpression>.transformChildren(transformer, data)
|
||||
}
|
||||
|
||||
override var typeRef: FirTypeRef = FirImplicitNothingTypeRef(session, psi)
|
||||
}
|
||||
+5
-3
@@ -6,11 +6,13 @@
|
||||
package org.jetbrains.kotlin.fir.expressions.impl
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.FirAbstractElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitUnitTypeRef
|
||||
|
||||
class FirUnitExpression(
|
||||
session: FirSession,
|
||||
psi: PsiElement?
|
||||
): FirAbstractExpression(session, psi)
|
||||
) : FirAbstractExpression(session, psi) {
|
||||
override var typeRef: FirTypeRef = FirImplicitUnitTypeRef(session, psi)
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
FILE fqName:<root> fileName:/bangbang.kt
|
||||
FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:IrErrorType
|
||||
FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:kotlin.Nothing
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.Any?): IrErrorType declared in <root>'
|
||||
BLOCK type=IrErrorType origin=EXCLEXCL
|
||||
RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.Any?): kotlin.Nothing declared in <root>'
|
||||
BLOCK type=kotlin.Nothing origin=EXCLEXCL
|
||||
VAR name:<bangbang> type:kotlin.Any? [val]
|
||||
GET_VAR 'a: kotlin.Any? declared in <root>.test1' type=kotlin.Any? origin=null
|
||||
WHEN type=IrErrorType origin=EXCLEXCL
|
||||
WHEN type=kotlin.Nothing origin=EXCLEXCL
|
||||
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 <bangbang>: kotlin.Any? [val] declared in <root>.test1' type=kotlin.Any? origin=null
|
||||
@@ -16,14 +16,14 @@ FILE fqName:<root> fileName:/bangbang.kt
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'val <bangbang>: kotlin.Any? [val] declared in <root>.test1' type=kotlin.Any? origin=null
|
||||
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:IrErrorType
|
||||
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:kotlin.Nothing
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.Any?): IrErrorType declared in <root>'
|
||||
BLOCK type=IrErrorType origin=EXCLEXCL
|
||||
RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.Any?): kotlin.Nothing declared in <root>'
|
||||
BLOCK type=kotlin.Nothing origin=EXCLEXCL
|
||||
VAR name:<bangbang> type:kotlin.Int [val]
|
||||
CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null
|
||||
WHEN type=IrErrorType origin=EXCLEXCL
|
||||
WHEN type=kotlin.Nothing origin=EXCLEXCL
|
||||
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 <bangbang>: kotlin.Int [val] declared in <root>.test2' type=kotlin.Int origin=null
|
||||
|
||||
+3
-3
@@ -5,14 +5,14 @@ FILE fqName:<root> fileName:/eqeqRhsConditionPossiblyAffectingLhs.kt
|
||||
RETURN type=kotlin.Nothing from='public final fun test (x: kotlin.Any): kotlin.Boolean declared in <root>'
|
||||
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.Any declared in <root>.test' type=kotlin.Any origin=null
|
||||
arg1: WHEN type=IrErrorType origin=IF
|
||||
arg1: WHEN type=kotlin.Nothing origin=IF
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=kotlin.Double
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.test' type=kotlin.Any origin=null
|
||||
then: BLOCK type=IrErrorType origin=EXCLEXCL
|
||||
then: BLOCK type=kotlin.Nothing origin=EXCLEXCL
|
||||
VAR name:<bangbang> type:kotlin.Nothing? [val]
|
||||
CONST Null type=kotlin.Nothing? value=null
|
||||
WHEN type=IrErrorType origin=EXCLEXCL
|
||||
WHEN type=kotlin.Nothing origin=EXCLEXCL
|
||||
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 <bangbang>: kotlin.Nothing? [val] declared in <root>.test' type=kotlin.Nothing? origin=null
|
||||
|
||||
+6
-6
@@ -36,11 +36,11 @@ FILE fqName:<root> fileName:/kt30020.kt
|
||||
TYPE_OP type=kotlin.collections.MutableList<kotlin.Int> origin=CAST typeOperand=kotlin.collections.MutableList<kotlin.Int>
|
||||
CALL 'public abstract fun f (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any> origin=null
|
||||
ERROR_CALL 'Unresolved reference: R|<local>/<complex-set>|' type=IrErrorType
|
||||
VAR name:<complex-set> type:IrErrorType [val]
|
||||
BLOCK type=IrErrorType origin=EXCLEXCL
|
||||
VAR name:<complex-set> type:kotlin.Nothing [val]
|
||||
BLOCK type=kotlin.Nothing origin=EXCLEXCL
|
||||
VAR name:<bangbang> type:kotlin.collections.MutableList<kotlin.Any> [val]
|
||||
CALL 'public abstract fun <get-xs> (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any> origin=null
|
||||
WHEN type=IrErrorType origin=EXCLEXCL
|
||||
WHEN type=kotlin.Nothing origin=EXCLEXCL
|
||||
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 <bangbang>: kotlin.collections.MutableList<kotlin.Any> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Any> origin=null
|
||||
@@ -51,11 +51,11 @@ FILE fqName:<root> fileName:/kt30020.kt
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'val <bangbang>: kotlin.collections.MutableList<kotlin.Any> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Any> origin=null
|
||||
ERROR_CALL 'Unresolved reference: R|<local>/<complex-set>|' type=IrErrorType
|
||||
VAR name:<complex-set> type:IrErrorType [val]
|
||||
BLOCK type=IrErrorType origin=EXCLEXCL
|
||||
VAR name:<complex-set> type:kotlin.Nothing [val]
|
||||
BLOCK type=kotlin.Nothing origin=EXCLEXCL
|
||||
VAR name:<bangbang> type:kotlin.collections.MutableList<kotlin.Any> [val]
|
||||
CALL 'public abstract fun f (): kotlin.collections.MutableList<kotlin.Any> declared in <root>.X' type=kotlin.collections.MutableList<kotlin.Any> origin=null
|
||||
WHEN type=IrErrorType origin=EXCLEXCL
|
||||
WHEN type=kotlin.Nothing origin=EXCLEXCL
|
||||
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 <bangbang>: kotlin.collections.MutableList<kotlin.Any> [val] declared in <root>.test' type=kotlin.collections.MutableList<kotlin.Any> origin=null
|
||||
|
||||
@@ -54,7 +54,7 @@ FILE fqName:<root> fileName:/nonLocalReturn.kt
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): IrErrorType declared in <root>.testLrmFoo1'
|
||||
BLOCK type=IrErrorType origin=null
|
||||
WHEN type=IrErrorType origin=IF
|
||||
WHEN type=kotlin.Unit 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: ERROR_CALL 'Unresolved reference: <Unresolved name: it>#' type=IrErrorType
|
||||
@@ -73,7 +73,7 @@ FILE fqName:<root> fileName:/nonLocalReturn.kt
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): IrErrorType declared in <root>.testLrmFoo2'
|
||||
BLOCK type=IrErrorType origin=null
|
||||
WHEN type=IrErrorType origin=IF
|
||||
WHEN type=kotlin.Unit 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: ERROR_CALL 'Unresolved reference: <Unresolved name: it>#' type=IrErrorType
|
||||
|
||||
Reference in New Issue
Block a user