Skip to content

Kotlin: fix bit-inversion operator for Byte and Short types #10797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,10 @@ open class KotlinFileExtractor(
}
}
tw.writeExprsKotlinType(id, type.kotlinResult.id)
unaryopDisp(id)
if (isFunction(target, "kotlin", "Byte or Short", { it == "Byte" || it == "Short" }, "inv"))
unaryopReceiver(id, c.extensionReceiver, "Extension receiver")
else
unaryopDisp(id)
}
// We need to handle all the builtin operators defines in BuiltInOperatorNames in
// compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrBuiltIns.kt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.dec in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.dec in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.dec in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.dec in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.inc in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.inc in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.inc in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.inc in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.toInt in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.toInt in java.lang.Byte |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Byte.toInt in java.lang.Byte |
Expand All @@ -21,6 +29,22 @@
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Int.inc in java.lang.Integer |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Int.rangeTo in java.lang.Integer |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Int.rangeTo in java.lang.Integer |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Long.dec in java.lang.Long |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Long.dec in java.lang.Long |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Long.dec in java.lang.Long |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Long.dec in java.lang.Long |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Long.inc in java.lang.Long |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Long.inc in java.lang.Long |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Long.inc in java.lang.Long |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Long.inc in java.lang.Long |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Short.dec in java.lang.Short |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Short.dec in java.lang.Short |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Short.dec in java.lang.Short |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Short.dec in java.lang.Short |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Short.inc in java.lang.Short |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Short.inc in java.lang.Short |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Short.inc in java.lang.Short |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Short.inc in java.lang.Short |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Short.toInt in java.lang.Short |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Short.toInt in java.lang.Short |
| file://:0:0:0:0 | Couldn't find a Java equivalent function to kotlin.Short.toInt in java.lang.Short |
Expand Down
308 changes: 308 additions & 0 deletions java/ql/test/kotlin/library-tests/exprs/PrintAst.expected
Original file line number Diff line number Diff line change
Expand Up @@ -2862,6 +2862,14 @@ exprs.kt:
# 279| 0: [TypeAccess] int
# 279| 1: [Parameter] d
# 279| 0: [TypeAccess] double
# 279| 2: [Parameter] b
# 279| 0: [TypeAccess] byte
# 279| 3: [Parameter] s
# 279| 0: [TypeAccess] short
# 279| 4: [Parameter] l
# 279| 0: [TypeAccess] long
# 279| 5: [Parameter] f
# 279| 0: [TypeAccess] float
# 279| 5: [BlockStmt] { ... }
# 280| 0: [ExprStmt] <Expr>;
# 280| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
Expand Down Expand Up @@ -2963,6 +2971,306 @@ exprs.kt:
# 293| 0: [TypeAccess] Unit
# 293| 1: [MethodAccess] dec(...)
# 293| -1: [VarAccess] i1
# 294| 14: [ExprStmt] <Expr>;
# 294| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 294| 0: [TypeAccess] Unit
# 294| 1: [BitNotExpr] ~...
# 294| 0: [VarAccess] i
# 296| 15: [ExprStmt] <Expr>;
# 296| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 296| 0: [TypeAccess] Unit
# 296| 1: [MinusExpr] -...
# 296| 0: [VarAccess] b
# 297| 16: [ExprStmt] <Expr>;
# 297| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 297| 0: [TypeAccess] Unit
# 297| 1: [PlusExpr] +...
# 297| 0: [VarAccess] b
# 298| 17: [LocalVariableDeclStmt] var ...;
# 298| 1: [LocalVariableDeclExpr] b0
# 298| 0: [IntegerLiteral] 1
# 299| 18: [LocalVariableDeclStmt] var ...;
# 299| 1: [LocalVariableDeclExpr] b1
# 299| 0: [IntegerLiteral] 1
# 300| 19: [ExprStmt] <Expr>;
# 300| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 300| 0: [TypeAccess] Unit
# 300| 1: [StmtExpr] <Stmt>
# 300| 0: [BlockStmt] { ... }
# 300| 0: [LocalVariableDeclStmt] var ...;
# 300| 1: [LocalVariableDeclExpr] tmp2
# 300| 0: [VarAccess] b0
# 300| 1: [ExprStmt] <Expr>;
# 300| 0: [AssignExpr] ...=...
# 300| 0: [VarAccess] b0
# 300| 1: [MethodAccess] inc(...)
# 300| -1: [VarAccess] tmp2
# 300| 2: [ExprStmt] <Expr>;
# 300| 0: [VarAccess] tmp2
# 301| 20: [ExprStmt] <Expr>;
# 301| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 301| 0: [TypeAccess] Unit
# 301| 1: [StmtExpr] <Stmt>
# 301| 0: [BlockStmt] { ... }
# 301| 0: [ExprStmt] <Expr>;
# 301| 0: [AssignExpr] ...=...
# 301| 0: [VarAccess] b0
# 301| 1: [MethodAccess] inc(...)
# 301| -1: [VarAccess] b0
# 301| 1: [ExprStmt] <Expr>;
# 301| 0: [VarAccess] b0
# 302| 21: [ExprStmt] <Expr>;
# 302| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 302| 0: [TypeAccess] Unit
# 302| 1: [StmtExpr] <Stmt>
# 302| 0: [BlockStmt] { ... }
# 302| 0: [LocalVariableDeclStmt] var ...;
# 302| 1: [LocalVariableDeclExpr] tmp3
# 302| 0: [VarAccess] b0
# 302| 1: [ExprStmt] <Expr>;
# 302| 0: [AssignExpr] ...=...
# 302| 0: [VarAccess] b0
# 302| 1: [MethodAccess] dec(...)
# 302| -1: [VarAccess] tmp3
# 302| 2: [ExprStmt] <Expr>;
# 302| 0: [VarAccess] tmp3
# 303| 22: [ExprStmt] <Expr>;
# 303| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 303| 0: [TypeAccess] Unit
# 303| 1: [StmtExpr] <Stmt>
# 303| 0: [BlockStmt] { ... }
# 303| 0: [ExprStmt] <Expr>;
# 303| 0: [AssignExpr] ...=...
# 303| 0: [VarAccess] b0
# 303| 1: [MethodAccess] dec(...)
# 303| -1: [VarAccess] b0
# 303| 1: [ExprStmt] <Expr>;
# 303| 0: [VarAccess] b0
# 304| 23: [ExprStmt] <Expr>;
# 304| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 304| 0: [TypeAccess] Unit
# 304| 1: [MethodAccess] inc(...)
# 304| -1: [VarAccess] b0
# 305| 24: [ExprStmt] <Expr>;
# 305| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 305| 0: [TypeAccess] Unit
# 305| 1: [MethodAccess] dec(...)
# 305| -1: [VarAccess] b0
# 306| 25: [ExprStmt] <Expr>;
# 306| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 306| 0: [TypeAccess] Unit
# 306| 1: [MethodAccess] inc(...)
# 306| -1: [VarAccess] b1
# 307| 26: [ExprStmt] <Expr>;
# 307| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 307| 0: [TypeAccess] Unit
# 307| 1: [MethodAccess] dec(...)
# 307| -1: [VarAccess] b1
# 308| 27: [ExprStmt] <Expr>;
# 308| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 308| 0: [TypeAccess] Unit
# 308| 1: [BitNotExpr] ~...
# 308| 0: [VarAccess] b
# 310| 28: [ExprStmt] <Expr>;
# 310| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 310| 0: [TypeAccess] Unit
# 310| 1: [MinusExpr] -...
# 310| 0: [VarAccess] s
# 311| 29: [ExprStmt] <Expr>;
# 311| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 311| 0: [TypeAccess] Unit
# 311| 1: [PlusExpr] +...
# 311| 0: [VarAccess] s
# 312| 30: [LocalVariableDeclStmt] var ...;
# 312| 1: [LocalVariableDeclExpr] s0
# 312| 0: [IntegerLiteral] 1
# 313| 31: [LocalVariableDeclStmt] var ...;
# 313| 1: [LocalVariableDeclExpr] s1
# 313| 0: [IntegerLiteral] 1
# 314| 32: [ExprStmt] <Expr>;
# 314| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 314| 0: [TypeAccess] Unit
# 314| 1: [StmtExpr] <Stmt>
# 314| 0: [BlockStmt] { ... }
# 314| 0: [LocalVariableDeclStmt] var ...;
# 314| 1: [LocalVariableDeclExpr] tmp4
# 314| 0: [VarAccess] s0
# 314| 1: [ExprStmt] <Expr>;
# 314| 0: [AssignExpr] ...=...
# 314| 0: [VarAccess] s0
# 314| 1: [MethodAccess] inc(...)
# 314| -1: [VarAccess] tmp4
# 314| 2: [ExprStmt] <Expr>;
# 314| 0: [VarAccess] tmp4
# 315| 33: [ExprStmt] <Expr>;
# 315| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 315| 0: [TypeAccess] Unit
# 315| 1: [StmtExpr] <Stmt>
# 315| 0: [BlockStmt] { ... }
# 315| 0: [ExprStmt] <Expr>;
# 315| 0: [AssignExpr] ...=...
# 315| 0: [VarAccess] s0
# 315| 1: [MethodAccess] inc(...)
# 315| -1: [VarAccess] s0
# 315| 1: [ExprStmt] <Expr>;
# 315| 0: [VarAccess] s0
# 316| 34: [ExprStmt] <Expr>;
# 316| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 316| 0: [TypeAccess] Unit
# 316| 1: [StmtExpr] <Stmt>
# 316| 0: [BlockStmt] { ... }
# 316| 0: [LocalVariableDeclStmt] var ...;
# 316| 1: [LocalVariableDeclExpr] tmp5
# 316| 0: [VarAccess] s0
# 316| 1: [ExprStmt] <Expr>;
# 316| 0: [AssignExpr] ...=...
# 316| 0: [VarAccess] s0
# 316| 1: [MethodAccess] dec(...)
# 316| -1: [VarAccess] tmp5
# 316| 2: [ExprStmt] <Expr>;
# 316| 0: [VarAccess] tmp5
# 317| 35: [ExprStmt] <Expr>;
# 317| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 317| 0: [TypeAccess] Unit
# 317| 1: [StmtExpr] <Stmt>
# 317| 0: [BlockStmt] { ... }
# 317| 0: [ExprStmt] <Expr>;
# 317| 0: [AssignExpr] ...=...
# 317| 0: [VarAccess] s0
# 317| 1: [MethodAccess] dec(...)
# 317| -1: [VarAccess] s0
# 317| 1: [ExprStmt] <Expr>;
# 317| 0: [VarAccess] s0
# 318| 36: [ExprStmt] <Expr>;
# 318| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 318| 0: [TypeAccess] Unit
# 318| 1: [MethodAccess] inc(...)
# 318| -1: [VarAccess] s0
# 319| 37: [ExprStmt] <Expr>;
# 319| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 319| 0: [TypeAccess] Unit
# 319| 1: [MethodAccess] dec(...)
# 319| -1: [VarAccess] s0
# 320| 38: [ExprStmt] <Expr>;
# 320| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 320| 0: [TypeAccess] Unit
# 320| 1: [MethodAccess] inc(...)
# 320| -1: [VarAccess] s1
# 321| 39: [ExprStmt] <Expr>;
# 321| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 321| 0: [TypeAccess] Unit
# 321| 1: [MethodAccess] dec(...)
# 321| -1: [VarAccess] s1
# 322| 40: [ExprStmt] <Expr>;
# 322| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 322| 0: [TypeAccess] Unit
# 322| 1: [BitNotExpr] ~...
# 322| 0: [VarAccess] s
# 324| 41: [ExprStmt] <Expr>;
# 324| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 324| 0: [TypeAccess] Unit
# 324| 1: [MinusExpr] -...
# 324| 0: [VarAccess] l
# 325| 42: [ExprStmt] <Expr>;
# 325| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 325| 0: [TypeAccess] Unit
# 325| 1: [PlusExpr] +...
# 325| 0: [VarAccess] l
# 326| 43: [LocalVariableDeclStmt] var ...;
# 326| 1: [LocalVariableDeclExpr] l0
# 326| 0: [LongLiteral] 1
# 327| 44: [LocalVariableDeclStmt] var ...;
# 327| 1: [LocalVariableDeclExpr] l1
# 327| 0: [LongLiteral] 1
# 328| 45: [ExprStmt] <Expr>;
# 328| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 328| 0: [TypeAccess] Unit
# 328| 1: [StmtExpr] <Stmt>
# 328| 0: [BlockStmt] { ... }
# 328| 0: [LocalVariableDeclStmt] var ...;
# 328| 1: [LocalVariableDeclExpr] tmp6
# 328| 0: [VarAccess] l0
# 328| 1: [ExprStmt] <Expr>;
# 328| 0: [AssignExpr] ...=...
# 328| 0: [VarAccess] l0
# 328| 1: [MethodAccess] inc(...)
# 328| -1: [VarAccess] tmp6
# 328| 2: [ExprStmt] <Expr>;
# 328| 0: [VarAccess] tmp6
# 329| 46: [ExprStmt] <Expr>;
# 329| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 329| 0: [TypeAccess] Unit
# 329| 1: [StmtExpr] <Stmt>
# 329| 0: [BlockStmt] { ... }
# 329| 0: [ExprStmt] <Expr>;
# 329| 0: [AssignExpr] ...=...
# 329| 0: [VarAccess] l0
# 329| 1: [MethodAccess] inc(...)
# 329| -1: [VarAccess] l0
# 329| 1: [ExprStmt] <Expr>;
# 329| 0: [VarAccess] l0
# 330| 47: [ExprStmt] <Expr>;
# 330| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 330| 0: [TypeAccess] Unit
# 330| 1: [StmtExpr] <Stmt>
# 330| 0: [BlockStmt] { ... }
# 330| 0: [LocalVariableDeclStmt] var ...;
# 330| 1: [LocalVariableDeclExpr] tmp7
# 330| 0: [VarAccess] l0
# 330| 1: [ExprStmt] <Expr>;
# 330| 0: [AssignExpr] ...=...
# 330| 0: [VarAccess] l0
# 330| 1: [MethodAccess] dec(...)
# 330| -1: [VarAccess] tmp7
# 330| 2: [ExprStmt] <Expr>;
# 330| 0: [VarAccess] tmp7
# 331| 48: [ExprStmt] <Expr>;
# 331| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 331| 0: [TypeAccess] Unit
# 331| 1: [StmtExpr] <Stmt>
# 331| 0: [BlockStmt] { ... }
# 331| 0: [ExprStmt] <Expr>;
# 331| 0: [AssignExpr] ...=...
# 331| 0: [VarAccess] l0
# 331| 1: [MethodAccess] dec(...)
# 331| -1: [VarAccess] l0
# 331| 1: [ExprStmt] <Expr>;
# 331| 0: [VarAccess] l0
# 332| 49: [ExprStmt] <Expr>;
# 332| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 332| 0: [TypeAccess] Unit
# 332| 1: [MethodAccess] inc(...)
# 332| -1: [VarAccess] l0
# 333| 50: [ExprStmt] <Expr>;
# 333| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 333| 0: [TypeAccess] Unit
# 333| 1: [MethodAccess] dec(...)
# 333| -1: [VarAccess] l0
# 334| 51: [ExprStmt] <Expr>;
# 334| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 334| 0: [TypeAccess] Unit
# 334| 1: [MethodAccess] inc(...)
# 334| -1: [VarAccess] l1
# 335| 52: [ExprStmt] <Expr>;
# 335| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 335| 0: [TypeAccess] Unit
# 335| 1: [MethodAccess] dec(...)
# 335| -1: [VarAccess] l1
# 336| 53: [ExprStmt] <Expr>;
# 336| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 336| 0: [TypeAccess] Unit
# 336| 1: [BitNotExpr] ~...
# 336| 0: [VarAccess] l
# 338| 54: [ExprStmt] <Expr>;
# 338| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 338| 0: [TypeAccess] Unit
# 338| 1: [PlusExpr] +...
# 338| 0: [VarAccess] f
# 339| 55: [ExprStmt] <Expr>;
# 339| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 339| 0: [TypeAccess] Unit
# 339| 1: [MinusExpr] -...
# 339| 0: [VarAccess] f
# 142| 2: [Class] C
# 142| 1: [Constructor] C
#-----| 4: (Parameters)
Expand Down
Loading