mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Merge pull request #9875 from smowton/smowton/fix/charat-naming
Kotlin: Special-case String.charAt naming
This commit is contained in:
@@ -51,6 +51,8 @@ private val specialFunctions = mapOf(
|
||||
makeDescription(FqName("java.lang.Number"), "toFloat") to "floatValue",
|
||||
makeDescription(StandardNames.FqNames.number.toSafe(), "toDouble") to "doubleValue",
|
||||
makeDescription(FqName("java.lang.Number"), "toDouble") to "doubleValue",
|
||||
makeDescription(StandardNames.FqNames.string.toSafe(), "get") to "charAt",
|
||||
makeDescription(FqName("java.lang.String"), "get") to "charAt",
|
||||
)
|
||||
|
||||
private val specialFunctionShortNames = specialFunctions.keys.map { it.functionName }.toSet()
|
||||
|
||||
@@ -8,7 +8,7 @@ reflection.kt:
|
||||
# 46| 0: [TypeAccess] String
|
||||
# 47| 5: [BlockStmt] { ... }
|
||||
# 47| 0: [ReturnStmt] return ...
|
||||
# 47| 0: [MethodAccess] get(...)
|
||||
# 47| 0: [MethodAccess] charAt(...)
|
||||
# 47| -1: [ExtensionReceiverAccess] this
|
||||
# 47| 0: [SubExpr] ... - ...
|
||||
# 47| 0: [MethodAccess] length(...)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Test {
|
||||
|
||||
public char f(String s) { return s.charAt(0); }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
| Test.java:3:36:3:46 | charAt(...) |
|
||||
| test.kt:2:20:2:23 | charAt(...) |
|
||||
2
java/ql/test/kotlin/library-tests/string-charat/test.kt
Normal file
2
java/ql/test/kotlin/library-tests/string-charat/test.kt
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
fun f(x: String) = x[0]
|
||||
4
java/ql/test/kotlin/library-tests/string-charat/test.ql
Normal file
4
java/ql/test/kotlin/library-tests/string-charat/test.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import java
|
||||
|
||||
from MethodAccess ma
|
||||
select ma
|
||||
Reference in New Issue
Block a user