mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Map java.lang.Number methods to their Java equivalents
This commit is contained in:
@@ -90,6 +90,18 @@ open class KotlinUsesExtractor(
|
||||
makeDescription(FqName("java.lang.Enum"), "<get-ordinal>") to "ordinal",
|
||||
makeDescription(StandardNames.FqNames._enum.toSafe(), "<get-name>") to "name",
|
||||
makeDescription(FqName("java.lang.Enum"), "<get-name>") to "name",
|
||||
makeDescription(StandardNames.FqNames.number.toSafe(), "toByte") to "byteValue",
|
||||
makeDescription(FqName("java.lang.Number"), "toByte") to "byteValue",
|
||||
makeDescription(StandardNames.FqNames.number.toSafe(), "toShort") to "shortValue",
|
||||
makeDescription(FqName("java.lang.Number"), "toShort") to "shortValue",
|
||||
makeDescription(StandardNames.FqNames.number.toSafe(), "toInt") to "intValue",
|
||||
makeDescription(FqName("java.lang.Number"), "toInt") to "intValue",
|
||||
makeDescription(StandardNames.FqNames.number.toSafe(), "toLong") to "longValue",
|
||||
makeDescription(FqName("java.lang.Number"), "toLong") to "longValue",
|
||||
makeDescription(StandardNames.FqNames.number.toSafe(), "toFloat") to "floatValue",
|
||||
makeDescription(FqName("java.lang.Number"), "toFloat") to "floatValue",
|
||||
makeDescription(StandardNames.FqNames.number.toSafe(), "toDouble") to "doubleValue",
|
||||
makeDescription(FqName("java.lang.Number"), "toDouble") to "doubleValue",
|
||||
)
|
||||
|
||||
private val specialFunctionShortNames = specialFunctions.keys.map { it.functionName }.toSet()
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
public class Test {
|
||||
|
||||
byte b;
|
||||
short s;
|
||||
int i;
|
||||
long l;
|
||||
float f;
|
||||
double d;
|
||||
|
||||
public void test(Number n, Byte b2) {
|
||||
|
||||
b = n.byteValue();
|
||||
s = n.shortValue();
|
||||
i = n.intValue();
|
||||
l = n.longValue();
|
||||
f = n.floatValue();
|
||||
d = n.doubleValue();
|
||||
b = b2.byteValue();
|
||||
s = b2.shortValue();
|
||||
i = b2.intValue();
|
||||
l = b2.longValue();
|
||||
f = b2.floatValue();
|
||||
d = b2.doubleValue();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
| java.lang.Byte | byteValue |
|
||||
| java.lang.Byte | compare |
|
||||
| java.lang.Byte | compareTo |
|
||||
| java.lang.Byte | compareUnsigned |
|
||||
| java.lang.Byte | decode |
|
||||
| java.lang.Byte | describeConstable |
|
||||
| java.lang.Byte | doubleValue |
|
||||
| java.lang.Byte | equals |
|
||||
| java.lang.Byte | floatValue |
|
||||
| java.lang.Byte | hashCode |
|
||||
| java.lang.Byte | intValue |
|
||||
| java.lang.Byte | longValue |
|
||||
| java.lang.Byte | parseByte |
|
||||
| java.lang.Byte | shortValue |
|
||||
| java.lang.Byte | toString |
|
||||
| java.lang.Byte | toUnsignedInt |
|
||||
| java.lang.Byte | toUnsignedLong |
|
||||
| java.lang.Byte | valueOf |
|
||||
| java.lang.Number | byteValue |
|
||||
| java.lang.Number | doubleValue |
|
||||
| java.lang.Number | floatValue |
|
||||
| java.lang.Number | intValue |
|
||||
| java.lang.Number | longValue |
|
||||
| java.lang.Number | shortValue |
|
||||
| kotlin.Byte | byteValue |
|
||||
| kotlin.Byte | compareTo |
|
||||
| kotlin.Byte | dec |
|
||||
| kotlin.Byte | describeConstable |
|
||||
| kotlin.Byte | div |
|
||||
| kotlin.Byte | doubleValue |
|
||||
| kotlin.Byte | floatValue |
|
||||
| kotlin.Byte | inc |
|
||||
| kotlin.Byte | intValue |
|
||||
| kotlin.Byte | longValue |
|
||||
| kotlin.Byte | minus |
|
||||
| kotlin.Byte | plus |
|
||||
| kotlin.Byte | rangeTo |
|
||||
| kotlin.Byte | rem |
|
||||
| kotlin.Byte | shortValue |
|
||||
| kotlin.Byte | times |
|
||||
| kotlin.Byte | toChar |
|
||||
| kotlin.Byte | unaryMinus |
|
||||
| kotlin.Byte | unaryPlus |
|
||||
| kotlin.Number | byteValue |
|
||||
| kotlin.Number | doubleValue |
|
||||
| kotlin.Number | floatValue |
|
||||
| kotlin.Number | intValue |
|
||||
| kotlin.Number | longValue |
|
||||
| kotlin.Number | shortValue |
|
||||
| kotlin.Number | toChar |
|
||||
@@ -0,0 +1 @@
|
||||
fun f(n: Number, b: Byte) = n.toByte() + n.toShort() + n.toInt() + n.toLong() + n.toFloat() + n.toDouble() + b.toByte() + b.toShort() + b.toInt() + b.toLong() + b.toFloat() + b.toDouble()
|
||||
@@ -0,0 +1,5 @@
|
||||
import java
|
||||
|
||||
from Method m
|
||||
where m.getDeclaringType().getName() = ["Number", "Byte"]
|
||||
select m.getDeclaringType().getQualifiedName(), m.toString()
|
||||
Reference in New Issue
Block a user