-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Kotlin: Simplify kotlinFunctionToJavaEquivalent
#10646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kotlin: Simplify kotlinFunctionToJavaEquivalent
#10646
Conversation
| val syntheticToRealClassMap = HashMap<IrClass, IrClass?>() | ||
| val syntheticToRealFunctionMap = HashMap<IrFunction, IrFunction?>() | ||
| val syntheticToRealFieldMap = HashMap<IrField, IrField?>() | ||
|
|
||
| val deduplicatedWarnings = mutableSetOf<String>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these be some variants of concurrent maps? Is there any guarantee that we run single threaded? Could KotlinExtractorExtension::generate be invoked by kotlinc from multiple threads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM.
| val msg = "Couldn't find a Java equivalent function to $parentFqName.${f.name.asString()} in ${javaClass.fqNameWhenAvailable?.asString()}" | ||
| if (!globalExtensionState.deduplicatedWarnings.contains(msg)) { | ||
| logger.warn(msg) | ||
| globalExtensionState.deduplicatedWarnings.add(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that https://github.com/github/codeql/blob/main/java/kotlin-extractor/src/main/kotlin/utils/Logger.kt#L117 is already going to limit the number of any kind of warning to (by default) 100, so although this is more specific, I'm not sure that it's worth the extra code here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, let me revert this.
This reverts commit 7524f33.
This PR
kotlinFunctionToJavaEquivalentand instead looks up only exact member match;expectedMissingEquivalents, which was hiding the fact that some of the mappings were missing;inv,not,and,or,xor,shl,shrandushr;kotlinFunctionToJavaEquivalentto ignore nullability;only logs each missing mapping once.