@@ -1475,19 +1475,45 @@ class X {
14751475 }
14761476 }
14771477
1478+ fun extractTypeAccess (t : IrType , parent : Label <out DbExprparent >, idx : Int , elementForLocation : IrElement ) {
1479+ // TODO: elementForLocation allows us to give some sort of
1480+ // location, but a proper location for the type access will
1481+ // require upstream changes
1482+ val type = useType(t)
1483+ val id = tw.getFreshIdLabel<DbUnannotatedtypeaccess >()
1484+ tw.writeExprs_unannotatedtypeaccess(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
1485+ val locId = tw.getLocation(elementForLocation)
1486+ tw.writeHasLocation(id, locId)
1487+ }
1488+
14781489 fun extractTypeOperatorCall (e : IrTypeOperatorCall , callable : Label <out DbCallable >, parent : Label <out DbExprparent >, idx : Int ) {
14791490 when (e.operator ) {
1491+ IrTypeOperator .CAST -> {
1492+ val id = tw.getFreshIdLabel<DbCastexpr >()
1493+ val locId = tw.getLocation(e)
1494+ val type = useType(e.type)
1495+ tw.writeExprs_castexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
1496+ tw.writeHasLocation(id, locId)
1497+ extractTypeAccess(e.typeOperand, id, 0 , e)
1498+ extractExpressionExpr(e.argument, callable, id, 1 )
1499+ }
14801500 IrTypeOperator .INSTANCEOF -> {
14811501 val id = tw.getFreshIdLabel<DbInstanceofexpr >()
14821502 val locId = tw.getLocation(e)
14831503 val type = useType(e.type)
14841504 tw.writeExprs_instanceofexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
14851505 tw.writeHasLocation(id, locId)
14861506 extractExpressionExpr(e.argument, callable, id, 0 )
1487- val typeArg = useType(e.typeOperand)
1488- val typeAccessId = tw.getFreshIdLabel<DbUnannotatedtypeaccess >()
1489- tw.writeExprs_unannotatedtypeaccess(typeAccessId, typeArg.javaResult.id, typeArg.kotlinResult.id, id, 1 )
1490- // TODO: Type access location
1507+ extractTypeAccess(e.typeOperand, id, 1 , e)
1508+ }
1509+ IrTypeOperator .NOT_INSTANCEOF -> {
1510+ val id = tw.getFreshIdLabel<DbNotinstanceofexpr >()
1511+ val locId = tw.getLocation(e)
1512+ val type = useType(e.type)
1513+ tw.writeExprs_notinstanceofexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
1514+ tw.writeHasLocation(id, locId)
1515+ extractExpressionExpr(e.argument, callable, id, 0 )
1516+ extractTypeAccess(e.typeOperand, id, 1 , e)
14911517 }
14921518 else -> {
14931519 logger.warnElement(Severity .ErrorSevere , " Unrecognised IrTypeOperatorCall: " + e.render(), e)
0 commit comments