Skip to content

Commit 5282c86

Browse files
committed
Apply review feedback
1 parent b8ed3b7 commit 5282c86

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ open class KotlinFileExtractor(
217217
is IrField -> {
218218
val parentId = useDeclarationParent(getFieldParent(declaration), false)?.cast<DbReftype>()
219219
if (parentId != null) {
220-
extractField(declaration, parentId, extractFunctionBodies)
220+
// For consistency with the Java extractor, enum entries get type accesses only if we're extracting from .kt source (i.e., when `extractFunctionBodies` is set)
221+
extractField(declaration, parentId, extractAnnotationEnumTypeAccesses = extractFunctionBodies)
221222
}
222223
Unit
223224
}
@@ -496,7 +497,7 @@ open class KotlinFileExtractor(
496497
private fun replaceKotlinDeprecatedAnnotation(annotations: List<IrConstructorCall>): List<IrConstructorCall> {
497498
val shouldReplace =
498499
annotations.any { (it.type as? IrSimpleType)?.classFqName?.asString() == "kotlin.Deprecated" } &&
499-
annotations.none { (it.type as? IrSimpleType)?.classFqName?.asString() == "java.lang.Deprecated" }
500+
annotations.none { it.type.classOrNull == javaLangDeprecated?.symbol }
500501
val jldConstructor = javaLangDeprecatedConstructor
501502
if (!shouldReplace || jldConstructor == null)
502503
return annotations
@@ -508,10 +509,7 @@ open class KotlinFileExtractor(
508509
}
509510

510511
private fun extractAnnotations(c: IrAnnotationContainer, annotations: List<IrConstructorCall>, parent: Label<out DbExprparent>, extractEnumTypeAccesses: Boolean) {
511-
val origin = when(c) {
512-
is IrDeclaration -> c.origin
513-
else -> null
514-
}
512+
val origin = (c as? IrDeclaration)?.origin ?: run { logger.warn("Unexpected annotation container: $c"); return }
515513
val replacedAnnotations =
516514
if (origin == IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB)
517515
replaceKotlinDeprecatedAnnotation(annotations)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from create_database_utils import *
2+
import os
23

34
os.mkdir('out')
45
os.mkdir('out2')
56
os.mkdir('out3')
6-
run_codeql_database_create(["javac AnnotatedInterface.java AnnotatedMethods.java zpkg/A.java org/jetbrains/annotations/NotNull.java org/jetbrains/annotations/Nullable.java -d out", "kotlinc ktUser.kt -cp out -d out2", "javac JavaUser.java -cp out:out2 -d out3"], lang="java")
7+
run_codeql_database_create(["javac AnnotatedInterface.java AnnotatedMethods.java zpkg/A.java org/jetbrains/annotations/NotNull.java org/jetbrains/annotations/Nullable.java -d out", "kotlinc ktUser.kt -cp out -d out2", "javac JavaUser.java -cp out" + os.pathsep + "out2 -d out3"], lang="java")

0 commit comments

Comments
 (0)