Skip to content

Commit 9593cee

Browse files
committed
Kotlin: Special-case String.charAt naming
In the Kotlin universe this is called `get` so that Kotlin programmers can use the `[]` operator on `String`s.
1 parent 4d0f6a0 commit 9593cee

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

java/kotlin-extractor/src/main/kotlin/utils/JvmNames.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ private val specialFunctions = mapOf(
5151
makeDescription(FqName("java.lang.Number"), "toFloat") to "floatValue",
5252
makeDescription(StandardNames.FqNames.number.toSafe(), "toDouble") to "doubleValue",
5353
makeDescription(FqName("java.lang.Number"), "toDouble") to "doubleValue",
54+
makeDescription(StandardNames.FqNames.string.toSafe(), "get") to "charAt",
55+
makeDescription(FqName("java.lang.String"), "get") to "charAt",
5456
)
5557

5658
private val specialFunctionShortNames = specialFunctions.keys.map { it.functionName }.toSet()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class Test {
2+
3+
public char f(String s) { return s.charAt(0); }
4+
5+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| Test.java:3:36:3:46 | charAt(...) |
2+
| test.kt:2:20:2:23 | charAt(...) |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
fun f(x: String) = x[0]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import java
2+
3+
from MethodAccess ma
4+
select ma

0 commit comments

Comments
 (0)