File tree Expand file tree Collapse file tree 4 files changed +21
-1
lines changed
kotlin-extractor/src/main/kotlin
ql/test/kotlin/library-tests/java-map-methods Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import com.semmle.extractor.java.OdasaOutput
6
6
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
7
7
import org.jetbrains.kotlin.backend.common.ir.allOverridden
8
8
import org.jetbrains.kotlin.backend.common.lower.parentsWithSelf
9
+ import org.jetbrains.kotlin.backend.jvm.ir.propertyIfAccessor
9
10
import org.jetbrains.kotlin.builtins.StandardNames
10
11
import org.jetbrains.kotlin.descriptors.*
11
12
import org.jetbrains.kotlin.ir.declarations.*
@@ -960,7 +961,19 @@ open class KotlinUsesExtractor(
960
961
decl.name == f.name &&
961
962
decl.valueParameters.size == f.valueParameters.size
962
963
} ? :
963
- run {
964
+ // Or check property accessors:
965
+ if (f.isAccessor) {
966
+ val prop = javaClass.declarations.filterIsInstance<IrProperty >().find { decl ->
967
+ decl.name == (f.propertyIfAccessor as IrProperty ).name
968
+ }
969
+ if (prop?.getter?.name == f.name)
970
+ prop.getter
971
+ else if (prop?.setter?.name == f.name)
972
+ prop.setter
973
+ else null
974
+ } else {
975
+ null
976
+ } ? : run {
964
977
val parentFqName = parentClass.fqNameWhenAvailable?.asString()
965
978
if (! expectedMissingEquivalents.contains(parentFqName)) {
966
979
logger.warn(" Couldn't find a Java equivalent function to $parentFqName .${f.name} in ${javaClass.fqNameWhenAvailable} " )
Original file line number Diff line number Diff line change
1
+ diagnostics
2
+ #select
1
3
| Integer |
2
4
| Object |
Original file line number Diff line number Diff line change 1
1
fun test (m : Map <Int , Int >) = m.getOrDefault(1 , 2 )
2
+
3
+ fun test2 (s : String ) = s.length
Original file line number Diff line number Diff line change 1
1
import java
2
+ import semmle.code.java.Diagnostics
2
3
3
4
from MethodAccess ma
4
5
select ma .getCallee ( ) .getAParameter ( ) .getType ( ) .toString ( )
6
+
7
+ query predicate diagnostics ( Diagnostic d ) { any ( ) }
You can’t perform that action at this time.
0 commit comments