before_code
stringlengths
30
149k
reviewer_comment
stringlengths
16
20.6k
after_code
stringlengths
30
163k
diff_context
stringlengths
0
22.4k
file_path
stringlengths
6
155
comment_line
int64
0
26
language
stringclasses
19 values
quality_score
float64
0.07
1
comment_type
stringclasses
9 values
comment_length
int64
16
20.6k
before_lines
int64
2
4.61k
after_lines
int64
2
4.4k
is_negative
bool
2 classes
pr_title
stringlengths
7
140
pr_number
int64
18
61.2k
repo_name
stringclasses
29 values
repo_stars
int64
321
56k
repo_language
stringclasses
14 values
reviewer_username
stringclasses
378 values
author_username
stringclasses
739 values
user
stringlengths
361
200k
assistant
stringlengths
16
20.6k
system
stringclasses
1 value
public void testBuildFile() throws Exception { File buildXml = new File(getTestDataDir(), "build.xml"); runCompiler( "buildFile.compile", AbstractCliTest.replacePathsInBuildXml("-Xbuild-file=" + buildXml, getTestDataDir(), tmpdir.getPath()) ); run("bu...
Let's just suppress it on the whole class
} public void testBuildFile() throws Exception { File buildXml = new File(getTestDataDir(), "build.xml"); runCompiler( "buildFile.compile", AbstractCliTest.replacePathsInBuildXml("-Xbuild-file=" + buildXml, getTestDataDir(), tmpdir.getPath()) ); r...
@@ -203,6 +209,7 @@ public void testNoReflect() throws Exception { } // related to KT-14772, destination is not a jar, and clashing with an existing file + @SuppressWarnings("ResultOfMethodCallIgnored")
compiler/tests/org/jetbrains/kotlin/integration/CompilerSmokeTest.java
26
Java
0.071
suggestion
41
51
51
false
kotlinc: Add a test to for the situation where pathname of destination does not name a parent
4,189
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Java File: compiler/tests/org/jetbrains/kotlin/integration/CompilerSmokeTest.java PR Title: kotlinc: Add a test to for the situation where pathname of destination does not name a parent BEFORE CODE: public void testBuildFile() throws Exception { File buildXml ...
Let's just suppress it on the whole class
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import java.net.URLClassLoader import java.util.jar.Attributes import java.util.jar.JarFile class RunnerException(message: String) : RuntimeException(message) abstract class AbstractRunner : Runner { protected abstract val className: String protected abstract fun createClassLoader(classpath: List<URL>): Clas...
This change is needed here to print an error message instead of the exception stack. It is related to [KT-46171](https://youtrack.jetbrains.com/issue/KT-46171), I created that issue earlier today.
import java.net.URLClassLoader import java.util.jar.Attributes import java.util.jar.JarFile class RunnerException(message: String, cause: Throwable? = null) : RuntimeException(message, cause) abstract class AbstractRunner : Runner { protected abstract val className: String protected abstract fun createClassL...
@@ -37,23 +37,23 @@ abstract class AbstractRunner : Runner { val mainClass = try { classLoader.loadClass(className) - } - catch (e: ClassNotFoundException) { + } catch (e: ClassNotFoundException) { + throw RunnerException("could not find or load main class $classN...
compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/runners.kt
26
Kotlin
0.571
suggestion
197
51
51
false
CLI: Allow running class files with '.class' extension in 'kotlin' script
4,205
JetBrains/kotlin
51,705
Kotlin
scaventz
scaventz
Review this pull request change. Language: Kotlin File: compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/runners.kt PR Title: CLI: Allow running class files with '.class' extension in 'kotlin' script BEFORE CODE: import java.net.URLClassLoader import java.util.jar.Attributes import java.util.jar.JarFile cla...
This change is needed here to print an error message instead of the exception stack. It is related to [KT-46171](https://youtrack.jetbrains.com/issue/KT-46171), I created that issue earlier today.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
fun testRunClassFileWithExtension() { runProcess("kotlinc", "$testDataDirectory/helloWorld.kt", "-d", tmpdir.path) runProcess( "kotlin", "test/HelloWorldKt.class", expectedStdout = "Hello!\n", workDirectory = tmpdir ) runProcess( ...
Hope this function makes our test more readable and reliable
assertExists(File("${testDir.path}/DefaultPackageKt.class")) runProcess( "kotlin", "test.DefaultPackageKt", workDirectory = tmpdir, expectedExitCode = 1, expectedStderr = """ error: could not find or load main class test.DefaultPackageKt Caused by: java.l...
@@ -359,4 +359,70 @@ fun f() : Result<Int> = Result.success(42) expectedExitCode = 1 ) } + + fun testRunClassFileWithExtension() { + runProcess("kotlinc", "$testDataDirectory/helloWorld.kt", "-d", tmpdir.path) + runProcess( + "kotlin", + "test/HelloWorld...
compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt
26
Kotlin
0.214
suggestion
60
51
51
false
CLI: Allow running class files with '.class' extension in 'kotlin' script
4,205
JetBrains/kotlin
51,705
Kotlin
scaventz
scaventz
Review this pull request change. Language: Kotlin File: compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt PR Title: CLI: Allow running class files with '.class' extension in 'kotlin' script BEFORE CODE: fun testRunClassFileWithExtension() { runProcess("kotlinc", "$testDataDirectory/helloWor...
Hope this function makes our test more readable and reliable
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} fun testRunClassFileWithExtension() { runProcess("kotlinc", "$testDataDirectory/helloWorld.kt", "-d", tmpdir.path) runProcess( "kotlin", "test/HelloWorldKt.class", expectedStdout = "Hello!\n", workDirectory = tmpdir ) runProcess(...
Hope this function makes our test more reliable and slightly more readable. If it doesn't, I can remove it.
assertExists(File("${testDir.path}/DefaultPackageKt.class")) runProcess( "kotlin", "test.DefaultPackageKt", workDirectory = tmpdir, expectedExitCode = 1, expectedStderr = """ error: could not find or load main class test.DefaultPackageKt Caused by: java.l...
@@ -359,4 +360,70 @@ fun f() : Result<Int> = Result.success(42) expectedExitCode = 1 ) } + + fun testRunClassFileWithExtension() { + runProcess("kotlinc", "$testDataDirectory/helloWorld.kt", "-d", tmpdir.path) + runProcess( + "kotlin", + "test/HelloWorld...
compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt
26
Kotlin
0.429
suggestion
107
51
51
false
CLI: Allow running class files with '.class' extension in 'kotlin' script
4,205
JetBrains/kotlin
51,705
Kotlin
scaventz
scaventz
Review this pull request change. Language: Kotlin File: compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt PR Title: CLI: Allow running class files with '.class' extension in 'kotlin' script BEFORE CODE: } fun testRunClassFileWithExtension() { runProcess("kotlinc", "$testDataDirectory/he...
Hope this function makes our test more reliable and slightly more readable. If it doesn't, I can remove it.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} else if (arg.startsWith("-")) { throw RunnerException("unknown option: $arg") } else if (howtorun == HowToRun.JAR || (howtorun == HowToRun.GUESS && arg.endsWith(".jar"))) { setRunner(JarRunner(arg)) restAsArguments() ...
The method `toRelativeString` may throw an `IllegalArgumentException` when our `classFile.canonicalFile` and `workingDir.canonicalFile` have different roots, but it has been circumvented in our `if` statement, so there is no need to catch it.
} else if (arg.startsWith("-")) { throw RunnerException("unknown option: $arg") } else if (howtorun == HowToRun.JAR || (howtorun == HowToRun.GUESS && arg.endsWith(".jar"))) { setRunner(JarRunner(arg)) restAsArguments() ...
@@ -144,7 +144,18 @@ object Main { break } else { - setRunner(MainClassRunner(arg)) + val workingDir = File(".") + val classFile = File(arg) + // allow running class files with '.class' extension, but in order to infe...
compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/Main.kt
26
Kotlin
0.714
suggestion
243
51
51
false
CLI: Allow running class files with '.class' extension in 'kotlin' script
4,205
JetBrains/kotlin
51,705
Kotlin
scaventz
scaventz
Review this pull request change. Language: Kotlin File: compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/Main.kt PR Title: CLI: Allow running class files with '.class' extension in 'kotlin' script BEFORE CODE: } else if (arg.startsWith("-")) { throw RunnerException("un...
The method `toRelativeString` may throw an `IllegalArgumentException` when our `classFile.canonicalFile` and `workingDir.canonicalFile` have different roots, but it has been circumvented in our `if` statement, so there is no need to catch it.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
expectedExitCode = 1 ) } fun testRunClassFileWithExtension() { runProcess("kotlinc", "$testDataDirectory/helloWorld.kt", "-d", tmpdir.path) runProcess( "kotlin", "test/HelloWorldKt.class", expectedStdout = "Hello!\n", workDirec...
Minor, but let's throw `AssertionError` to make it clear that the test fails because of incorrect compiler behavior, not some I/O problems
runProcess("kotlinc", "$testDataDirectory/defaultPackage.kt", "-d", testDir.path) assertExists(File("${testDir.path}/DefaultPackageKt.class")) runProcess( "kotlin", "test.DefaultPackageKt", workDirectory = tmpdir, expectedExitCode = 1, expectedStderr = """ e...
@@ -359,4 +360,70 @@ fun f() : Result<Int> = Result.success(42) expectedExitCode = 1 ) } + + fun testRunClassFileWithExtension() { + runProcess("kotlinc", "$testDataDirectory/helloWorld.kt", "-d", tmpdir.path) + runProcess( + "kotlin", + "test/HelloWorld...
compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt
26
Kotlin
0.714
bug
138
51
51
false
CLI: Allow running class files with '.class' extension in 'kotlin' script
4,205
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Kotlin File: compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt PR Title: CLI: Allow running class files with '.class' extension in 'kotlin' script BEFORE CODE: expectedExitCode = 1 ) } fun testRunClassFileWithExtension() { r...
Minor, but let's throw `AssertionError` to make it clear that the test fails because of incorrect compiler behavior, not some I/O problems
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// WITH_RUNTIME // IGNORE_BACKEND: JVM open class BaseWrapper<T>(val response: T) class Wrapper(result: Result<String>) : BaseWrapper<Result<String>>(result) fun box(): String { return Wrapper(Result.success("OK")).response.getOrThrow()) }
Looks like there's an extra `)` here, which is why this test fails for example for JS, JS_IR and WASM. I wonder why it passes for JVM_IR though...
// WITH_RUNTIME // IGNORE_BACKEND: JVM open class BaseWrapper<T>(val response: T) class Wrapper(result: Result<String>) : BaseWrapper<Result<String>>(result) fun box(): String { return Wrapper(Result.success("OK")).response.getOrThrow() }
@@ -0,0 +1,9 @@ +// WITH_RUNTIME +// IGNORE_BACKEND: JVM + +open class BaseWrapper<T>(val response: T) +class Wrapper(result: Result<String>) : BaseWrapper<Result<String>>(result) + +fun box(): String { + return Wrapper(Result.success("OK")).response.getOrThrow())
compiler/testData/codegen/box/inlineClasses/kt44867.kt
8
Kotlin
0.5
bug
146
10
10
false
JVM IR: Resolve fake overrides when calculating return types (KT-44867)
4,211
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: compiler/testData/codegen/box/inlineClasses/kt44867.kt PR Title: JVM IR: Resolve fake overrides when calculating return types (KT-44867) BEFORE CODE: // WITH_RUNTIME // IGNORE_BACKEND: JVM open class BaseWrapper<T>(val response: T) class Wrapper(result: Resul...
Looks like there's an extra `)` here, which is why this test fails for example for JS, JS_IR and WASM. I wonder why it passes for JVM_IR though...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
description = "Make JvmStatic functions in non-companion objects static and replace all call sites in the module" ) internal val jvmStaticInCompanionPhase = makeIrFilePhase( ::JvmStaticInCompanionLowering, name = "JvmStaticInCompanion", description = "Synthesize static proxy functions for JvmStatic fun...
Just curious, was this check for default parameters obsolete, or is it removed for some other reason?
::JvmStaticInObjectLowering, name = "JvmStaticInObject", description = "Make JvmStatic functions in non-companion objects static and replace all call sites in the module" ) internal val jvmStaticInCompanionPhase = makeIrFilePhase( ::JvmStaticInCompanionLowering, name = "JvmStaticInCompanion", d...
@@ -46,131 +48,107 @@ internal val jvmStaticInCompanionPhase = makeIrFilePhase( description = "Synthesize static proxy functions for JvmStatic functions in companion objects" ) -private class JvmStaticInObjectLowering(val context: JvmBackendContext) : IrElementTransformerVoid(), FileLoweringPass { - override...
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt
26
Kotlin
0.429
question
101
51
51
false
JVM_IR: remap calls to protected `@JvmStatic` in companions
4,222
JetBrains/kotlin
51,705
Kotlin
udalov
pyos
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt PR Title: JVM_IR: remap calls to protected `@JvmStatic` in companions BEFORE CODE: description = "Make JvmStatic functions in non-companion objects static and...
Just curious, was this check for default parameters obsolete, or is it removed for some other reason?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import kotlin.reflect.KProperty0 internal open class KProperty0Impl<out V> : KProperty0<V>, KPropertyImpl<V> { constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) constructor(container: KDeclarationContainerImpl, name: String, signature: String, bou...
```property.name``` is not sufficient as a basis for equality, and it is not feasible to use ```property==that.property``` directly because it requires equality of ```rawBoundReceiver```. So ```property.toString() == that.property.toString()``` seems good to me.
import kotlin.reflect.KProperty0 internal open class KProperty0Impl<out V> : KProperty0<V>, KPropertyImpl<V> { constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) constructor(container: KDeclarationContainerImpl, name: String, signature: String, bou...
@@ -42,6 +42,13 @@ internal open class KProperty0Impl<out V> : KProperty0<V>, KPropertyImpl<V> { class Getter<out R>(override val property: KProperty0Impl<R>) : KPropertyImpl.Getter<R>(), KProperty0.Getter<R> { override fun invoke(): R = property.get() + + override fun equals(other: Any?): Boolea...
core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt
26
Kotlin
0.857
suggestion
264
51
44
false
Provide "equals" and "hashCode" for Getter/Setter to fix KT-13490
4,236
JetBrains/kotlin
51,705
Kotlin
scaventz
scaventz
Review this pull request change. Language: Kotlin File: core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt PR Title: Provide "equals" and "hashCode" for Getter/Setter to fix KT-13490 BEFORE CODE: import kotlin.reflect.KProperty0 internal open class KProperty0Impl<out V> : KProperty0<V>, KPropert...
```property.name``` is not sufficient as a basis for equality, and it is not feasible to use ```property==that.property``` directly because it requires equality of ```rawBoundReceiver```. So ```property.toString() == that.property.toString()``` seems good to me.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license * that can be found in the LICENSE file. */ package org.jetbrains.kotlin.backend.konan.objcexport import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescri...
Does it check `shouldExportKDoc`?
/* * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license * that can be found in the LICENSE file. */ package org.jetbrains.kotlin.backend.konan.objcexport import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescri...
@@ -15,18 +15,14 @@ object StubRenderer { fun render(stub: Stub<*>): List<String> = render(stub, false) internal fun render(stub: Stub<*>, shouldExportKDoc: Boolean): List<String> = collect { stub.run { - val kDoc = if (shouldExportKDoc) { - this.descriptor?.extractKDocStrin...
kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/StubRenderer.kt
19
Kotlin
0.286
question
33
44
44
false
[Native] Add test for -Xexport-kdoc
4,249
JetBrains/kotlin
51,705
Kotlin
SvyatoslavScherbina
knebekaizer
Review this pull request change. Language: Kotlin File: kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/StubRenderer.kt PR Title: [Native] Add test for -Xexport-kdoc BEFORE CODE: /* * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed ...
Does it check `shouldExportKDoc`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
operator fun List<String>.unaryPlus() { collection += this } } } fun formatGenerics(buffer: Appendable, generics: List<Any>) { if (generics.isNotEmpty()) { generics.joinTo(buffer, separator = ", ", prefix = "<", postfix = ">") } } private fun DeclarationDescriptor.extra...
What happens if the kdoc is like ``` /* foo */ ``` ? I guess this might be easy to handle.
private class Collector { private val collection: MutableList<String> = mutableListOf() fun build(): List<String> = collection operator fun String.unaryPlus() { collection += this } operator fun List<String>.unaryPlus() { collection += this ...
@@ -221,3 +217,19 @@ private fun DeclarationDescriptor.extractKDocString(): String? { ?: extractSerializedKdocString() } +/** + * Parse kdoc removing surrounding stuff including lead and tail blank lines. + * Remove each line indent with leading asterisk. + * @return non-empty list of strings or null + ...
kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/StubRenderer.kt
26
Kotlin
0.714
question
99
34
26
false
[Native] Add test for -Xexport-kdoc
4,249
JetBrains/kotlin
51,705
Kotlin
SvyatoslavScherbina
knebekaizer
Review this pull request change. Language: Kotlin File: kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/StubRenderer.kt PR Title: [Native] Add test for -Xexport-kdoc BEFORE CODE: operator fun List<String>.unaryPlus() { collection += this ...
What happens if the kdoc is like ``` /* foo */ ``` ? I guess this might be easy to handle.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
collection += this } operator fun List<String>.unaryPlus() { collection += this } } } fun formatGenerics(buffer: Appendable, generics: List<Any>) { if (generics.isNotEmpty()) { generics.joinTo(buffer, separator = ", ", prefix = "<", postfix = ">") } ...
Do we really need to parse the comments to fix indents? I mean, why is it not enough to split a comment into lines, trim starts and then join lines back?
collector.p() return collector.build() } private class Collector { private val collection: MutableList<String> = mutableListOf() fun build(): List<String> = collection operator fun String.unaryPlus() { collection += this } operator fun List<...
@@ -221,3 +217,19 @@ private fun DeclarationDescriptor.extractKDocString(): String? { ?: extractSerializedKdocString() } +/** + * Parse kdoc removing surrounding stuff including lead and tail blank lines. + * Remove each line indent with leading asterisk. + * @return non-empty list of strings or null + ...
kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/StubRenderer.kt
26
Kotlin
0.357
question
154
37
29
false
[Native] Add test for -Xexport-kdoc
4,249
JetBrains/kotlin
51,705
Kotlin
SvyatoslavScherbina
knebekaizer
Review this pull request change. Language: Kotlin File: kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/StubRenderer.kt PR Title: [Native] Add test for -Xexport-kdoc BEFORE CODE: collection += this } operator fun List<String>.una...
Do we really need to parse the comments to fix indents? I mean, why is it not enough to split a comment into lines, trim starts and then join lines back?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
private val _basicDeclarationCheckers: MutableSet<FirBasicDeclarationChecker> = mutableSetOf() private val _memberDeclarationCheckers: MutableSet<FirMemberDeclarationChecker> = mutableSetOf() private val _functionCheckers: MutableSet<FirFunctionChecker> = mutableSetOf() private val _propertyCheckers: M...
This file and below are automatically generated, but I don't see any counterpart change in the generator?
override val variableAssignmentCfaBasedCheckers: Set<AbstractFirPropertyInitializationChecker> get() = _variableAssignmentCfaBasedCheckers private val _basicDeclarationCheckers: MutableSet<FirBasicDeclarationChecker> = mutableSetOf() private val _memberDeclarationCheckers: MutableSet<FirMemberDecla...
@@ -49,14 +49,14 @@ internal class ComposedDeclarationCheckers : DeclarationCheckers() { @CheckersComponentInternal internal fun register(checkers: DeclarationCheckers) { - _basicDeclarationCheckers += checkers.allBasicDeclarationCheckers - _memberDeclarationCheckers += checkers.allMemberDecla...
compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/ComposedDeclarationCheckers.kt
26
Kotlin
0.429
question
105
27
31
false
FIR checker: fix checker registration
4,250
JetBrains/kotlin
51,705
Kotlin
jsjeon
tgeng
Review this pull request change. Language: Kotlin File: compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/ComposedDeclarationCheckers.kt PR Title: FIR checker: fix checker registration BEFORE CODE: private val _basicDeclarationCheckers: MutableSet<FirBasicDeclarationChecker> = mu...
This file and below are automatically generated, but I don't see any counterpart change in the generator?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*/ abstract class DeclarationCheckers { companion object { val EMPTY: DeclarationCheckers = object : DeclarationCheckers() {} } open val basicDeclarationCheckers: Set<FirBasicDeclarationChecker> = emptySet() open val memberDeclarationCheckers: Set<FirMemberDeclarationChecker> = emptySet() ...
I don't think I understand this change... Rather, should we change `allFunctionCheckers` to be `functionCheckers + allMemberDeclarationCheckers` instead?
*/ abstract class DeclarationCheckers { companion object { val EMPTY: DeclarationCheckers = object : DeclarationCheckers() {} } open val basicDeclarationCheckers: Set<FirBasicDeclarationChecker> = emptySet() open val memberDeclarationCheckers: Set<FirMemberDeclarationChecker> = emptySet() ...
@@ -37,6 +37,6 @@ abstract class DeclarationCheckers { @CheckersComponentInternal internal val allPropertyCheckers: Set<FirPropertyChecker> get() = propertyCheckers + allMemberDeclarationCheckers @CheckersComponentInternal internal val allClassCheckers: Set<FirClassChecker> get() = classCheckers + allBasicDec...
compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt
26
Kotlin
0.571
question
153
29
31
false
FIR checker: fix checker registration
4,250
JetBrains/kotlin
51,705
Kotlin
jsjeon
tgeng
Review this pull request change. Language: Kotlin File: compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt PR Title: FIR checker: fix checker registration BEFORE CODE: */ abstract class DeclarationCheckers { companion object { val EMPTY: Declaration...
I don't think I understand this change... Rather, should we change `allFunctionCheckers` to be `functionCheckers + allMemberDeclarationCheckers` instead?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.jetbrains.kotlin.fir.declarations.* @OptIn(CheckersComponentInternal::class) class DeclarationCheckersDiagnosticComponent( collector: AbstractDiagnosticCollector, private val checkers: DeclarationCheckers = collector.session.checkersComponent.declarationCheckers, ) : AbstractDiagnosticCollectorCompo...
`allFunctionCheckers` should instead include `checkers.memberDeclarationCheckers`
import org.jetbrains.kotlin.fir.declarations.* @OptIn(CheckersComponentInternal::class) class DeclarationCheckersDiagnosticComponent( collector: AbstractDiagnosticCollector, private val checkers: DeclarationCheckers = collector.session.checkersComponent.declarationCheckers, ) : AbstractDiagnosticCollectorCompo...
@@ -13,65 +14,66 @@ import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.declarations.* +@OptIn(CheckersComponentInternal::class) class DeclarationCheckersDiagnosticComponent( col...
compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt
26
Kotlin
0.429
suggestion
81
51
51
false
FIR checker: fix checker registration
4,250
JetBrains/kotlin
51,705
Kotlin
punzki
tgeng
Review this pull request change. Language: Kotlin File: compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt PR Title: FIR checker: fix checker registration BEFORE CODE: import org.jetbrains.kotlin.fir.declarations.* @OptIn(CheckersComponentInt...
`allFunctionCheckers` should instead include `checkers.memberDeclarationCheckers`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} clazz.isEnumClassOrSpecializedEnumEntryClass() -> { // isEnum returns false for specialized enum constants (enum entries which are anonymous enum subclasses) val classId = (if (clazz.isEnum) clazz else clazz.enclosingClass).classId visitor.visitE...
It seems like `?: continue` would make more sense here rather than `?: return`, don't you think? Because if the visitor is not interested in one annotation instance in the array, we shouldn't disregard the whole array, but rather try to visit the rest too. At this point it makes no difference, I think, because only ...
} clazz.isEnumClassOrSpecializedEnumEntryClass() -> { // isEnum returns false for specialized enum constants (enum entries which are anonymous enum subclasses) val classId = (if (clazz.isEnum) clazz else clazz.enclosingClass).classId visitor.visitE...
@@ -243,6 +243,10 @@ private object ReflectClassStructure { componentType == Class::class.java -> for (element in value as Array<*>) { v.visitClassLiteral((element as Class<*>).classLiteralValue()) } + Annotation::class.java.isAssigna...
core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/components/ReflectKotlinClass.kt
26
Kotlin
0.643
refactor
527
51
51
false
Support array of annotation in KotlinJvmBinaryClass
4,258
JetBrains/kotlin
51,705
Kotlin
udalov
ting-yuan
Review this pull request change. Language: Kotlin File: core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/components/ReflectKotlinClass.kt PR Title: Support array of annotation in KotlinJvmBinaryClass BEFORE CODE: } clazz.isEnumClassOrSpecializedEnumEntryClass() -> { ...
It seems like `?: continue` would make more sense here rather than `?: return`, don't you think? Because if the visitor is not interested in one annotation instance in the array, we shouldn't disregard the whole array, but rather try to visit the rest too. At this point it makes no difference, I think, because only ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
val realVar = variableStorage.getOrCreateRealVariable(flow, fir.symbol, fir) realVar?.to(simpleTypeStatement(realVar, isNegated, function.session.builtinTypes.anyType.type))?.let { mutableMapOf(it) } } is ConeLogicalNot -> arg.buildTypeStatements(function, logicSystem, variableSt...
Probably it would be a good idea to move this and previous function in some other place
val fir = function.getParameterSymbol(arg.parameterIndex, context).fir val realVar = variableStorage.getOrCreateRealVariable(flow, fir.symbol, fir) realVar?.to(simpleTypeStatement(realVar, isNegated, function.session.builtinTypes.anyType.type))?.let { mutableMapOf(it) } } ...
@@ -202,6 +202,9 @@ object FirReturnsImpliesAnalyzer : FirControlFlowChecker() { fun KotlinTypeMarker.isSupertypeOf(context: TypeCheckerProviderContext, type: KotlinTypeMarker?) = type != null && AbstractTypeChecker.isSubtypeOf(context, type, this) + fun KotlinTypeMarker.isSubtypeOf(context: TypeChec...
compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirReturnsImpliesAnalyzer.kt
26
Kotlin
0.286
refactor
87
51
51
false
[FIR] Add FINAL_UPPER_BOUND diagnostic
4,270
JetBrains/kotlin
51,705
Kotlin
mglukhikh
zveznicht
Review this pull request change. Language: Kotlin File: compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirReturnsImpliesAnalyzer.kt PR Title: [FIR] Add FINAL_UPPER_BOUND diagnostic BEFORE CODE: val realVar = variableStorage.getOrCreateRealVariable(flow, fir.symbol, fir) real...
Probably it would be a good idea to move this and previous function in some other place
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
val c: IrConstructor = searchForDeclaration(descriptor) ?: compilerContext.symbolTable.referenceConstructor(descriptor).owner c.body = DeclarationIrBuilder(compilerContext, c.symbol, this.startOffset, this.endOffset).irBlockBody( this.startOffset, this.endOffset ) { bodyG...
Are you sure that this won't create unbound type parameter?
) { val c: IrConstructor = searchForDeclaration(descriptor) ?: compilerContext.symbolTable.referenceConstructor(descriptor).owner c.body = DeclarationIrBuilder(compilerContext, c.symbol, this.startOffset, this.endOffset).irBlockBody( this.startOffset, this.endOffset )...
@@ -81,48 +85,128 @@ interface IrBuilderExtension { ) { bodyGen(c) } } - // function will not be created in the real class - fun IrClass.createInlinedFunction( - name: Name, - visibility: DescriptorVisibility, - origin: IrDeclarationOrigin, - returnType: IrType, - ...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt
26
Kotlin
0.357
question
59
51
51
false
Fix IR compilation of serialization
4,276
JetBrains/kotlin
51,705
Kotlin
sandwwraith
shanshin
Review this pull request change. Language: Kotlin File: plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt PR Title: Fix IR compilation of serialization BEFORE CODE: val c: IrConstructor = searchForDeclaration(descriptor...
Are you sure that this won't create unbound type parameter?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
mapOf( kPropertyIrClass.typeParameters[0].symbol to targetIrType, kPropertyIrClass.typeParameters[1].symbol to containingClass.defaultType, ) ).toKotlinType() val targetKotlinType = targetIrType.toKotlinType() val propertyDescriptor = ...
you can use `irInvoke` to avoid multi-line `putXXX` calls
val kPropertyKotlinType = kPropertyIrClass.defaultType.substitute( mapOf( kPropertyIrClass.typeParameters[0].symbol to targetIrType, kPropertyIrClass.typeParameters[1].symbol to containingClass.defaultType, ) ).toKotlinType() val targetKot...
@@ -81,48 +85,128 @@ interface IrBuilderExtension { ) { bodyGen(c) } } - // function will not be created in the real class - fun IrClass.createInlinedFunction( - name: Name, - visibility: DescriptorVisibility, - origin: IrDeclarationOrigin, - returnType: IrType, - ...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt
26
Kotlin
0.429
suggestion
57
51
51
false
Fix IR compilation of serialization
4,276
JetBrains/kotlin
51,705
Kotlin
sandwwraith
shanshin
Review this pull request change. Language: Kotlin File: plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt PR Title: Fix IR compilation of serialization BEFORE CODE: mapOf( kPropertyIrClass.typeParame...
you can use `irInvoke` to avoid multi-line `putXXX` calls
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} } } // Missing field exception parts val exceptionFqn = getSerializationPackageFqn(MISSING_FIELD_EXC) val exceptionCtorRef = compilerContext.referenceConstructors(exceptionFqn) .single { it.owner.valueParameters.singl...
'internal' comment here may create confusion that it is related to internal visibility, not the `isInternalSerializable` function. So i'd rather avoid this word here
} // Missing field exception parts val exceptionFqn = getSerializationPackageFqn(MISSING_FIELD_EXC) val exceptionCtorRef = compilerContext.referenceConstructors(exceptionFqn) .single { it.owner.valueParameters.singleOrNull()?.type?.isString() == true } ...
@@ -118,7 +114,14 @@ class SerializableIrGenerator( // for abstract classes fields MUST BE checked in child classes !serializableDescriptor.isAbstractSerializableClass() && !serializableDescriptor.isSealedSerializableClass() ) { - generateGoldenMaskCheck(see...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt
26
Kotlin
0.571
suggestion
165
51
51
false
Fix IR compilation of serialization
4,276
JetBrains/kotlin
51,705
Kotlin
sandwwraith
shanshin
Review this pull request change. Language: Kotlin File: plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt PR Title: Fix IR compilation of serialization BEFORE CODE: } } } ...
'internal' comment here may create confusion that it is related to internal visibility, not the `isInternalSerializable` function. So i'd rather avoid this word here
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
statementsAfterSerializableProperty[prop.descriptor]?.forEach { +it } continue } else { irThrow(irInvoke(null, exceptionCtorRef, irString(prop.name), typeHint = exceptionType)) } } ...
formatting ```suggestion val serialDescriptorGetter = compilerContext.referenceClass(serializer.fqNameSafe)?.getPropertyGetter(SERIAL_DESC_FIELD) ?: throw Exception("No class with name ${serializer.fqNameSafe}") ```
} else { irThrow(irInvoke(null, exceptionCtorRef, irString(prop.name), typeHint = exceptionType)) } } val propNotSeenTest = irEquals( irInt(0), irBinOp( ...
@@ -169,47 +172,33 @@ class SerializableIrGenerator( } } - private fun IrBlockBodyBuilder.getSerialDescriptorExpr(): IrExpression { - return if (serializableDescriptor.isStaticSerializable) { - val serializer = serializableDescriptor.classSerializer!! - val serial...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt
26
Kotlin
0.929
suggestion
236
51
51
false
Fix IR compilation of serialization
4,276
JetBrains/kotlin
51,705
Kotlin
sandwwraith
shanshin
Review this pull request change. Language: Kotlin File: plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt PR Title: Fix IR compilation of serialization BEFORE CODE: statementsAfterSerializableProp...
formatting ```suggestion val serialDescriptorGetter = compilerContext.referenceClass(serializer.fqNameSafe)?.getPropertyGetter(SERIAL_DESC_FIELD) ?: throw Exception("No class with name ${serializer.fqNameSafe}") ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} } } // Missing field exception parts val exceptionFqn = getSerializationPackageFqn(MISSING_FIELD_EXC) val exceptionCtorRef = compilerContext.referenceConstructors(exceptionFqn) .single { it.owner.valueParameters.singl...
```suggestion // synthetic constructor is created only for internally serializable classes - so companion definitely exists ```
} } } // Missing field exception parts val exceptionFqn = getSerializationPackageFqn(MISSING_FIELD_EXC) val exceptionCtorRef = compilerContext.referenceConstructors(exceptionFqn) .single { it.owner.valueParameters.singl...
@@ -116,7 +112,14 @@ class SerializableIrGenerator( // for abstract classes fields MUST BE checked in child classes !serializableDescriptor.isAbstractSerializableClass() && !serializableDescriptor.isSealedSerializableClass() ) { - generateGoldenMaskCheck(see...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt
26
Kotlin
0.714
suggestion
149
51
51
false
Fix IR compilation of serialization
4,276
JetBrains/kotlin
51,705
Kotlin
sandwwraith
shanshin
Review this pull request change. Language: Kotlin File: plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt PR Title: Fix IR compilation of serialization BEFORE CODE: } } } ...
```suggestion // synthetic constructor is created only for internally serializable classes - so companion definitely exists ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
fun dfs(current: AbstractInsnNode): List<SuspensionPoint> { if (!visited.add(current)) return emptyList() suspensionPointEnds[current]?.let { return listOf(it) } return cfg.getPredecessorsIndices(current).flatMap { dfs(instructions[it]) } } ...
This code block has just been moved earlier. It is unchanged.
fun dfs(current: AbstractInsnNode): List<SuspensionPoint> { if (!visited.add(current)) return emptyList() suspensionPointEnds[current]?.let { return listOf(it) } return cfg.getPredecessorsIndices(current).flatMap { dfs(instructions[it]) } } ...
@@ -759,6 +759,35 @@ class CoroutineTransformerMethodVisitor( referencesToCleanBySuspensionPointIndex += currentSpilledReferencesCount to predSpilledReferencesCount } + // Calculate debug metadata mapping before modifying method node to make it easier to locate
compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt
26
Kotlin
0.286
suggestion
61
51
51
false
[JVM] Fix uninitialized locals after coroutine transformation.
4,334
JetBrains/kotlin
51,705
Kotlin
madsager
madsager
Review this pull request change. Language: Kotlin File: compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt PR Title: [JVM] Fix uninitialized locals after coroutine transformation. BEFORE CODE: fun dfs(current: AbstractInsnNode): List<SuspensionPoint> { ...
This code block has just been moved earlier. It is unchanged.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType class AddWhenElseBranchFix(element: KtWhenExpression) : KotlinPsiOnlyQuickFixAction<KtWhenExpression>(element) { override fun getFamilyName() = KotlinBundle.message("fix.add.else.branch.when") ove...
Can you put this directly on the companion object? Just to make it consistent with a few others (see`ReplaceWithDotCallFix`)
import org.jetbrains.kotlin.psi.KtWhenExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType class AddWhenElseBranchFix(element: KtWhenExpression) : KotlinPsiOnlyQuickFixAction<KtWhenExpression>(element) { override fun getFamilyName() = KotlinB...
@@ -49,9 +38,9 @@ class AddWhenElseBranchFix(element: KtWhenExpression) : KotlinQuickFixAction<KtW editor?.caretModel?.moveToOffset(endOffset + 1) } - companion object : KotlinSingleIntentionActionFactory() { - public override fun createAction(diagnostic: Diagnostic): AddWhenElseBranchFix? { -...
idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddWhenElseBranchFix.kt
26
Kotlin
0.571
suggestion
124
31
32
false
FIR IDE: add quickfix AddWhenElseBranchFix
4,344
JetBrains/kotlin
51,705
Kotlin
punzki
tgeng
Review this pull request change. Language: Kotlin File: idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddWhenElseBranchFix.kt PR Title: FIR IDE: add quickfix AddWhenElseBranchFix BEFORE CODE: import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.getNonStri...
Can you put this directly on the companion object? Just to make it consistent with a few others (see`ReplaceWithDotCallFix`)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// Before the fix to kt46389, the IR backend would have added a bridge // for `h$default` in `B`, which would have lead both calls to use "K" // as the default value. This would arguably be less surprising, but is // impossible to match without jvm-default on the JVM(-IR)backend. // // Meanwhile, the two calls using "...
Looks like this test fails with ` java.lang.ClassFormatError: Method h$default in class I has illegal modifiers: 0x1009` on both backends
// The code in this test should be prohibited in the frontend, see KT-36188. // Before the fix to kt46389, the IR backend would have added a bridge // for `h$default` in `B`, which would have lead both calls to use "K" // as the default value. This would arguably be less surprising, but is // impossible to match witho...
@@ -0,0 +1,29 @@ +// IGNORE_BACKEND: JS, JS_IR +// !JVM_DEFAULT_MODE: all + +// The code in this test should be prohibited in the frontend, see KT-36188. + +// Before the fix to kt46389, the IR backend would have added a bridge +// for `h$default` in `B`, which would have lead both calls to use "K" +// as the default v...
compiler/testData/codegen/box/bridges/kt46389_jvmDefault.kt
26
Kotlin
0.643
bug
137
26
27
false
JVM IR: Don't generate bridges for default argument stubs (KT-46389)
4,359
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: compiler/testData/codegen/box/bridges/kt46389_jvmDefault.kt PR Title: JVM IR: Don't generate bridges for default argument stubs (KT-46389) BEFORE CODE: // Before the fix to kt46389, the IR backend would have added a bridge // for `h$default` in `B`, which wou...
Looks like this test fails with ` java.lang.ClassFormatError: Method h$default in class I has illegal modifiers: 0x1009` on both backends
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
registerBuiltinBinaryOp(FLOAT, IrBuiltIns.OperatorNames.IEEE754_EQUALS) { a, b -> a == b } registerBuiltinBinaryOp(INT, IrBuiltIns.OperatorNames.LESS) { a, b -> a < b } registerBuiltinBinaryOp(INT, IrBuiltIns.OperatorNames.LESS_OR_EQUAL) { a, b -> a <= b } registerBuilti...
This is now used only once below in `constType.isString()`, and probably can be replaced with `type.isStringClassType()`
registerBuiltinBinaryOp(FLOAT, IrBuiltIns.OperatorNames.IEEE754_EQUALS) { a, b -> a == b } registerBuiltinBinaryOp(INT, IrBuiltIns.OperatorNames.LESS) { a, b -> a < b } registerBuiltinBinaryOp(INT, IrBuiltIns.OperatorNames.LESS_OR_EQUAL) { a, b -> a <= b } registerBuilti...
@@ -107,16 +107,16 @@ class FoldConstantLowering( private fun buildIrConstant(startOffset: Int, endOffset: Int, type: IrType, v: Any?): IrConst<*> { val constType = type.makeNotNull()
compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/optimizations/FoldConstantLowering.kt
26
Kotlin
0.714
suggestion
120
51
51
false
[JVM IR] Fix constant folding to use basic types always.
4,367
JetBrains/kotlin
51,705
Kotlin
udalov
madsager
Review this pull request change. Language: Kotlin File: compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/optimizations/FoldConstantLowering.kt PR Title: [JVM IR] Fix constant folding to use basic types always. BEFORE CODE: registerBuiltinBinaryOp(FLOAT, IrBuiltIns.OperatorNames.I...
This is now used only once below in `constType.isString()`, and probably can be replaced with `type.isStringClassType()`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
public class Usage { public static final String BAT_DELIMITER_CHARACTERS_NOTE = "Note: on Windows, arguments that contain delimiter characters (whitespace, =, ;, ,) need to be surrounded with double quotes (\")."; // The magic number 29 corresponds to the similar padding width in javac and scalac ...
Why is this check needed? Isn't `-J` also supported for JS and Native compilers?
public class Usage { public static final String BAT_DELIMITER_CHARACTERS_NOTE = "Note: on Windows, arguments that contain delimiter characters (whitespace, =, ;, ,) need to be surrounded with double quotes (\")."; // The magic number 29 corresponds to the similar padding width in javac and scalac ...
@@ -53,6 +53,8 @@ appendln(sb, "Advanced options are non-standard and may be changed or removed without any notice."); } else { + if(tool.executableScriptFileName().equals("kotlinc-jvm"))
compiler/cli/src/org/jetbrains/kotlin/cli/common/Usage.java
26
Java
0.357
question
80
51
51
false
CLI: Add documentation for -J argument in 'kotlinc -help'
4,369
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Java File: compiler/cli/src/org/jetbrains/kotlin/cli/common/Usage.java PR Title: CLI: Add documentation for -J argument in 'kotlinc -help' BEFORE CODE: public class Usage { public static final String BAT_DELIMITER_CHARACTERS_NOTE = "Note: on Windows, argum...
Why is this check needed? Isn't `-J` also supported for JS and Native compilers?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// TARGET_PLATFORM: JVM // FILE: I.java public interface I<T> { public T create(); } // FILE: box.kt // A specific bytecode pattern here may confuse POP propagation. inline fun <reified T, V : Any> I<V>.bar(default: T, crossinline baz: V.(T) -> T) = u@{ it: Any? -> create().baz(it as? T ?: return@u default) } ...
`TARGET_BACKEND` + regenerate tests pls. But also consider moving this test to `boxInline`, to test the two-module scenario too
// TARGET_BACKEND: JVM // FILE: I.java public interface I<T> { public T create(); } // FILE: box.kt // A specific bytecode pattern here may confuse POP propagation. inline fun <reified T, V : Any> I<V>.bar(default: T, crossinline baz: V.(T) -> T) = u@{ it: Any? -> create().baz(it as? T ?: return@u default) } ...
@@ -0,0 +1,12 @@ +// TARGET_PLATFORM: JVM
compiler/testData/codegen/box/optimizations/kt46921.kt
1
Kotlin
0.571
suggestion
130
13
13
false
JVM: be more careful when removing unused constants
4,408
JetBrains/kotlin
51,705
Kotlin
udalov
pyos
Review this pull request change. Language: Kotlin File: compiler/testData/codegen/box/optimizations/kt46921.kt PR Title: JVM: be more careful when removing unused constants BEFORE CODE: // TARGET_PLATFORM: JVM // FILE: I.java public interface I<T> { public T create(); } // FILE: box.kt // A specific bytecode ...
`TARGET_BACKEND` + regenerate tests pls. But also consider moving this test to `boxInline`, to test the two-module scenario too
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license * that can be found in the LICENSE file. */ package org.jetbrains.kotlin.backend.konan.objcexport import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescri...
Why add the assert here, if the code below checks the same and gracefully handles the case when it is not true?
/* * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license * that can be found in the LICENSE file. */ package org.jetbrains.kotlin.backend.konan.objcexport import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescri...
@@ -18,9 +18,15 @@ object StubRenderer { val kDoc = if (shouldExportKDoc) { descriptor?.extractKDocString()?.let { if (it.isNotEmpty()) { // sometimes `findDoc` return empty string; is it a bug? + assert(it.startsWith("/**") && it.endsWith("*/")...
kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/StubRenderer.kt
21
Kotlin
0.5
question
111
46
46
false
[Native] Clean up nested comment when exporting kdoc to objc header
4,410
JetBrains/kotlin
51,705
Kotlin
SvyatoslavScherbina
knebekaizer
Review this pull request change. Language: Kotlin File: kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/StubRenderer.kt PR Title: [Native] Clean up nested comment when exporting kdoc to objc header BEFORE CODE: /* * Copyright 2010-2018 JetBrains s.r.o. Use ...
Why add the assert here, if the code below checks the same and gracefully handles the case when it is not true?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
val typeArgument = supertypeArgument.type if (typeArgument.isReifiedTypeParameter) { reifiedTypeParametersUsages.addUsedReifiedParameter(typeArgument.classifierOrFail.cast<IrTypeParameterSymbol>().owner.name.asString()) } else { pro...
What will be if clinit already generated (or it's last operation)? // cc @ilmirus
val typeArgument = supertypeArgument.type if (typeArgument.isReifiedTypeParameter) { reifiedTypeParametersUsages.addUsedReifiedParameter(typeArgument.classifierOrFail.cast<IrTypeParameterSymbol>().owner.name.asString()) } else { pro...
@@ -197,22 +197,19 @@ class ClassCodegen private constructor( } } - fun generateAssertFieldIfNeeded(generatingClInit: Boolean): IrExpression? { if (irClass.hasAssertionsDisabledField(context)) return null val topLevelClass = generateSequence(this) { it.parentClassCode...
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt
26
Kotlin
0.214
question
82
51
51
false
JVM_IR: fix a couple issues with inlining JVM assertions
4,481
JetBrains/kotlin
51,705
Kotlin
max-kammerer
pyos
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt PR Title: JVM_IR: fix a couple issues with inlining JVM assertions BEFORE CODE: val typeArgument = supertypeArgument.type if (typeArgument.isRe...
What will be if clinit already generated (or it's last operation)? // cc @ilmirus
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
val reificationArgument = cur.reificationArgument val parameterName = reificationArgument!!.parameterName result.reifiedTypeParametersUsages.addUsedReifiedParameter(parameterName) } } ...
Are all these cases are checked by tests?
val reificationArgument = cur.reificationArgument val parameterName = reificationArgument!!.parameterName result.reifiedTypeParametersUsages.addUsedReifiedParameter(parameterName) } } ...
@@ -558,21 +558,17 @@ class MethodInliner( ) } else if (fieldInsnNode.isCheckAssertionsStatus()) { fieldInsnNode.owner = inlineCallSiteInfo.ownerClassName - if (inliningContext.isInliningLambda) { - ...
compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt
26
Kotlin
0.071
question
41
51
51
false
JVM_IR: fix a couple issues with inlining JVM assertions
4,481
JetBrains/kotlin
51,705
Kotlin
max-kammerer
pyos
Review this pull request change. Language: Kotlin File: compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt PR Title: JVM_IR: fix a couple issues with inlining JVM assertions BEFORE CODE: val reificationArgument = cur.reificationArgument ...
Are all these cases are checked by tests?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/** * Adaptor for parsing string and returning the closest Float value to the real number in the string. * * @param string the String that will be parsed to a Float * @return the Float number closest to the real number * @exception NumberFormatException if the String doesn't represent a num...
(minor) Unfinished description
/** * Adaptor for parsing string and returning the closest Float value to the real number in the string. * * @param string the String that will be parsed to a Float * @return the Float number closest to the real number * @exception NumberFormatException if the String doesn't represent a num...
@@ -60,12 +60,107 @@ object FloatingPointParser { * Exponent is 10 based. * Eg. double's min value is 5e-324, so double "1e-325" should be parsed as 0.0 */ - private val FLOAT_MIN_EXP = -46 - private val FLOAT_MAX_EXP = 38 - private val DOUBLE_MIN_EXP = -324 - private val DOUBLE_MAX_EXP = ...
kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/FloatingPointParser.kt
26
Kotlin
0.071
suggestion
30
51
51
false
[Native, All platforms] HotFix of the incorrect parsing of long strings to Float and Double
4,492
JetBrains/kotlin
51,705
Kotlin
ilmat192
orchestr7
Review this pull request change. Language: Kotlin File: kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/FloatingPointParser.kt PR Title: [Native, All platforms] HotFix of the incorrect parsing of long strings to Float and Double BEFORE CODE: /** * Adaptor for parsing string and returning the c...
(minor) Unfinished description
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// Check if the value could be a hexadecimal representation and parse it properly. if (parseAsHex(s)) { return hexParserImpl(s) } val info = initialParse(s) // Two kinds of situation will directly return 0.0/0.0f: // 1. info.s is 0; // 2. actual expo...
What if make the method `inline` with `reified T`? It will also allow us to get rid of boxing. I don't think that boxing has significant performance impact comparing to the other parsing machinery, but still.
// Check if the value could be a hexadecimal representation and parse it properly. if (parseAsHex(s)) { return hexParserImpl(s) } val info = initialParse(s) // Two kinds of situation will directly return 0.0/0.0f: // 1. info.s is 0; // 2. actual expo...
@@ -60,12 +60,107 @@ object FloatingPointParser { * Exponent is 10 based. * Eg. double's min value is 5e-324, so double "1e-325" should be parsed as 0.0 */ - private val FLOAT_MIN_EXP = -46 - private val FLOAT_MAX_EXP = 38 - private val DOUBLE_MIN_EXP = -324 - private val DOUBLE_MAX_EXP = ...
kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/FloatingPointParser.kt
26
Kotlin
0.714
performance
208
51
51
false
[Native, All platforms] HotFix of the incorrect parsing of long strings to Float and Double
4,492
JetBrains/kotlin
51,705
Kotlin
ilmat192
orchestr7
Review this pull request change. Language: Kotlin File: kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/FloatingPointParser.kt PR Title: [Native, All platforms] HotFix of the incorrect parsing of long strings to Float and Double BEFORE CODE: // Check if the value could be a hexadecimal represen...
What if make the method `inline` with `reified T`? It will also allow us to get rid of boxing. I don't think that boxing has significant performance impact comparing to the other parsing machinery, but still.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assertEquals(10, "a".toByte(16)) assertEquals(170, "aa".toShort(16)) assertEquals(30, "11110".toInt(2)) assertEquals(4294967295, "ffffffff".toLong(16)) assertFailsWith<NumberFormatException> { "ffffffff".toLong(10) } } @Test fun checkDouble() { // ===== toDouble() parsing =======...
What is the difference with the previous check?
assertEquals(10, "a".toByte(16)) assertEquals(170, "aa".toShort(16)) assertEquals(30, "11110".toInt(2)) assertEquals(4294967295, "ffffffff".toLong(16)) assertFailsWith<NumberFormatException> { "ffffffff".toLong(10) } } @Test fun checkDouble() { // ===== toDouble() parsing =======...
@@ -7,19 +7,130 @@ package runtime.text.parse0 import kotlin.test.* -@Test fun runTest() { - println("false".toBoolean()) - println("true".toBoolean()) - println("-1".toByte()) - println("a".toByte(16)) - println("aa".toShort(16)) - println("11110".toInt(2)) - println("ffffffff".toLong(16)) - ...
kotlin-native/backend.native/tests/runtime/text/parse0.kt
26
Kotlin
0.071
question
47
51
51
false
[Native, All platforms] HotFix of the incorrect parsing of long strings to Float and Double
4,492
JetBrains/kotlin
51,705
Kotlin
ilmat192
orchestr7
Review this pull request change. Language: Kotlin File: kotlin-native/backend.native/tests/runtime/text/parse0.kt PR Title: [Native, All platforms] HotFix of the incorrect parsing of long strings to Float and Double BEFORE CODE: assertEquals(10, "a".toByte(16)) assertEquals(170, "aa".toShort(16)) asser...
What is the difference with the previous check?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assertFailsWith<NumberFormatException> { "ffffffff".toLong(10) } } @Test fun checkDouble() { // ===== toDouble() parsing ======= assertEquals(0.5, "0.5".toDouble()) assertEquals(-5000000000.0, "-00000000000000000000.5e10".toDouble()) assertEquals(-0.005, "-00000000000000000000.5e-2".toD...
As far as I see, `assertEquals` [compares](https://github.com/JetBrains/kotlin/blob/f33f3c769f511c2dab71852298219d45991757ff/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Utils.kt#L22) doubles as raw bits. What if `0.0/0.0` returns a `NaN` represented by a different bit sequence than a `NaN` returned by `toD...
assertFailsWith<NumberFormatException> { "ffffffff".toLong(10) } } @Test fun checkDouble() { // ===== toDouble() parsing ======= assertEquals(0.5, "0.5".toDouble()) assertEquals(-5000000000.0, "-00000000000000000000.5e10".toDouble()) assertEquals(-0.005, "-00000000000000000000.5e-2".toD...
@@ -7,19 +7,130 @@ package runtime.text.parse0 import kotlin.test.* -@Test fun runTest() { - println("false".toBoolean()) - println("true".toBoolean()) - println("-1".toByte()) - println("a".toByte(16)) - println("aa".toShort(16)) - println("11110".toInt(2)) - println("ffffffff".toLong(16)) - ...
kotlin-native/backend.native/tests/runtime/text/parse0.kt
26
Kotlin
0.643
question
437
51
51
false
[Native, All platforms] HotFix of the incorrect parsing of long strings to Float and Double
4,492
JetBrains/kotlin
51,705
Kotlin
ilmat192
orchestr7
Review this pull request change. Language: Kotlin File: kotlin-native/backend.native/tests/runtime/text/parse0.kt PR Title: [Native, All platforms] HotFix of the incorrect parsing of long strings to Float and Double BEFORE CODE: assertFailsWith<NumberFormatException> { "ffffffff".toLong(10) } } @Te...
As far as I see, `assertEquals` [compares](https://github.com/JetBrains/kotlin/blob/f33f3c769f511c2dab71852298219d45991757ff/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Utils.kt#L22) doubles as raw bits. What if `0.0/0.0` returns a `NaN` represented by a different bit sequence than a `NaN` returned by `toD...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
++start --length negative = true } else if (c == '+') { ++start --length } if (length == 0) throw NumberFormatException(s) decimal = s.indexOf('.') if (decimal > -1) { shift = end - decimal - 1 ...
@ilmat192 I would also like to refactor this method in the future, as I can see that it can lead to performance degradation in the parsing of strings. Do you have any benchmarks or environments where I can check my fixes? I do not want to break anything in this PR, so I decided not to refactor this part of the compl...
val result = parserImpl(info.s, info.e) return if (info.negative) unaryMinus(result) else result } /** * To unify the logic of Double and Float parsing we need a common method to calculate a negative value. * Unfortunately in this case we need to make uncheck cast to generic type T to...
@@ -74,7 +169,10 @@ object FloatingPointParser { * StringExponentPair will be used to calculate the floating point number by * taking the positive integer the String represents and multiplying by 10 * raised to the power of the exponent. - + * + * This method is not optimal, can cause performa...
kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/FloatingPointParser.kt
26
Kotlin
0.643
performance
361
51
51
false
[Native, All platforms] HotFix of the incorrect parsing of long strings to Float and Double
4,492
JetBrains/kotlin
51,705
Kotlin
orchestr7
orchestr7
Review this pull request change. Language: Kotlin File: kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/FloatingPointParser.kt PR Title: [Native, All platforms] HotFix of the incorrect parsing of long strings to Float and Double BEFORE CODE: ++start --length negative...
@ilmat192 I would also like to refactor this method in the future, as I can see that it can lead to performance degradation in the parsing of strings. Do you have any benchmarks or environments where I can check my fixes? I do not want to break anything in this PR, so I decided not to refactor this part of the compl...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
gradleBuildScript("Lib").appendText( "\ndependencies { implementation(project(':sample-lib')) }" ) val lintTask = ":Lib:lintFlavor1Debug" build(lintTask) { assertSuccessful() assertTasksExecuted(lintTask) // Check that the lint task ran successfully, K...
This test is not related to Android support, so putting it in `KotlinAndroid36GradleIT` doesn't look right, especially since this test will run more than once: here and in the subtype `KotlinAndroid70GradleIT` with a different AGP version.
@Test fun testLintInAndroidProjectsDependingOnMppWithoutAndroid() = with(Project("AndroidProject")) { embedProject(Project("sample-lib", directoryPrefix = "new-mpp-lib-and-app")) gradleBuildScript("Lib").appendText( "\ndependencies { implementation(project(':sample-lib')) }" ...
@@ -427,6 +427,21 @@ open class KotlinAndroid36GradleIT : KotlinAndroid34GradleIT() { assertSuccessful() } } + + @Test + fun testJvmWithJavaConfigurationCache() = + with(Project("mppJvmWithJava", gradleVersionRequirement = GradleVersionRequired.AtLeast("7.1"))) {
libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt
26
Kotlin
0.714
suggestion
239
51
51
false
MPP Gradle - Stop using convention mapping for archive name
4,529
JetBrains/kotlin
51,705
Kotlin
h0tk3y
gavra0
Review this pull request change. Language: Kotlin File: libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt PR Title: MPP Gradle - Stop using convention mapping for archive name BEFORE CODE: gradleBuildScript("Lib").appendTex...
This test is not related to Android support, so putting it in `KotlinAndroid36GradleIT` doesn't look right, especially since this test will run more than once: here and in the subtype `KotlinAndroid70GradleIT` with a different AGP version.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
irProviders: List<IrProvider>, linkerExtensions: Collection<IrDeserializer.IrLinkerExtension>, expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>? = null ): IrModuleFragment { val moduleGenerator = ModuleGenerator(context, expectDescriptorToSymbol) val irMo...
Similarly to deduplicating `JvmIrCodegenFactory`, I'd prefer to do this right away, by passing extra parameters to the existing `generateEvaluatorModuleFragment`. And then, eventually, maybe extract it to a separate method, if it proves to be worthwhile
fragmentContext ) } fun generateModuleFragment( context: GeneratorContext, ktFiles: Collection<KtFile>, irProviders: List<IrProvider>, linkerExtensions: Collection<IrDeserializer.IrLinkerExtension>, expectDescriptorToSymbol: MutableMap<DeclarationDesc...
@@ -94,4 +92,32 @@ class Psi2IrTranslator( return irModule } + + // TODO - De-duplicate this code from generateModuleFragment
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/Psi2IrTranslator.kt
26
Kotlin
0.643
refactor
253
51
37
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/Psi2IrTranslator.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: irProviders: List<IrProvider>, linkerExtensions: Collection<IrDeserializer.IrLinkerExtension>, ...
Similarly to deduplicating `JvmIrCodegenFactory`, I'd prefer to do this right away, by passing extra parameters to the existing `generateEvaluatorModuleFragment`. And then, eventually, maybe extract it to a separate method, if it proves to be worthwhile
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.NotFoundClasses import org.jetbrains.kotlin.ir.IrBuiltIns import org.jetbrains.kotlin.ir.builders.IrGe...
Let's slightly encapsulate this in a new class (`FragmentContext` or something like that?). Among increasing readability a bit, it'll allow to make the map nullable and mutable, and initialized to null at the beginning, so that we could completely skip hash table lookup in `CallGenerator.generateValueReference` in t...
import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.NotFoundClasses import org.jetbrains.kotlin.ir.IrBuiltIns import org.jetbrains.kotlin.ir.builders.IrGe...
@@ -31,7 +32,8 @@ class GeneratorContext private constructor( val extensions: GeneratorExtensions, val typeTranslator: TypeTranslator, override val irBuiltIns: IrBuiltIns, - internal val callToSubstitutedDescriptorMap: MutableMap<IrDeclarationReference, CallableDescriptor> + internal val callToSubs...
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/GeneratorContext.kt
26
Kotlin
0.786
suggestion
341
51
51
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/GeneratorContext.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.De...
Let's slightly encapsulate this in a new class (`FragmentContext` or something like that?). Among increasing readability a bit, it'll allow to make the map nullable and mutable, and initialized to null at the beginning, so that we could completely skip hash table lookup in `CallGenerator.generateValueReference` in t...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.common.serialization import org.jetbrains.kotlin.backend.common.serializ...
Probably this was for debug and is no longer needed?
/* * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.common.serialization import org.jetbrains.kotlin.backend.common.serializ...
@@ -22,7 +22,9 @@ class DescriptorByIdSignatureFinder( private val lookupMode: LookupMode ) { init { - assert(lookupMode != LookupMode.MODULE_ONLY || moduleDescriptor is ModuleDescriptorImpl) + assert(lookupMode != LookupMode.MODULE_ONLY || moduleDescriptor is ModuleDescriptorImpl) { + ...
compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/DescriptorByIdSignatureFinder.kt
26
Kotlin
0.357
bug
52
51
51
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/DescriptorByIdSignatureFinder.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: /* * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming ...
Probably this was for debug and is no longer needed?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
) : SymbolTable(signatureComposer, irFactory, nameProvider) { override fun referenceValueParameter(descriptor: ParameterDescriptor): IrValueParameterSymbol { if (descriptor !is ReceiverParameterDescriptor) return super.referenceValueParameter(descriptor) val finderPredicate = when (val receiverVal...
Remove the `map` call and just do `fragmentInfo.parameters.indexOf(value)`?
irFactory: IrFactory, private val fragmentInfo: EvaluatorFragmentInfo, nameProvider: NameProvider = NameProvider.DEFAULT, ) : SymbolTable(signatureComposer, irFactory, nameProvider) { override fun referenceValueParameter(descriptor: ParameterDescriptor): IrValueParameterSymbol { if (descriptor ...
@@ -0,0 +1,59 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.psi2ir.generators.fragments + +import org.jetbrains.kotlin...
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/FragmentCompilerSymbolTableDecorator.kt
26
Kotlin
0.429
question
75
33
36
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
madsager
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/FragmentCompilerSymbolTableDecorator.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: ) : SymbolTable(signatureComposer, irFactory, nameProvider) { over...
Remove the `map` call and just do `fragmentInfo.parameters.indexOf(value)`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol import org.jetbrains.kotlin.ir.util.IdSignatureComposer import org.jetbrains.kotlin.ir.util.NameProvider import org.jetbrains.kotlin.ir.util.SymbolTable import org.jetbrains.kotlin.psi2ir.generators.fragments.EvaluatorFragmentInfo import org.jetbrains.kotlin.resolve....
Let's go with "Unimplemented" for the text? I'm not sure that this covers all the cases, so unimplemented seems good for now. We should probably explicitly take care off all possibilities here in a follow-up change.
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol import org.jetbrains.kotlin.ir.util.IdSignatureComposer import org.jetbrains.kotlin.ir.util.NameProvider import org.jetbrains.kotlin.ir.util.SymbolTable import org.jetbrains.kotlin.psi2ir.generators.fragments.EvaluatorFragmentInfo import org.jetbrains.kotlin.resolve....
@@ -0,0 +1,59 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.psi2ir.generators.fragments + +import org.jetbrains.kotlin...
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/FragmentCompilerSymbolTableDecorator.kt
26
Kotlin
0.5
suggestion
215
46
49
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
madsager
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/FragmentCompilerSymbolTableDecorator.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: import org.jetbrains.kotlin.ir.symbols.IrValueSymbol import org.jetbrai...
Let's go with "Unimplemented" for the text? I'm not sure that this covers all the cases, so unimplemented seems good for now. We should probably explicitly take care off all possibilities here in a follow-up change.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
override val context: GeneratorContext, private val fragmentInfo: EvaluatorFragmentInfo ) : Generator { private val typeTranslator = context.typeTranslator fun KotlinType.toIrType() = typeTranslator.translateType(this) fun generateClassForCodeFragment(ktFile: KtBlockCodeFragment): IrClass = ...
What purpose does this extra abstract class serve? Could `FragmentDeclarationGenerator` just be open and have two subclasses instead of having this extra abstract class?
import org.jetbrains.kotlin.psi2ir.generators.Generator import org.jetbrains.kotlin.psi2ir.generators.GeneratorContext import org.jetbrains.kotlin.psi2ir.generators.createBodyGenerator import org.jetbrains.kotlin.types.KotlinType open class FragmentDeclarationGenerator( override val context: GeneratorContext, ...
@@ -0,0 +1,56 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.psi2ir.generators.fragments + +import org.jetbrains.kotlin...
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/FragmentDeclarationGenerator.kt
26
Kotlin
0.571
refactor
169
38
51
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
madsager
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/FragmentDeclarationGenerator.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: override val context: GeneratorContext, private val fragmentInfo: Evalu...
What purpose does this extra abstract class serve? Could `FragmentDeclarationGenerator` just be open and have two subclasses instead of having this extra abstract class?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.jvm import org.jetbrains.kotlin.descriptors.SourceFile import org.jetbra...
I'd actually implement all of this since it seems trivial :) ``` override val incompatibility: IncompatibleVersionErrorData<*>? get() = null override val isPreReleaseInvisible: Boolean get() = false override val abiStability: DeserializedContainerAbiStability get() = Deseriali...
/* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.jvm import org.jetbrains.kotlin.descriptors.SourceFile import org.jetbra...
@@ -0,0 +1,41 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.backend.jvm + +import org.jetbrains.kotlin.descriptors.Sou...
compiler/ir/backend.jvm/entrypoint/src/org/jetbrains/kotlin/backend/jvm/FacadeClassSourceShimForFragmentCompilation.kt
26
Kotlin
0.929
suggestion
448
42
44
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/entrypoint/src/org/jetbrains/kotlin/backend/jvm/FacadeClassSourceShimForFragmentCompilation.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: /* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming L...
I'd actually implement all of this since it seems trivial :) ``` override val incompatibility: IncompatibleVersionErrorData<*>? get() = null override val isPreReleaseInvisible: Boolean get() = false override val abiStability: DeserializedContainerAbiStability get() = Deseriali...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.jvm import org.jetbrains.kotlin.descriptors.SourceFile import org.jetbra...
Maybe annotate everything that's used only from the IDE plugin with `@Suppress("unused")`? With a comment saying that this is needed for the plugin... To prevent someone from trying to delete it just because it's marked as unused in the IDE. Unless we're planning to introduce some kind of usages in the main Kotlin r...
/* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.jvm import org.jetbrains.kotlin.descriptors.SourceFile import org.jetbra...
@@ -0,0 +1,41 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.backend.jvm + +import org.jetbrains.kotlin.descriptors.Sou...
compiler/ir/backend.jvm/entrypoint/src/org/jetbrains/kotlin/backend/jvm/FacadeClassSourceShimForFragmentCompilation.kt
21
Kotlin
0.643
suggestion
327
42
44
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/entrypoint/src/org/jetbrains/kotlin/backend/jvm/FacadeClassSourceShimForFragmentCompilation.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: /* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming L...
Maybe annotate everything that's used only from the IDE plugin with `@Suppress("unused")`? With a comment saying that this is needed for the plugin... To prevent someone from trying to delete it just because it's marked as unused in the IDE. Unless we're planning to introduce some kind of usages in the main Kotlin r...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
val backendExtension: JvmBackendExtension, val notifyCodegenStart: () -> Unit, ) override fun generateModule(state: GenerationState, files: Collection<KtFile>) { val input = convertToIr(state, files) doGenerateFilesInternal(input) } @JvmOverloads fun convertToIr(sta...
Minor styling suggestion ```suggestion fragmentContext = if (evaluatorFragmentInfoForPsi2Ir != null) FragmentContext() else null ) ```
val backendExtension: JvmBackendExtension, val notifyCodegenStart: () -> Unit, ) : CodegenFactory.BackendInput override fun convertToIr(input: CodegenFactory.IrConversionInput): JvmIrBackendInput { val (mangler, symbolTable) = if (externalSymbolTable != null) externalMangler...
@@ -71,7 +74,12 @@ open class JvmIrCodegenFactory( } val psi2ir = Psi2IrTranslator(state.languageVersionSettings, Psi2IrConfiguration(ignoreErrors)) val messageLogger = state.configuration[IrMessageLogger.IR_MESSAGE_LOGGER] ?: IrMessageLogger.None - val psi2irContext = psi2ir.creat...
compiler/ir/backend.jvm/entrypoint/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt
26
Kotlin
0.857
suggestion
158
51
51
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/entrypoint/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: val backendExtension: JvmBackendExtension, val notifyCodegenStart: () -> Un...
Minor styling suggestion ```suggestion fragmentContext = if (evaluatorFragmentInfoForPsi2Ir != null) FragmentContext() else null ) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*/ package org.jetbrains.kotlin.psi2ir.generators.fragments import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ParameterDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueDescriptor import org....
I usually prefer to move parameters with default values to the end, to avoid requiring named arguments for subsequent parameters at the call site
*/ package org.jetbrains.kotlin.psi2ir.generators.fragments import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ParameterDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueDescriptor import org....
@@ -0,0 +1,60 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.psi2ir.generators.fragments + +import org.jetbrains.kotlin...
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/FragmentCompilerSymbolTableDecorator.kt
26
Kotlin
0.429
suggestion
145
51
51
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/FragmentCompilerSymbolTableDecorator.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: */ package org.jetbrains.kotlin.psi2ir.generators.fragments import o...
I usually prefer to move parameters with default values to the end, to avoid requiring named arguments for subsequent parameters at the call site
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.psi2ir.generators.fragments import org.jetbrains.kotlin.ir.PsiIrFileEntry import or...
Usually we avoid such double checking with ``` val ktBlockCodeFragment = ktFiles.singleOrNull() as? KtBlockCodeFragment ?: error("Multiple fragments in one compilation not understood and implemented yet") ```
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.psi2ir.generators.fragments import org.jetbrains.kotlin.ir.PsiIrFileEntry import or...
@@ -0,0 +1,49 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.psi2ir.generators.fragments + +import org.jetbrains.kotlin...
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/FragmentModuleGenerator.kt
26
Kotlin
1
suggestion
232
48
46
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/FragmentModuleGenerator.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors...
Usually we avoid such double checking with ``` val ktBlockCodeFragment = ktFiles.singleOrNull() as? KtBlockCodeFragment ?: error("Multiple fragments in one compilation not understood and implemented yet") ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
fragmentContext: FragmentContext? = null ): GeneratorContext { val typeTranslator = TypeTranslatorImpl(symbolTable, languageVersionSettings, moduleDescriptor, extensions = extensions) return GeneratorContext( configuration, moduleDescriptor, bindingContext...
(extremely minor, but since you're using `let`...) ```suggestion FragmentModuleGenerator(context, it) ```
fragmentContext: FragmentContext? = null ): GeneratorContext { val typeTranslator = TypeTranslatorImpl(symbolTable, languageVersionSettings, moduleDescriptor, extensions = extensions) return GeneratorContext( configuration, moduleDescriptor, bindingContext...
@@ -72,9 +77,13 @@ class Psi2IrTranslator( ktFiles: Collection<KtFile>, irProviders: List<IrProvider>, linkerExtensions: Collection<IrDeserializer.IrLinkerExtension>, - expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>? = null + expectDescriptorToSymbol: Muta...
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/Psi2IrTranslator.kt
26
Kotlin
0.714
suggestion
120
49
49
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/Psi2IrTranslator.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: fragmentContext: FragmentContext? = null ): GeneratorContext { val typeTranslator = TypeTran...
(extremely minor, but since you're using `let`...) ```suggestion FragmentModuleGenerator(context, it) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyClass import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource import org.jetbrains.kotlin.types.KotlinType interface DeserializableClass { fun loadIr(): Boolean } open cla...
Would be great to have a comment here, or in the default implementation for JVM, that this behavior is customized in the IDE plugin repo for the purposes of evaluate expression. Just as with unused stuff, to prevent it being refactored with the goal of simplification
import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyClass import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource import org.jetbrains.kotlin.types.KotlinType interface DeserializableClass { fun loadIr(): Boolean } open cla...
@@ -26,6 +26,8 @@ open class StubGeneratorExtensions { stubGenerator: DeclarationStubGenerator, ): IrClass? = null + open fun getContainerSource(descriptor: DeclarationDescriptor): DeserializedContainerSource? = null
compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/StubGeneratorExtensions.kt
26
Kotlin
0.5
refactor
267
51
51
false
[EE-IR] Fragment Compiler Entrypoint in IR Backend
4,542
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/StubGeneratorExtensions.kt PR Title: [EE-IR] Fragment Compiler Entrypoint in IR Backend BEFORE CODE: import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyClass...
Would be great to have a comment here, or in the default implementation for JVM, that this behavior is customized in the IDE plugin repo for the purposes of evaluate expression. Just as with unused stuff, to prevent it being refactored with the goal of simplification
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
&& (descriptor.hasJvmStaticAnnotation() || !checkJvmStaticAnnotation) } private fun isMainWithParameter( declaration: KtDeclaration, checkJvmStaticAnnotation: Boolean ) = declaration is KtNamedFunction && isMain(declaration, checkJvmStaticAnnotation, allowParameterless = fal...
Let's move this function to `findMainClass.kt` since it's not used anywhere else
private fun isMainWithParameter( declaration: KtDeclaration, checkJvmStaticAnnotation: Boolean ) = declaration is KtNamedFunction && isMain(declaration, checkJvmStaticAnnotation, allowParameterless = false) fun getMainFunction(module: ModuleDescriptor): FunctionDescriptor? = getMainFunctio...
@@ -178,8 +176,11 @@ class MainFunctionDetector { return null } - private fun findMainFunction(declarations: List<KtDeclaration>) = - declarations.filterIsInstance<KtNamedFunction>().find { isMain(it) } + fun findMainFunction(declarations: List<KtElement>): KtNamedFunction? =
compiler/frontend/src/org/jetbrains/kotlin/idea/MainFunctionDetector.kt
26
Kotlin
0.429
refactor
80
51
51
false
JVM Cli: Proper Main-class manifest attribute for JvmStatic entry point.
4,546
JetBrains/kotlin
51,705
Kotlin
udalov
ov7a
Review this pull request change. Language: Kotlin File: compiler/frontend/src/org/jetbrains/kotlin/idea/MainFunctionDetector.kt PR Title: JVM Cli: Proper Main-class manifest attribute for JvmStatic entry point. BEFORE CODE: && (descriptor.hasJvmStaticAnnotation() || !checkJvmStaticAnnotation) } ...
Let's move this function to `findMainClass.kt` since it's not used anywhere else
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
declaration: KtDeclaration, checkJvmStaticAnnotation: Boolean ) = declaration is KtNamedFunction && isMain(declaration, checkJvmStaticAnnotation, allowParameterless = false) fun getMainFunction(module: ModuleDescriptor): FunctionDescriptor? = getMainFunction(module, module.getPackage(FqName.ROO...
I suggest to rewrite it a bit, so that in case there are several `main`s in the same file, we would avoid writing any of them to the manifest (might be worth adding a test for this case). Just like we do when several files declare top-level `main`. ``` fun findMainFunction(container: KtDeclarationContainer): KtNa...
) = declaration is KtNamedFunction && isMain(declaration, checkJvmStaticAnnotation, allowParameterless = false) fun getMainFunction(module: ModuleDescriptor): FunctionDescriptor? = getMainFunction(module, module.getPackage(FqName.ROOT)) private fun getMainFunction(module: ModuleDescriptor, packageView: Pa...
@@ -178,8 +176,11 @@ class MainFunctionDetector { return null } - private fun findMainFunction(declarations: List<KtDeclaration>) = - declarations.filterIsInstance<KtNamedFunction>().find { isMain(it) } + fun findMainFunction(declarations: List<KtElement>): KtNamedFunction? = + decla...
compiler/frontend/src/org/jetbrains/kotlin/idea/MainFunctionDetector.kt
26
Kotlin
1
suggestion
668
51
51
false
JVM Cli: Proper Main-class manifest attribute for JvmStatic entry point.
4,546
JetBrains/kotlin
51,705
Kotlin
udalov
ov7a
Review this pull request change. Language: Kotlin File: compiler/frontend/src/org/jetbrains/kotlin/idea/MainFunctionDetector.kt PR Title: JVM Cli: Proper Main-class manifest attribute for JvmStatic entry point. BEFORE CODE: declaration: KtDeclaration, checkJvmStaticAnnotation: Boolean ) = declar...
I suggest to rewrite it a bit, so that in case there are several `main`s in the same file, we would avoid writing any of them to the manifest (might be worth adding a test for this case). Just like we do when several files declare top-level `main`. ``` fun findMainFunction(container: KtDeclarationContainer): KtNa...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.cli.jvm.compiler import org.jetbrains.kotlin.cfg.getElementParentDeclaration imp...
Let's use `getParentOfType<KtClassOrObject>` instead
/* * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.cli.jvm.compiler import org.jetbrains.kotlin.config.LanguageVersionSettings impo...
@@ -5,21 +5,31 @@ package org.jetbrains.kotlin.cli.jvm.compiler +import org.jetbrains.kotlin.cfg.getElementParentDeclaration import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil import org.jetbrains.kotlin.idea.MainFunctionDetector import org.jetbr...
compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/findMainClass.kt
25
Kotlin
0.571
suggestion
52
36
44
false
JVM Cli: Proper Main-class manifest attribute for JvmStatic entry point.
4,546
JetBrains/kotlin
51,705
Kotlin
udalov
ov7a
Review this pull request change. Language: Kotlin File: compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/findMainClass.kt PR Title: JVM Cli: Proper Main-class manifest attribute for JvmStatic entry point. BEFORE CODE: /* * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * ...
Let's use `getParentOfType<KtClassOrObject>` instead
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("StandardKt") package kotlin import kotlin.contra...
Super minor, but do we usually name something like `localLock`? :)
/* * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("StandardKt") package kotlin import kotlin.contra...
@@ -19,13 +19,18 @@ public actual inline fun <R> synchronized(lock: Any, block: () -> R): R { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } + // Force the lock object into a local and use that local for monitor enter/exit. + // This ensures that the JVM can prove that locking is balanced whic...
libraries/stdlib/jvm/src/kotlin/util/Synchronized.kt
25
Kotlin
0.357
suggestion
66
32
37
false
[JVM] Force lock object in JVM `synchronized` implementation into local.
4,555
JetBrains/kotlin
51,705
Kotlin
jsjeon
madsager
Review this pull request change. Language: Kotlin File: libraries/stdlib/jvm/src/kotlin/util/Synchronized.kt PR Title: [JVM] Force lock object in JVM `synchronized` implementation into local. BEFORE CODE: /* * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source ...
Super minor, but do we usually name something like `localLock`? :)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
): IrExpression = // Assertion is safe here because annotation calls and class literals are not allowed in constant initializers generateConstantOrAnnotationValueAsExpression(startOffset, endOffset, constantValue, null, null)!! /** * @return null if the constant value is an unresolved anno...
By the way, the fact that `constantValueType` is used in two places instead of `constantKtType` hints at incorrect generation for annotations too: * in spreadOperatorInAnnotationArguments, `@A(*arrayOf("a"), *arrayOf("b"))` is translated into `A(xs = [['a'], ['b']])` instead of `A(xs = ['a', 'b'])` - this is an IrT...
): IrExpression = // Assertion is safe here because annotation calls and class literals are not allowed in constant initializers generateConstantOrAnnotationValueAsExpression(startOffset, endOffset, constantValue, null, null)!! /** * @return null if the constant value is an unresolved anno...
@@ -36,23 +36,32 @@ abstract class ConstantValueGenerator( startOffset: Int, endOffset: Int, constantValue: ConstantValue<*>, - varargElementType: KotlinType? = null ): IrExpression = // Assertion is safe here because annotation calls and class literals are not allowed in...
compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ConstantValueGenerator.kt
26
Kotlin
0.786
bug
601
51
51
false
IR: do not infer array element types for non-annotation constants
4,570
JetBrains/kotlin
51,705
Kotlin
pyos
pyos
Review this pull request change. Language: Kotlin File: compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ConstantValueGenerator.kt PR Title: IR: do not infer array element types for non-annotation constants BEFORE CODE: ): IrExpression = // Assertion is safe here because annotation calls and class l...
By the way, the fact that `constantValueType` is used in two places instead of `constantKtType` hints at incorrect generation for annotations too: * in spreadOperatorInAnnotationArguments, `@A(*arrayOf("a"), *arrayOf("b"))` is translated into `A(xs = [['a'], ['b']])` instead of `A(xs = ['a', 'b'])` - this is an IrT...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} val call = callExpression.getResolvedCall(bindingContext) ?: return null return call.resultingDescriptor.name.asString() } private fun declareParameter(descriptor: ParameterDescriptor, ktElement: KtPureElement?, irOwnerElement: IrElement, name: Name? = null) = context.symbolT...
`$valueExpression` will always just print the node type, consider adding `getElementTextWithContext()` and/or info about `valueParameterDescriptor`
else -> return null } val call = callExpression.getResolvedCall(bindingContext) ?: return null return call.resultingDescriptor.name.asString() } private fun declareParameter(descriptor: ParameterDescriptor, ktElement: KtPureElement?, irOwnerElement: IrElement, name: Name? =...
@@ -387,11 +387,9 @@ class FunctionGenerator(declarationGenerator: DeclarationGenerator) : Declaratio val constantDefaultValue = ConstantExpressionEvaluator.getConstant(valueExpression, context.bindingContext)?.toConstantValue(valueParameterDescriptor.type) ?: error("Constant valu...
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/FunctionGenerator.kt
26
Kotlin
0.714
suggestion
147
30
31
false
IR: do not infer array element types for non-annotation constants
4,570
JetBrains/kotlin
51,705
Kotlin
udalov
pyos
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/FunctionGenerator.kt PR Title: IR: do not infer array element types for non-annotation constants BEFORE CODE: } val call = callExpression.getResolvedCall(bindingContext) ?: retur...
`$valueExpression` will always just print the node type, consider adding `getElementTextWithContext()` and/or info about `valueParameterDescriptor`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
fun generateConstantValueAsExpression( startOffset: Int, endOffset: Int, constantValue: ConstantValue<*>, ): IrExpression = // Assertion is safe here because annotation calls and class literals are not allowed in constant initializers generateConstantOrAnnotationValueAsEx...
Minor, but not sure if "inferred" is the perfect name... isn't it more of an "expected" type?
fun generateConstantValueAsExpression( startOffset: Int, endOffset: Int, constantValue: ConstantValue<*>, ): IrExpression = // Assertion is safe here because annotation calls and class literals are not allowed in constant initializers generateConstantOrAnnotationValueAsEx...
@@ -36,23 +36,32 @@ abstract class ConstantValueGenerator( startOffset: Int, endOffset: Int, constantValue: ConstantValue<*>, - varargElementType: KotlinType? = null ): IrExpression = // Assertion is safe here because annotation calls and class literals are not allowed in...
compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ConstantValueGenerator.kt
26
Kotlin
0.357
question
93
51
51
false
IR: do not infer array element types for non-annotation constants
4,570
JetBrains/kotlin
51,705
Kotlin
udalov
pyos
Review this pull request change. Language: Kotlin File: compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/ConstantValueGenerator.kt PR Title: IR: do not infer array element types for non-annotation constants BEFORE CODE: fun generateConstantValueAsExpression( startOffset: Int, endOffset: Int,...
Minor, but not sure if "inferred" is the perfect name... isn't it more of an "expected" type?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
private class LocalFunctionContext( override val declaration: IrSimpleFunction, val index: Int, val ownerForLoweredDeclaration: IrDeclarationContainer ) : LocalContextWithClosureAsParameters() { lateinit var closure: Closure override lateinit var transformedDecla...
This is minor, but maybe make it a bit more explicit, by using a custom class instead of `Lazy`? It'll make it easier to inspect where exactly the related logic is (searching for usages of Lazy is costly). E.g. (not sure about the names) ``` private class FieldToBeGenerated(generate: () -> IrField) { pri...
private class LocalFunctionContext( override val declaration: IrSimpleFunction, val index: Int, val ownerForLoweredDeclaration: IrDeclarationContainer ) : LocalContextWithClosureAsParameters() { lateinit var closure: Closure override lateinit var transformedDecl...
@@ -163,36 +165,55 @@ class LocalDeclarationsLowering( override lateinit var transformedDeclaration: IrConstructor } - private class LocalClassContext(val declaration: IrClass, val inInlineFunctionScope: Boolean) : LocalContext() { + private inner class LocalClassContext( + val declaration:...
compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt
26
Kotlin
1
suggestion
508
51
51
false
IR: do not create unused capture fields
4,582
JetBrains/kotlin
51,705
Kotlin
udalov
pyos
Review this pull request change. Language: Kotlin File: compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt PR Title: IR: do not create unused capture fields BEFORE CODE: private class LocalFunctionContext( override val declaration: IrSimpleFunction, ...
This is minor, but maybe make it a bit more explicit, by using a custom class instead of `Lazy`? It'll make it easier to inspect where exactly the related logic is (searching for usages of Lazy is costly). E.g. (not sure about the names) ``` private class FieldToBeGenerated(generate: () -> IrField) { pri...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
else -1 localFunctions[declaration] = LocalFunctionContext(declaration, index, enclosingScope.irElement as IrDeclarationContainer) enclosingScope.usedLocalFunctionNames.add(declaration.name) } ...
I'm out of the loop... How is it possible to have many primary constructors in the same class? O_o
override fun visitConstructor(declaration: IrConstructor, data: Data) { super.visitConstructor(declaration, data) if (!isScriptMode && !declaration.constructedClass.isLocalNotInner()) return // LDL doesn't work on the enums because local enums...
@@ -953,7 +974,15 @@ class LocalDeclarationsLowering( // LDL doesn't work on the enums because local enums are not allowed, so skipping them in scripts too if (isScriptMode && declaration.kind == ClassKind.ENUM_CLASS) return - localClasses[declaration] = Lo...
compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt
26
Kotlin
0.214
suggestion
98
47
43
false
IR: do not create unused capture fields
4,582
JetBrains/kotlin
51,705
Kotlin
udalov
pyos
Review this pull request change. Language: Kotlin File: compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt PR Title: IR: do not create unused capture fields BEFORE CODE: else -1 localFunctions[declaration] = ...
I'm out of the loop... How is it possible to have many primary constructors in the same class? O_o
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} private fun generateDefaultGetterBody( getter: PropertyGetterDescriptor, irAccessor: IrSimpleFunction ): IrBlockBody { val property = getter.correspondingProperty val irProperty = irAccessor.correspondingPropertySymbol?.owner ?: error("Expected property for $getter") ...
`property.type.toIrType()` is not very cheap operation, so IMO it's better to extract it to a separate variable beforehand
} private fun generateDefaultGetterBody( getter: PropertyGetterDescriptor, irAccessor: IrSimpleFunction ): IrBlockBody { val property = getter.correspondingProperty val irProperty = irAccessor.correspondingPropertySymbol?.owner ?: error("Expected property for $getter") ...
@@ -597,7 +604,9 @@ interface IrBuilderExtension { irProperty.backingField?.symbol ?: error("Property expected to have backing field"), property.type.toIrType(), receiver - ) + ).let { + if (property.type.toI...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt
26
Kotlin
0.714
refactor
122
51
51
false
Serialization: Serializable meta annotation
4,583
JetBrains/kotlin
51,705
Kotlin
sandwwraith
rsinukov
Review this pull request change. Language: Kotlin File: plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt PR Title: Serialization: Serializable meta annotation BEFORE CODE: } private fun generateDefaultGetterBody( ...
`property.type.toIrType()` is not very cheap operation, so IMO it's better to extract it to a separate variable beforehand
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlin.util.collectionUtils.filterIsInstanceAnd import org.jetbrains.kotlin.utils.getOrPutNullable import org.jetbrains.kotlinx.serialization.compiler.backend.common.* import org.jetbrains.kotlinx.serialization.compiler.diagnostic.serializabl...
In general, it's better to avoid using descriptors in IR transformations because it's considered deprecated and dangerous API, which can sometimes lead to 'unbound symbol' bugs. I think it's possible to modify `IrClass.hasSerializableAnnotationWithoutArgs(): Boolean` function so it would take into account meta-annotati...
import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlin.util.collectionUtils.filterIsInstanceAnd import org.jetbrains.kotlin.utils.getOrPutNullable import org.jetbrains.kotlinx.serialization.compiler.backend.common.* import org.jetbrains.kotlinx.serialization.compiler.diagnostic.serializabl...
@@ -46,17 +46,7 @@ class SerializableIrGenerator( private val addElementFun = serialDescImplClass.referenceFunctionSymbol(CallingConventions.addElement) - private fun IrClass.hasSerializableAnnotationWithoutArgs(): Boolean { - val annot = getAnnotation(SerializationAnnotations.serializableAnnotationF...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt
26
Kotlin
0.786
bug
331
51
51
false
Serialization: Serializable meta annotation
4,583
JetBrains/kotlin
51,705
Kotlin
sandwwraith
rsinukov
Review this pull request change. Language: Kotlin File: plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt PR Title: Serialization: Serializable meta annotation BEFORE CODE: import org.jetbrains.kotlin.util.OperatorNameCo...
In general, it's better to avoid using descriptors in IR transformations because it's considered deprecated and dangerous API, which can sometimes lead to 'unbound symbol' bugs. I think it's possible to modify `IrClass.hasSerializableAnnotationWithoutArgs(): Boolean` function so it would take into account meta-annotati...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
val allPublicPackages = listOf(packageFqName, encodingPackageFqName, descriptorsPackageFqName, builtinsPackageFqName) } object SerializationAnnotations { // When changing names for these annotations, please change // org.jetbrains.kotlin.idea.caches.lightClasses.annotations.KOTLINX_SERIALIZABLE_FQ_NAME an...
IMO better move it next to SerialInfo & InheritableSerialInfo
val allPublicPackages = listOf(packageFqName, encodingPackageFqName, descriptorsPackageFqName, builtinsPackageFqName) } object SerializationAnnotations { // When changing names for these annotations, please change // org.jetbrains.kotlin.idea.caches.lightClasses.annotations.KOTLINX_SERIALIZABLE_FQ_NAME an...
@@ -38,6 +38,8 @@ object SerializationAnnotations { internal val contextualOnPropertyFqName = FqName("kotlinx.serialization.Contextual") internal val polymorphicFqName = FqName("kotlinx.serialization.Polymorphic") internal val additionalSerializersFqName = FqName("kotlinx.serialization.UseSerializers") +...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/resolve/NamingConventions.kt
26
Kotlin
0.286
suggestion
61
51
51
false
Serialization: Serializable meta annotation
4,583
JetBrains/kotlin
51,705
Kotlin
sandwwraith
rsinukov
Review this pull request change. Language: Kotlin File: plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/resolve/NamingConventions.kt PR Title: Serialization: Serializable meta annotation BEFORE CODE: val allPublicPackages = listOf(packageFqName, encod...
IMO better move it next to SerialInfo & InheritableSerialInfo
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM_IR // WITH_STDLIB import kotlinx.serialization.* import kotlinx.serialization.* import kotlinx.serialization.encoding.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.json.* import kotlin.reflect.KClass import kotlin.test.assertEquals // T...
Have you launched this test? I've just realized it doesn't work: because of `@Serializable(with = MySerializer::class)` , `Project3.serializer()` returns `MySerializer` that have manually-written descriptor and doesn't have annotation in it. That's a known problem even for regular SerialInfo annotations. Not sure if it...
// assertEquals("""{"name":"name","language":"lang"}""", string) // // val reconstructed = Json.decodeFromString(Project2.serializer(), string) // assertEquals("name", reconstructed.name) // assertEquals("lang", reconstructed.language) // // val info = Project2.serializer().descriptor.annotations.filterI...
@@ -0,0 +1,100 @@ +// IGNORE_BACKEND_FIR: JVM_IR +// TARGET_BACKEND: JVM_IR + +// WITH_STDLIB + +import kotlinx.serialization.* +import kotlinx.serialization.* +import kotlinx.serialization.encoding.* +import kotlinx.serialization.descriptors.* +import kotlinx.serialization.json.* +import kotlin.reflect.KClass +import ...
plugins/kotlin-serialization/kotlin-serialization-compiler/testData/boxIr/metaSerializable.kt
26
Kotlin
0.643
question
594
101
51
false
Serialization: Serializable meta annotation
4,583
JetBrains/kotlin
51,705
Kotlin
sandwwraith
rsinukov
Review this pull request change. Language: Kotlin File: plugins/kotlin-serialization/kotlin-serialization-compiler/testData/boxIr/metaSerializable.kt PR Title: Serialization: Serializable meta annotation BEFORE CODE: // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM_IR // WITH_STDLIB import kotlinx.serializati...
Have you launched this test? I've just realized it doesn't work: because of `@Serializable(with = MySerializer::class)` , `Project3.serializer()` returns `MySerializer` that have manually-written descriptor and doesn't have annotation in it. That's a known problem even for regular SerialInfo annotations. Not sure if it...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
//@MetaSerializable @Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY) annotation class MySerializable //@MetaSerializable @Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY) annotation class MySerializableWithInfo( val value: Int, val kclass: KClass<*> ) @MySerializable class Project1(val nam...
I'd also add tests for various 'non-standard' entities that can be serializable: objects, sealed & abstract classes, enums
//@MetaSerializable @Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY) annotation class MySerializable //@MetaSerializable @Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY) annotation class MySerializableWithInfo( val value: Int, val kclass: KClass<*> ) @MySerializable class Project1(val nam...
@@ -0,0 +1,100 @@ +// IGNORE_BACKEND_FIR: JVM_IR +// TARGET_BACKEND: JVM_IR + +// WITH_STDLIB + +import kotlinx.serialization.* +import kotlinx.serialization.* +import kotlinx.serialization.encoding.* +import kotlinx.serialization.descriptors.* +import kotlinx.serialization.json.* +import kotlin.reflect.KClass +import ...
plugins/kotlin-serialization/kotlin-serialization-compiler/testData/boxIr/metaSerializable.kt
26
Kotlin
0.357
refactor
122
51
51
false
Serialization: Serializable meta annotation
4,583
JetBrains/kotlin
51,705
Kotlin
sandwwraith
rsinukov
Review this pull request change. Language: Kotlin File: plugins/kotlin-serialization/kotlin-serialization-compiler/testData/boxIr/metaSerializable.kt PR Title: Serialization: Serializable meta annotation BEFORE CODE: //@MetaSerializable @Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY) annotation class My...
I'd also add tests for various 'non-standard' entities that can be serializable: objects, sealed & abstract classes, enums
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.jetbrains.kotlinx.serialization.compiler.diagnostic.serializableAnnotationIsUseless import org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationPluginContext import org.jetbrains.kotlinx.serialization.compiler.resolve.* import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityN...
serializable annotation always have one argument so I think we may skip a loop here
import org.jetbrains.kotlinx.serialization.compiler.diagnostic.serializableAnnotationIsUseless import org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationPluginContext import org.jetbrains.kotlinx.serialization.compiler.resolve.* import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityN...
@@ -46,17 +46,21 @@ class SerializableIrGenerator( private val addElementFun = serialDescImplClass.referenceFunctionSymbol(CallingConventions.addElement) - private fun IrClass.hasSerializableAnnotationWithoutArgs(): Boolean { - val annot = getAnnotation(SerializationAnnotations.serializableAnnotation...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt
26
Kotlin
0.214
suggestion
83
51
51
false
Serialization: Serializable meta annotation
4,583
JetBrains/kotlin
51,705
Kotlin
sandwwraith
rsinukov
Review this pull request change. Language: Kotlin File: plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt PR Title: Serialization: Serializable meta annotation BEFORE CODE: import org.jetbrains.kotlinx.serialization.comp...
serializable annotation always have one argument so I think we may skip a loop here
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// IGNORE_BACKEND: JVM // MODULE: lib // FILE: lib.kt import kotlin.reflect.KProperty open class A { inline operator fun Int.getValue(thisRef: Any?, property: KProperty<*>): String = property.name } // MODULE: main(lib) // FILE: main.kt import kotlin.reflect.KProperty open class B : A() { inline oper...
In #4592, I've noticed that the test also checks `setValue`... Could you add it here please?
// IGNORE_BACKEND: JVM // MODULE: lib // FILE: lib.kt import kotlin.reflect.KProperty open class A { inline operator fun Int.getValue(thisRef: Any?, property: KProperty<*>): String = property.name } // MODULE: main(lib) // FILE: main.kt import kotlin.reflect.KProperty open class B : A() { var result ...
@@ -0,0 +1,25 @@ +// IGNORE_BACKEND: JVM +// MODULE: lib +// FILE: lib.kt +import kotlin.reflect.KProperty + +open class A { + inline operator fun Int.getValue(thisRef: Any?, property: KProperty<*>): String = + property.name +} + +// MODULE: main(lib) +// FILE: main.kt +import kotlin.reflect.KProperty + +open...
compiler/testData/codegen/box/delegatedProperty/optimizedDelegatedProperties/kt48825.kt
25
Kotlin
0.429
question
92
26
32
false
JVM_IR: resolve fake overrides of inline delegated property operators
4,591
JetBrains/kotlin
51,705
Kotlin
udalov
pyos
Review this pull request change. Language: Kotlin File: compiler/testData/codegen/box/delegatedProperty/optimizedDelegatedProperties/kt48825.kt PR Title: JVM_IR: resolve fake overrides of inline delegated property operators BEFORE CODE: // IGNORE_BACKEND: JVM // MODULE: lib // FILE: lib.kt import kotlin.reflect.KPr...
In #4592, I've noticed that the test also checks `setValue`... Could you add it here please?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl import org...
Sealed interfaces are possible since 1.5, so a class can have several sealed supertypes: ``` sealed class A sealed interface I class C : A(), I ```
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl import org...
@@ -32,9 +33,15 @@ import org.jetbrains.kotlin.parcelize.serializers.ParcelizeExtensionBase import org.jetbrains.kotlin.parcelize.serializers.ParcelizeExtensionBase.Companion.CREATOR_NAME import org.jetbrains.kotlin.types.Variance +private val IrClass.sealedSuperClass: IrClass? + get() = superTypes.mapNotNull { ...
plugins/parcelize/parcelize-compiler/src/org/jetbrains/kotlin/parcelize/ir/irUtils.kt
26
Kotlin
0.857
suggestion
154
51
51
false
Parcelize: Allow Parcelize annotation on sealed classes
4,596
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: plugins/parcelize/parcelize-compiler/src/org/jetbrains/kotlin/parcelize/ir/irUtils.kt PR Title: Parcelize: Allow Parcelize annotation on sealed classes BEFORE CODE: import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.exp...
Sealed interfaces are possible since 1.5, so a class can have several sealed supertypes: ``` sealed class A sealed interface I class C : A(), I ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.jetbrains.kotlin.diagnostics.rendering.Renderers.RENDER_CLASS_OR_OBJECT import org.jetbrains.kotlin.diagnostics.rendering.Renderers.RENDER_TYPE_WITH_ANNOTATIONS object DefaultErrorMessagesParcelize : DefaultErrorMessages.Extension { private val MAP = DiagnosticFactoryToRendererMap("Parcelize") overr...
```suggestion "'Parcelable' should not be an 'abstract' class" ```
import org.jetbrains.kotlin.diagnostics.rendering.Renderers.RENDER_CLASS_OR_OBJECT import org.jetbrains.kotlin.diagnostics.rendering.Renderers.RENDER_TYPE_WITH_ANNOTATIONS object DefaultErrorMessagesParcelize : DefaultErrorMessages.Extension { private val MAP = DiagnosticFactoryToRendererMap("Parcelize") overr...
@@ -43,7 +43,7 @@ object DefaultErrorMessagesParcelize : DefaultErrorMessages.Extension { MAP.put( ErrorsParcelize.PARCELABLE_SHOULD_BE_INSTANTIABLE, - "'Parcelable' should not be a 'sealed' or 'abstract' class" + "'Parcelable' should not be a 'abstract' class"
plugins/parcelize/parcelize-compiler/src/org/jetbrains/kotlin/parcelize/diagnostic/DefaultErrorMessagesParcelize.kt
26
Kotlin
0.643
refactor
80
51
51
false
Parcelize: Allow Parcelize annotation on sealed classes
4,596
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: plugins/parcelize/parcelize-compiler/src/org/jetbrains/kotlin/parcelize/diagnostic/DefaultErrorMessagesParcelize.kt PR Title: Parcelize: Allow Parcelize annotation on sealed classes BEFORE CODE: import org.jetbrains.kotlin.diagnostics.rendering.Renderers.RENDE...
```suggestion "'Parcelable' should not be an 'abstract' class" ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
FqName("kotlinx.android.parcel.WriteWith") ) val IGNORED_ON_PARCEL_FQ_NAMES = listOf( FqName("kotlinx.parcelize.IgnoredOnParcel"), FqName("kotlinx.android.parcel.IgnoredOnParcel") ) val PARCELIZE_CLASS_FQ_NAMES: List<FqName> = listOf( FqName("kotlinx.parcelize.Parcelize"), FqName("kotlinx.android....
Probably also needs to handle sealed interfaces
FqName("kotlinx.parcelize.WriteWith"), FqName("kotlinx.android.parcel.WriteWith") ) val IGNORED_ON_PARCEL_FQ_NAMES = listOf( FqName("kotlinx.parcelize.IgnoredOnParcel"), FqName("kotlinx.android.parcel.IgnoredOnParcel") ) val PARCELIZE_CLASS_FQ_NAMES: List<FqName> = listOf( FqName("kotlinx.parceliz...
@@ -197,16 +201,11 @@ val RAW_VALUE_ANNOTATION_FQ_NAMES = listOf( internal val PARCELER_FQNAME = FqName("kotlinx.parcelize.Parceler") internal val OLD_PARCELER_FQNAME = FqName("kotlinx.android.parcel.Parceler") -val ClassDescriptor.isParcelize: Boolean - get() { - for (fqName in PARCELIZE_CLASS_FQ_NAMES) ...
plugins/parcelize/parcelize-compiler/src/org/jetbrains/kotlin/parcelize/ParcelizeResolveExtension.kt
26
Kotlin
0.214
suggestion
47
50
51
false
Parcelize: Allow Parcelize annotation on sealed classes
4,596
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: plugins/parcelize/parcelize-compiler/src/org/jetbrains/kotlin/parcelize/ParcelizeResolveExtension.kt PR Title: Parcelize: Allow Parcelize annotation on sealed classes BEFORE CODE: FqName("kotlinx.android.parcel.WriteWith") ) val IGNORED_ON_PARCEL_FQ_NAMES...
Probably also needs to handle sealed interfaces
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
bindingContext: BindingContext, languageVersionSettings: LanguageVersionSettings ) { if (!descriptor.isParcelize) { return } if (declaration !is KtClassOrObject) { diagnosticHolder.report(ErrorsParcelize.PARCELABLE_SHOULD_BE_CLASS.on(declaration)) ...
```suggestion val abstractModifier = ```
if (!descriptor.isParcelize) { return } if (declaration !is KtClassOrObject) { diagnosticHolder.report(ErrorsParcelize.PARCELABLE_SHOULD_BE_CLASS.on(declaration)) return } if (declaration is KtClass && (declaration.isAnnotation() || declarati...
@@ -167,7 +167,7 @@ open class ParcelizeDeclarationChecker : DeclarationChecker { } val sealedOrAbstract =
plugins/parcelize/parcelize-compiler/src/org/jetbrains/kotlin/parcelize/ParcelizeDeclarationChecker.kt
26
Kotlin
0.571
refactor
50
51
51
false
Parcelize: Allow Parcelize annotation on sealed classes
4,596
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: plugins/parcelize/parcelize-compiler/src/org/jetbrains/kotlin/parcelize/ParcelizeDeclarationChecker.kt PR Title: Parcelize: Allow Parcelize annotation on sealed classes BEFORE CODE: bindingContext: BindingContext, languageVersionSettings: Langu...
```suggestion val abstractModifier = ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* JVM-specific flags in addition to common flags declared in [Flag]. * * @see Flag * @see Flags */ object JvmFlag { /** * JVM-specific property flags in addition to common property flags declared in [Flag.Property]. */ object Property { /** * Applied to a property declared in an ...
```suggestion * Applied to an interface compiled with -Xjvm-default=all or all-compatibility. ```
* JVM-specific flags in addition to common flags declared in [Flag]. * * @see Flag * @see Flags */ object JvmFlag { /** * JVM-specific property flags in addition to common property flags declared in [Flag.Property]. */ object Property { /** * Applied to a property declared in an ...
@@ -31,6 +31,23 @@ object JvmFlag { val IS_MOVED_FROM_INTERFACE_COMPANION = booleanFlag(JF.IS_MOVED_FROM_INTERFACE_COMPANION) } + /** + * JVM-specific class flags in addition to common class flags declared in [Flag.Class]. + */ + object Class { + /** + * Applied to an interf...
libraries/kotlinx-metadata/jvm/src/kotlinx/metadata/jvm/JvmFlag.kt
26
Kotlin
0.714
suggestion
108
41
49
false
kotlinx-metadata-jvm: Handle the jvmClassFlags extension
4,614
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: libraries/kotlinx-metadata/jvm/src/kotlinx/metadata/jvm/JvmFlag.kt PR Title: kotlinx-metadata-jvm: Handle the jvmClassFlags extension BEFORE CODE: * JVM-specific flags in addition to common flags declared in [Flag]. * * @see Flag * @see Flags */ object Jv...
```suggestion * Applied to an interface compiled with -Xjvm-default=all or all-compatibility. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/** * JVM-specific property flags in addition to common property flags declared in [Flag.Property]. */ object Property { /** * Applied to a property declared in an interface's companion object, signifies that its backing field is declared as a static * field in the interface....
```suggestion * Applied to an interface compiled with -Xjvm-default=all-compatibility. ```
/** * JVM-specific property flags in addition to common property flags declared in [Flag.Property]. */ object Property { /** * Applied to a property declared in an interface's companion object, signifies that its backing field is declared as a static * field in the interface....
@@ -31,6 +31,23 @@ object JvmFlag { val IS_MOVED_FROM_INTERFACE_COMPANION = booleanFlag(JF.IS_MOVED_FROM_INTERFACE_COMPANION) } + /** + * JVM-specific class flags in addition to common class flags declared in [Flag.Class]. + */ + object Class { + /** + * Applied to an interf...
libraries/kotlinx-metadata/jvm/src/kotlinx/metadata/jvm/JvmFlag.kt
26
Kotlin
0.714
suggestion
101
35
43
false
kotlinx-metadata-jvm: Handle the jvmClassFlags extension
4,614
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: libraries/kotlinx-metadata/jvm/src/kotlinx/metadata/jvm/JvmFlag.kt PR Title: kotlinx-metadata-jvm: Handle the jvmClassFlags extension BEFORE CODE: /** * JVM-specific property flags in addition to common property flags declared in [Flag.Property]. ...
```suggestion * Applied to an interface compiled with -Xjvm-default=all-compatibility. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* @see Flags */ object JvmFlag { /** * JVM-specific property flags in addition to common property flags declared in [Flag.Property]. */ object Property { /** * Applied to a property declared in an interface's companion object, signifies that its backing field is declared as a static...
Something feels off about this name, but I can't quite explain what. It wasn't a problem as long as it was internal in our project, but maybe we can invent some better name for the public library. Like `HAS_METHOD_BODIES_IN_INTERFACE` (as opposed to in DefaultImpls -- which the kdoc might also explain)?
* @see Flags */ object JvmFlag { /** * JVM-specific property flags in addition to common property flags declared in [Flag.Property]. */ object Property { /** * Applied to a property declared in an interface's companion object, signifies that its backing field is declared as a static...
@@ -31,6 +31,23 @@ object JvmFlag { val IS_MOVED_FROM_INTERFACE_COMPANION = booleanFlag(JF.IS_MOVED_FROM_INTERFACE_COMPANION) } + /** + * JVM-specific class flags in addition to common class flags declared in [Flag.Class]. + */ + object Class { + /** + * Applied to an interf...
libraries/kotlinx-metadata/jvm/src/kotlinx/metadata/jvm/JvmFlag.kt
26
Kotlin
0.643
question
304
38
46
false
kotlinx-metadata-jvm: Handle the jvmClassFlags extension
4,614
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: libraries/kotlinx-metadata/jvm/src/kotlinx/metadata/jvm/JvmFlag.kt PR Title: kotlinx-metadata-jvm: Handle the jvmClassFlags extension BEFORE CODE: * @see Flags */ object JvmFlag { /** * JVM-specific property flags in addition to common property flag...
Something feels off about this name, but I can't quite explain what. It wasn't a problem as long as it was internal in our project, but maybe we can invent some better name for the public library. Like `HAS_METHOD_BODIES_IN_INTERFACE` (as opposed to in DefaultImpls -- which the kdoc might also explain)?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
object Property { /** * Applied to a property declared in an interface's companion object, signifies that its backing field is declared as a static * field in the interface. In Kotlin code, this usually happens if the property is annotated with [JvmField]. * * Has no effe...
Similar to the above, maybe something like `IS_COMPILED_IN_COMPATIBILITY_MODE`?
object Property { /** * Applied to a property declared in an interface's companion object, signifies that its backing field is declared as a static * field in the interface. In Kotlin code, this usually happens if the property is annotated with [JvmField]. * * Has no effe...
@@ -31,6 +31,23 @@ object JvmFlag { val IS_MOVED_FROM_INTERFACE_COMPANION = booleanFlag(JF.IS_MOVED_FROM_INTERFACE_COMPANION) } + /** + * JVM-specific class flags in addition to common class flags declared in [Flag.Class]. + */ + object Class { + /** + * Applied to an interf...
libraries/kotlinx-metadata/jvm/src/kotlinx/metadata/jvm/JvmFlag.kt
26
Kotlin
0.357
question
79
32
40
false
kotlinx-metadata-jvm: Handle the jvmClassFlags extension
4,614
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: libraries/kotlinx-metadata/jvm/src/kotlinx/metadata/jvm/JvmFlag.kt PR Title: kotlinx-metadata-jvm: Handle the jvmClassFlags extension BEFORE CODE: object Property { /** * Applied to a property declared in an interface's companion object, s...
Similar to the above, maybe something like `IS_COMPILED_IN_COMPATIBILITY_MODE`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
internal val includeBinaries: List<String> = configuration.getList(KonanConfigKeys.INCLUDED_BINARY_FILES) internal val languageVersionSettings = configuration.get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS)!! internal val friendModuleFiles: Set<File> = configura...
The absolute majority of our users invoke compiler via Gradle, so it makes sense to show how to adjust Gradle script instead of compiler flag. Let's change the message to the following: > Android Native executables are currently built as shared libraries with NativeActivity support, but the default behavior is going...
internal val includeBinaries: List<String> = configuration.getList(KonanConfigKeys.INCLUDED_BINARY_FILES) internal val languageVersionSettings = configuration.get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS)!! internal val friendModuleFiles: Set<File> = configura...
@@ -275,6 +275,23 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration internal val propertyLazyInitialization: Boolean get() = configuration.get(KonanConfigKeys.PROPERTY_LAZY_INITIALIZATION)!! internal val lazyIrForCaches: Boolean get() = configuration.get(KonanConfigKeys.LAZ...
kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt
26
Kotlin
1
suggestion
867
41
47
false
[Native] Enable real Android Native executables
4,624
JetBrains/kotlin
51,705
Kotlin
sbogolepov
natario1
Review this pull request change. Language: Kotlin File: kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt PR Title: [Native] Enable real Android Native executables BEFORE CODE: internal val includeBinaries: List<String> = configuration.get...
The absolute majority of our users invoke compiler via Gradle, so it makes sense to show how to adjust Gradle script instead of compiler flag. Let's change the message to the following: > Android Native executables are currently built as shared libraries with NativeActivity support, but the default behavior is going...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
libraries: List<String>, linkerArgs: List<String>, optimize: Boolean, debug: Boolean, kind: LinkerOutputKind, outputDsymBundle: String, needsProfileLibrary: Boolean, mimallocEnable...
Let's change these lines to something like this: ```kotlin when (kind) { LinkerOutputKind.EXECUTABLE -> +listOf("-fPIE", "-pie") LinkerOutputKind.DYNAMIC_LIBRARY -> +listOf("-fPIC", "-shared") LinkerOutputKind.STATIC_LIBRARY -> {} } ``` Motivation: * It is more explicit that we add these flags only...
libraries: List<String>, linkerArgs: List<String>, optimize: Boolean, debug: Boolean, kind: LinkerOutputKind, outputDsymBundle: String, needsProfileLibrary: Boolean, mimallocEnable...
@@ -145,8 +145,8 @@ class AndroidLinker(targetProperties: AndroidConfigurables) return listOf(Command(clang).apply { +"-o" +executable - +"-fPIC" - +"-shared" + if (dynamic) +"-fPIC" else +listOf("-fPIE", "-pie") + if (dynamic) +"-shared"
kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt
26
Kotlin
0.857
bug
411
51
51
false
[Native] Enable real Android Native executables
4,624
JetBrains/kotlin
51,705
Kotlin
sbogolepov
natario1
Review this pull request change. Language: Kotlin File: kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt PR Title: [Native] Enable real Android Native executables BEFORE CODE: libraries: List<String>, linkerArgs: List<String>, ...
Let's change these lines to something like this: ```kotlin when (kind) { LinkerOutputKind.EXECUTABLE -> +listOf("-fPIE", "-pie") LinkerOutputKind.DYNAMIC_LIBRARY -> +listOf("-fPIC", "-shared") LinkerOutputKind.STATIC_LIBRARY -> {} } ``` Motivation: * It is more explicit that we add these flags only...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
addValueParameter("receiver", irBuiltIns.anyNType) addValueParameter { name = Name.identifier("args") type = irBuiltIns.arrayClass.typeWith(irBuiltIns.anyNType) varargElementType = irBuiltIns.anyNType } ...
@udalov Is this "too defensive"? What I am thinking is by doing this mutation of JvmSymbols, I guess it's possible to create an inconsistent state if `JvmReflectSymbols` is instantiated a number of times.
addValueParameter("receiver", irBuiltIns.anyNType) addValueParameter { name = Name.identifier("args") type = irBuiltIns.arrayClass.typeWith(irBuiltIns.anyNType) varargElementType = irBuiltIns.anyNType } ...
@@ -0,0 +1,149 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ +package org.jetbrains.kotlin.backend.jvm + +import org.jetbrains.kotlin.backend.common.i...
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmReflectSymbols.kt
26
Kotlin
0.571
suggestion
204
51
51
false
[IR] Refactor `JvmSymbols` for on-demand `java.lang.reflect` symbols
4,641
JetBrains/kotlin
51,705
Kotlin
kandersen
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmReflectSymbols.kt PR Title: [IR] Refactor `JvmSymbols` for on-demand `java.lang.reflect` symbols BEFORE CODE: addValueParameter("receiver", irBuiltIns.anyNType) add...
@udalov Is this "too defensive"? What I am thinking is by doing this mutation of JvmSymbols, I guess it's possible to create an inconsistent state if `JvmReflectSymbols` is instantiated a number of times.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// // Upon return, all `Ref`s are written back into the stack, thus allowing fragments // to modify the state of the program being debugged. // // This lowering promotes these parameters to `Ref`s, as deemed appropriate by // psi2ir's Fragment generation. // // The reason for this "phasing" is that the JVM specific inf...
Nit: Do we rely on this name elsewhere? Should we introduce a constants for it?
// Upon return, all `Ref`s are written back into the stack, thus allowing fragments // to modify the state of the program being debugged. // // This lowering promotes these parameters to `Ref`s, as deemed appropriate by // psi2ir's Fragment generation. // // The reason for this "phasing" is that the JVM specific infras...
@@ -0,0 +1,116 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.backend.jvm.lower + +import org.jetbrains.kotlin.backend....
compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/FragmentSharedVariablesLowering.kt
26
Kotlin
0.286
question
79
51
51
false
[EE-IR] Support mutations by evaluator fragments
4,647
JetBrains/kotlin
51,705
Kotlin
madsager
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/FragmentSharedVariablesLowering.kt PR Title: [EE-IR] Support mutations by evaluator fragments BEFORE CODE: // // Upon return, all `Ref`s are written back into the stack, thus allowing fra...
Nit: Do we rely on this name elsewhere? Should we introduce a constants for it?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
override fun getSharedValue(sharedVariableSymbol: IrVariableSymbol, originalGet: IrGetValue): IrExpression = with(originalGet) { val unboxedType = InlineClassAbi.unboxType(symbol.owner.type) val provider = getProvider(unboxedType ?: symbol.owner.type) val receiver = IrGet...
Can we share this code with the other getSharedValue and setSharedValue? I believe there is an inheritance relationship between IrVariableSymbol and IrValueSymbol. Can one of the methods here just forward to the other?
with(originalGet) { val unboxedType = InlineClassAbi.unboxType(symbol.owner.type) val provider = getProvider(unboxedType ?: symbol.owner.type) val receiver = IrGetValueImpl(startOffset, endOffset, sharedVariableSymbol) val unboxedRead = IrGetFieldImpl(startOffset,...
@@ -146,6 +147,32 @@ class JvmSharedVariablesManager( val receiver = IrGetValueImpl(startOffset, endOffset, sharedVariableSymbol) IrSetFieldImpl(startOffset, endOffset, provider.elementField.symbol, receiver, unboxedValue, type, origin) } + + fun getIrType(originalType: IrType): Ir...
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSharedVariablesManager.kt
26
Kotlin
0.429
question
219
51
33
false
[EE-IR] Support mutations by evaluator fragments
4,647
JetBrains/kotlin
51,705
Kotlin
madsager
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSharedVariablesManager.kt PR Title: [EE-IR] Support mutations by evaluator fragments BEFORE CODE: override fun getSharedValue(sharedVariableSymbol: IrVariableSymbol, originalGet: IrGetValue): ...
Can we share this code with the other getSharedValue and setSharedValue? I believe there is an inheritance relationship between IrVariableSymbol and IrValueSymbol. Can one of the methods here just forward to the other?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
package org.jetbrains.kotlin.backend.jvm.lower import org.jetbrains.kotlin.backend.common.FileLoweringPass import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext import org.jetbrains.kotlin.backend.common.ir.copyTo import org.jetbrains.kotlin.backend.common.phaser.makeIrModulePhase import org....
This is the default value already, so not needed ```suggestion ```
package org.jetbrains.kotlin.backend.jvm.lower import org.jetbrains.kotlin.backend.common.FileLoweringPass import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext import org.jetbrains.kotlin.backend.common.ir.copyTo import org.jetbrains.kotlin.backend.common.phaser.makeIrModulePhase import org....
@@ -0,0 +1,116 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.backend.jvm.lower + +import org.jetbrains.kotlin.backend....
compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/FragmentSharedVariablesLowering.kt
26
Kotlin
0.571
suggestion
68
51
51
false
[EE-IR] Support mutations by evaluator fragments
4,647
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/FragmentSharedVariablesLowering.kt PR Title: [EE-IR] Support mutations by evaluator fragments BEFORE CODE: package org.jetbrains.kotlin.backend.jvm.lower import org.jetbrains.kotlin.bac...
This is the default value already, so not needed ```suggestion ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.psi2ir.generators.fragments import org.jetbrains.kotlin.descriptors.ClassDescrip...
This comment seems now a bit out of place, since it specifically explains what `EvaluatorFramentInfo`'s `classDescriptor`, `methodDescriptor` and `parameters` are
/* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.psi2ir.generators.fragments import org.jetbrains.kotlin.descriptors.ClassDescrip...
@@ -19,8 +19,14 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor * This data structure contains "synthesized" descriptors for that class,
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/EvaluatorFragmentInfo.kt
19
Kotlin
0.5
suggestion
162
32
44
false
[EE-IR] Support mutations by evaluator fragments
4,647
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/EvaluatorFragmentInfo.kt PR Title: [EE-IR] Support mutations by evaluator fragments BEFORE CODE: /* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors....
This comment seems now a bit out of place, since it specifically explains what `EvaluatorFramentInfo`'s `classDescriptor`, `methodDescriptor` and `parameters` are
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.psi2ir.generators.fragments import org.jetbrains.kotlin.descriptors.ClassDescrip...
Could you please keep the constructor with the old signature, so that the current plugin code will compile (and if possible, work somehow)? Otherwise I can't merge the changes because IDE plugin build is a part of the verification check for all builds. (Alternatively, I could wait until https://github.com/JetBrains/...
/* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.psi2ir.generators.fragments import org.jetbrains.kotlin.descriptors.ClassDescrip...
@@ -22,5 +22,10 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor class EvaluatorFragmentInfo( val classDescriptor: ClassDescriptor, val methodDescriptor: FunctionDescriptor, - val parameters: List<DeclarationDescriptor> -) \ No newline at end of file + val parameters: List<EvaluatorFragmen...
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/EvaluatorFragmentInfo.kt
25
Kotlin
0.5
question
447
32
48
false
[EE-IR] Support mutations by evaluator fragments
4,647
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/EvaluatorFragmentInfo.kt PR Title: [EE-IR] Support mutations by evaluator fragments BEFORE CODE: /* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors....
Could you please keep the constructor with the old signature, so that the current plugin code will compile (and if possible, work somehow)? Otherwise I can't merge the changes because IDE plugin build is a part of the verification check for all builds. (Alternatively, I could wait until https://github.com/JetBrains/...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import org.jetbrains.kotlin.descriptors.FunctionDescriptor /** * Information for compilation of code fragments for `evaluate expression` * * The expression evaluator works by wrapping a code fragment in a method. * The free variables of the fragment are closed over by the parameters of * that method, and fina...
Ignore this, will revert. Completely misread the problem :sweat_smile:
import org.jetbrains.kotlin.descriptors.FunctionDescriptor /** * Information for compilation of code fragments for `evaluate expression` * * The expression evaluator works by wrapping a code fragment in a method. * The free variables of the fragment are closed over by the parameters of * that method, and fina...
@@ -22,5 +22,15 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor class EvaluatorFragmentInfo( val classDescriptor: ClassDescriptor, val methodDescriptor: FunctionDescriptor, - val parameters: List<DeclarationDescriptor> -) \ No newline at end of file + val parameters: List<EvaluatorFragmen...
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/EvaluatorFragmentInfo.kt
26
Kotlin
0.214
suggestion
73
28
39
false
[EE-IR] Support mutations by evaluator fragments
4,647
JetBrains/kotlin
51,705
Kotlin
kandersen
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/EvaluatorFragmentInfo.kt PR Title: [EE-IR] Support mutations by evaluator fragments BEFORE CODE: import org.jetbrains.kotlin.descriptors.FunctionDescriptor /** * Information for comp...
Ignore this, will revert. Completely misread the problem :sweat_smile:
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.psi2ir.generators.fragments import org.jetbrains.kotlin.descriptors.ClassDescrip...
@udalov OK, so here's a migration plan: 0. this PR lands 1. intellij-community#1839 lands, using `createWithFragmentParameterInfo` on the companion. 2. we change the constructor to the new signature, and the implementation in the companion accordingly. 3. we change the call site in intellij-community to u...
/* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.psi2ir.generators.fragments import org.jetbrains.kotlin.descriptors.ClassDescrip...
@@ -22,5 +22,27 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor class EvaluatorFragmentInfo( val classDescriptor: ClassDescriptor, val methodDescriptor: FunctionDescriptor, - val parameters: List<DeclarationDescriptor> + parameterDescriptors: List<DeclarationDescriptor>,
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/EvaluatorFragmentInfo.kt
25
Kotlin
0.643
question
354
26
48
false
[EE-IR] Support mutations by evaluator fragments
4,647
JetBrains/kotlin
51,705
Kotlin
kandersen
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/fragments/EvaluatorFragmentInfo.kt PR Title: [EE-IR] Support mutations by evaluator fragments BEFORE CODE: /* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors....
@udalov OK, so here's a migration plan: 0. this PR lands 1. intellij-community#1839 lands, using `createWithFragmentParameterInfo` on the companion. 2. we change the constructor to the new signature, and the implementation in the companion accordingly. 3. we change the call site in intellij-community to u...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// TARGET_BACKEND: JVM_IR // WITH_STDLIB // WITH_REFLECT // FULL_JDK annotation class Ann1(val value: UByte = 41u) annotation class Ann2(val value: UShort = 42u) annotation class Ann3(val value: UInt = 43u) annotation class Ann4(val value: ULong = 44u) @Ann1 @Ann2 @Ann3 @Ann4 class A fun box(): String { val defa...
`Class.getDeclaredAnnotation` is missing on JDK6 and older versions of Android, so the corresponding tests (`compiler/tests-different-jdk`, `compiler/android-tests`) are failing. Let's use `Class.getAnnotation` instead
// TARGET_BACKEND: JVM_IR // WITH_STDLIB // WITH_REFLECT // FULL_JDK annotation class Ann1(val value: UByte = 41u) annotation class Ann2(val value: UShort = 42u) annotation class Ann3(val value: UInt = 43u) annotation class Ann4(val value: ULong = 44u) @Ann1 @Ann2 @Ann3 @Ann4 class A fun box(): String { val defa...
@@ -0,0 +1,29 @@ +// TARGET_BACKEND: JVM_IR +// WITH_STDLIB +// WITH_REFLECT +// FULL_JDK + +annotation class Ann1(val value: UByte = 41u) +annotation class Ann2(val value: UShort = 42u) +annotation class Ann3(val value: UInt = 43u) +annotation class Ann4(val value: ULong = 44u) + +@Ann1 +@Ann2 +@Ann3 +@Ann4 +class A +...
compiler/testData/codegen/box/annotations/annotationDefaultValueOfUnsigned.kt
18
Kotlin
0.643
bug
218
30
30
false
JVM_IR: recover accidentally lost backingField (KT-49998)
4,669
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Kotlin File: compiler/testData/codegen/box/annotations/annotationDefaultValueOfUnsigned.kt PR Title: JVM_IR: recover accidentally lost backingField (KT-49998) BEFORE CODE: // TARGET_BACKEND: JVM_IR // WITH_STDLIB // WITH_REFLECT // FULL_JDK annotation class Ann1(val value...
`Class.getDeclaredAnnotation` is missing on JDK6 and older versions of Android, so the corresponding tests (`compiler/tests-different-jdk`, `compiler/android-tests`) are failing. Let's use `Class.getAnnotation` instead
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
val newDeclaration = deepCopyWithSymbols(parent) val valueParametersCount = valueParameters.size val type = newDeclaration.extensionReceiverParameter!!.type.atomicToValueType() val getterType = context.buildGetterType(type) val setterType =...
What if we have code like this? ```kotlin fun foo() { if (cond()) { trace { "Doing something" } } } ```
val newDeclaration = deepCopyWithSymbols(parent) val valueParametersCount = valueParameters.size val type = newDeclaration.extensionReceiverParameter!!.type.atomicToValueType() val getterType = context.buildGetterType(type) val setterType =...
@@ -98,6 +102,17 @@ class AtomicfuTransformer(private val context: IrPluginContext) { private inner class AtomicTransformer : IrElementTransformer<IrFunction?> { override fun visitFunction(declaration: IrFunction, data: IrFunction?): IrStatement { + // Erase messages added by the Trace object...
plugins/atomicfu/atomicfu-compiler/src/org.jetbrains.kotlinx.atomicfu.compiler/extensions/AtomicfuTransformer.kt
26
Kotlin
0.714
question
122
51
51
false
kotlinx.atomicfu compiler plugin (JS): tracing supported.
4,691
JetBrains/kotlin
51,705
Kotlin
romanart
mvicsokolova
Review this pull request change. Language: Kotlin File: plugins/atomicfu/atomicfu-compiler/src/org.jetbrains.kotlinx.atomicfu.compiler/extensions/AtomicfuTransformer.kt PR Title: kotlinx.atomicfu compiler plugin (JS): tracing supported. BEFORE CODE: val newDeclaration = deepCopyWithSymbols(parent) ...
What if we have code like this? ```kotlin fun foo() { if (cond()) { trace { "Doing something" } } } ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} return null } } private inner class AtomicTransformer : IrElementTransformer<IrFunction?> { override fun visitProperty(declaration: IrProperty, data: IrFunction?): IrStatement { // Support transformation for delegated properties: if (declaratio...
What if ```kotlin val a = atomic(42) class B { val b: Int by a } ```
} return null } } private inner class AtomicTransformer : IrElementTransformer<IrFunction?> { override fun visitProperty(declaration: IrProperty, data: IrFunction?): IrStatement { // Support transformation for delegated properties: if (declaratio...
@@ -101,6 +103,44 @@ class AtomicfuTransformer(private val context: IrPluginContext) { private inner class AtomicTransformer : IrElementTransformer<IrFunction?> { + override fun visitProperty(declaration: IrProperty, data: IrFunction?): IrStatement { + // Support transformation for delegated ...
plugins/atomicfu/atomicfu-compiler/src/org.jetbrains.kotlinx.atomicfu.compiler/extensions/AtomicfuTransformer.kt
26
Kotlin
0.571
suggestion
76
51
51
false
kotlinx.atomicfu compiler plugin (JS): delegated properties supported
4,692
JetBrains/kotlin
51,705
Kotlin
romanart
mvicsokolova
Review this pull request change. Language: Kotlin File: plugins/atomicfu/atomicfu-compiler/src/org.jetbrains.kotlinx.atomicfu.compiler/extensions/AtomicfuTransformer.kt PR Title: kotlinx.atomicfu compiler plugin (JS): delegated properties supported BEFORE CODE: } return null } } ...
What if ```kotlin val a = atomic(42) class B { val b: Int by a } ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
delegateBackingField.initializer?.let { val initializer = it.expression as IrCall when { initializer.isAtomicFieldGetter() -> { // val _a = atomic(0) // var a: ...
I think modifying accessors here would be a bit more straightforward and simple instead of doing so in the separate lowering through backings field
delegateBackingField.initializer?.let { val initializer = it.expression as IrCall when { initializer.isAtomicFieldGetter() -> { // val _a = atomic(0) // var a: ...
@@ -101,6 +103,44 @@ class AtomicfuTransformer(private val context: IrPluginContext) { private inner class AtomicTransformer : IrElementTransformer<IrFunction?> { + override fun visitProperty(declaration: IrProperty, data: IrFunction?): IrStatement { + // Support transformation for delegated ...
plugins/atomicfu/atomicfu-compiler/src/org.jetbrains.kotlinx.atomicfu.compiler/extensions/AtomicfuTransformer.kt
26
Kotlin
0.429
suggestion
147
51
51
false
kotlinx.atomicfu compiler plugin (JS): delegated properties supported
4,692
JetBrains/kotlin
51,705
Kotlin
romanart
mvicsokolova
Review this pull request change. Language: Kotlin File: plugins/atomicfu/atomicfu-compiler/src/org.jetbrains.kotlinx.atomicfu.compiler/extensions/AtomicfuTransformer.kt PR Title: kotlinx.atomicfu compiler plugin (JS): delegated properties supported BEFORE CODE: delegateBackingField.initializer?....
I think modifying accessors here would be a bit more straightforward and simple instead of doing so in the separate lowering through backings field
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
override fun getCompanionObjectDescriptor(): ClassDescriptor? = companionObjectDescriptor() internal fun hasNestedClass(name: Name): Boolean = name in memberScope.classNames private fun computeSubclassesForSealedClass(): Collection<ClassDescriptor> { if (modality != Modality.SEALED) retur...
BTW even though this change doesn't seem to affect anything, it looks a bit incorrect because multi-field _value_ classes (`LanguageFeature.ValueClasses`, the feature which @zhelenskiy is working on) will not be represented in the way inline classes are represented in Kotlin metadata. We'll need at least a list of all ...
override fun getCompanionObjectDescriptor(): ClassDescriptor? = companionObjectDescriptor() internal fun hasNestedClass(name: Name): Boolean = name in memberScope.classNames private fun computeSubclassesForSealedClass(): Collection<ClassDescriptor> { if (modality != Modality.SEALED) retur...
@@ -177,7 +177,7 @@ class DeserializedClassDescriptor( override fun getInlineClassRepresentation(): InlineClassRepresentation<SimpleType>? = inlineClassRepresentation() private fun computeInlineClassRepresentation(): InlineClassRepresentation<SimpleType>? { - if (!isInlineClass()) return null + ...
core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt
26
Kotlin
0.643
bug
512
51
51
false
inlineClassUtils: Fix handling of inline classes without constructors (KT-50992)
4,725
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt PR Title: inlineClassUtils: Fix handling of inline classes without constructors (KT-50992) BEFORE CODE: override fun getCompanionObjectD...
BTW even though this change doesn't seem to affect anything, it looks a bit incorrect because multi-field _value_ classes (`LanguageFeature.ValueClasses`, the feature which @zhelenskiy is working on) will not be represented in the way inline classes are represented in Kotlin metadata. We'll need at least a list of all ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package kotlin.jvm.optionals import java.util.Optional /** * Returns this [Optional]'s value if [present][O...
Not sure what `out T` achieves in these functions comparing to just `T`
/* * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package kotlin.jvm.optionals import java.util.Optional /** * Returns this [Optional]'s value if [present][O...
@@ -0,0 +1,55 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.jvm.optionals + +import java.util.Optional + +/** + * Returns this [Opti...
libraries/stdlib/jdk8/src/kotlin/jvm/optionals/Optionals.kt
13
Kotlin
0.357
suggestion
71
38
38
false
Optionals
4,737
JetBrains/kotlin
51,705
Kotlin
ilya-g
kevin1e100
Review this pull request change. Language: Kotlin File: libraries/stdlib/jdk8/src/kotlin/jvm/optionals/Optionals.kt PR Title: Optionals BEFORE CODE: /* * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be f...
Not sure what `out T` achieves in these functions comparing to just `T`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
import kotlin.test.* import kotlin.jvm.optionals.* class OptionalsTest { @Test fun getOrNull() { assertEquals("foo", Optional.of("foo").getOrNull()) assertNull(Optional.empty<String>().getOrNull()) } @Test fun getOrDefault() { assertEquals("foo", Optional.of("foo").getOrDef...
`message` parameter here doesn't make it checked that the exception caught has the specified message. Instead it is used as a message of an assertion error if the assertion doesn't pass. If you want to check properties of the expected exception, you can use the following approach: https://youtrack.jetbrains.com/issue...
import kotlin.test.* import kotlin.jvm.optionals.* class OptionalsTest { @Test fun getOrNull() { assertEquals("foo", Optional.of("foo").getOrNull()) assertNull(Optional.empty<String>().getOrNull()) } @Test fun getOrDefault() { assertEquals("foo", Optional.of("foo").getOrDef...
@@ -0,0 +1,74 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.jdk8.jvm.optionals.test + +import java.util.Optional +import kotlin.test...
libraries/stdlib/jdk8/test/jvm/optionals/OptionalsTest.kt
26
Kotlin
0.786
suggestion
359
51
51
false
Optionals
4,737
JetBrains/kotlin
51,705
Kotlin
ilya-g
kevin1e100
Review this pull request change. Language: Kotlin File: libraries/stdlib/jdk8/test/jvm/optionals/OptionalsTest.kt PR Title: Optionals BEFORE CODE: import kotlin.test.* import kotlin.jvm.optionals.* class OptionalsTest { @Test fun getOrNull() { assertEquals("foo", Optional.of("foo").getOrNull()) ...
`message` parameter here doesn't make it checked that the exception caught has the specified message. Instead it is used as a message of an assertion error if the assertion doesn't pass. If you want to check properties of the expected exception, you can use the following approach: https://youtrack.jetbrains.com/issue...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/* * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package kotlin.jvm.optionals import java.util.Optional /** * Returns this [Optional]'s value if [present][O...
Let's annotate all new functions with ``` @SinceKotlin("1.7") @ExperimentalStdlibApi ```
/* * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package kotlin.jvm.optionals import java.util.Optional /** * Returns this [Optional]'s value if [present][O...
@@ -0,0 +1,55 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.jvm.optionals + +import java.util.Optional + +/** + * Returns this [Opti...
libraries/stdlib/jdk8/src/kotlin/jvm/optionals/Optionals.kt
18
Kotlin
0.571
suggestion
93
43
43
false
Optionals
4,737
JetBrains/kotlin
51,705
Kotlin
ilya-g
kevin1e100
Review this pull request change. Language: Kotlin File: libraries/stdlib/jdk8/src/kotlin/jvm/optionals/Optionals.kt PR Title: Optionals BEFORE CODE: /* * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be f...
Let's annotate all new functions with ``` @SinceKotlin("1.7") @ExperimentalStdlibApi ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
name + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, parameterTypes.toTypedArray(), loadReturnType(desc), isStaticDefault = isMember ) } fun findConstructorBySignature(desc: String): Constructor<*>? = jClass.tryGetConstructor(loadParameterTypes(desc)) fun findDefaultConstructor(desc: Stri...
I am very sorry, but I am not fluent in English. If there is a better way to express this, I would appreciate it if you could let me know.
name + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, parameterTypes.toTypedArray(), loadReturnType(desc), isStaticDefault = isMember ) } fun findConstructorBySignature(desc: String): Constructor<*>? = jClass.tryGetConstructor(loadParameterTypes(desc)) fun findDefaultConstructor(desc: Stri...
@@ -236,7 +236,17 @@ internal abstract class KDeclarationContainerImpl : ClassBasedDeclarationContain repeat((valueParameters.size + Integer.SIZE - 1) / Integer.SIZE) { result.add(Integer.TYPE) } - result.add(if (isConstructor) DEFAULT_CONSTRUCTOR_MARKER else Any::class.java) + + ...
core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt
26
Kotlin
0.429
suggestion
139
51
51
false
Partial fix for KT-27598
4,746
JetBrains/kotlin
51,705
Kotlin
k163377
k163377
Review this pull request change. Language: Kotlin File: core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt PR Title: Partial fix for KT-27598 BEFORE CODE: name + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, parameterTypes.toTypedArray(), loadReturnType(desc), isStaticDefault = isMemb...
I am very sorry, but I am not fluent in English. If there is a better way to express this, I would appreciate it if you could let me know.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} else -> 0 } val kotlinParameterTypes: List<KotlinType> = ArrayList<KotlinType>().also { kotlinParameterTypes -> val extensionReceiverType = descriptor.extensionReceiverParameter?.type if (extensionReceiverType != null) { kotlinParameter...
The correct formula is `(kotlinParameterTypes.size + Int.SIZE_BITS - 1) / Int.SIZE_BITS` which means to round the division result up to the nearest integer: https://github.com/JetBrains/kotlin/blob/d61e7db937499b0a26efacb8c10c5f92ec512aa2/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt...
} else -> 0 } val kotlinParameterTypes: List<KotlinType> = ArrayList<KotlinType>().also { kotlinParameterTypes -> val extensionReceiverType = descriptor.extensionReceiverParameter?.type if (extensionReceiverType != null) { kotlinParameter...
@@ -96,6 +93,10 @@ internal class InlineClassAwareCaller<out M : Member?>( descriptor.valueParameters.mapTo(kotlinParameterTypes, ValueParameterDescriptor::getType) } + + // If the default argument is set, ((paramSize / Int.SIZE_BITS) + 1) masks and one marker are added to the end of the ...
core/reflection.jvm/src/kotlin/reflect/jvm/internal/calls/InlineClassAwareCaller.kt
26
Kotlin
0.786
bug
500
51
51
false
Fix KT-51804
4,779
JetBrains/kotlin
51,705
Kotlin
udalov
k163377
Review this pull request change. Language: Kotlin File: core/reflection.jvm/src/kotlin/reflect/jvm/internal/calls/InlineClassAwareCaller.kt PR Title: Fix KT-51804 BEFORE CODE: } else -> 0 } val kotlinParameterTypes: List<KotlinType> = ArrayList<KotlinType>().also { kotlinPa...
The correct formula is `(kotlinParameterTypes.size + Int.SIZE_BITS - 1) / Int.SIZE_BITS` which means to round the division result up to the nearest integer: https://github.com/JetBrains/kotlin/blob/d61e7db937499b0a26efacb8c10c5f92ec512aa2/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
else -> 0 } val kotlinParameterTypes: List<KotlinType> = ArrayList<KotlinType>().also { kotlinParameterTypes -> val extensionReceiverType = descriptor.extensionReceiverParameter?.type if (extensionReceiverType != null) { kotlinParameterTypes.add(exte...
```suggestion val extraArgumentsTail = (if (isDefault) ((kotlinParameterTypes.size + Integer.SIZE - 1) / Integer.SIZE) + 1 else 0) + ``` Minor, but let's either use numbers in both places, or the constant `Integer.SIZE` in both places. :)
else -> 0 } val kotlinParameterTypes: List<KotlinType> = ArrayList<KotlinType>().also { kotlinParameterTypes -> val extensionReceiverType = descriptor.extensionReceiverParameter?.type if (extensionReceiverType != null) { kotlinParameterTypes.add(exte...
@@ -96,6 +93,11 @@ internal class InlineClassAwareCaller<out M : Member?>( descriptor.valueParameters.mapTo(kotlinParameterTypes, ValueParameterDescriptor::getType) } + + // If the default argument is set, + // (kotlinParameterTypes.size + Integer.SIZE - 1) / Integer.SIZE masks and...
core/reflection.jvm/src/kotlin/reflect/jvm/internal/calls/InlineClassAwareCaller.kt
26
Kotlin
1
suggestion
249
51
51
false
Fix KT-51804
4,779
JetBrains/kotlin
51,705
Kotlin
udalov
k163377
Review this pull request change. Language: Kotlin File: core/reflection.jvm/src/kotlin/reflect/jvm/internal/calls/InlineClassAwareCaller.kt PR Title: Fix KT-51804 BEFORE CODE: else -> 0 } val kotlinParameterTypes: List<KotlinType> = ArrayList<KotlinType>().also { kotlinParameterTypes -...
```suggestion val extraArgumentsTail = (if (isDefault) ((kotlinParameterTypes.size + Integer.SIZE - 1) / Integer.SIZE) + 1 else 0) + ``` Minor, but let's either use numbers in both places, or the constant `Integer.SIZE` in both places. :)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
data class A(val x: Double = 1.0, val y: String = "", val z: Char = '0') fun foo(a: A, block: (A, String, Int) -> String): String = block(a, "", 1) val arrayOfA: Array<A> = Array(1) { A() } fun box() { foo(A()) { (x, _, y), _, w -> val (a, _, c) = A() val (_, `_`, d) = A() for ...
The change here is that in fact there is no place where the q is visible in the debugger before and after this change. The code is: ``` for ((_, q) in arrayOfA) { } ``` The q is in the local variable table covering exactly one `iinc` instruction in the generated code before this change. That `iinc` instr...
data class A(val x: Double = 1.0, val y: String = "", val z: Char = '0') fun foo(a: A, block: (A, String, Int) -> String): String = block(a, "", 1) val arrayOfA: Array<A> = Array(1) { A() } fun box() { foo(A()) { (x, _, y), _, w -> val (a, _, c) = A() val (_, `_`, d) = A() for ...
@@ -23,7 +23,6 @@ fun box() { // METHOD : UnderscoreNamesKt$box$1.invoke(LA;Ljava/lang/String;I)Ljava/lang/String; // VARIABLE : NAME=x TYPE=D INDEX=4 // VARIABLE : NAME=y TYPE=C INDEX=6 -// VARIABLE : NAME=q TYPE=Ljava/lang/String; INDEX=16
compiler/testData/checkLocalVariablesTable/underscoreNames.kt
26
Kotlin
1
bug
447
39
40
false
[JVM IR] Limit local variables in do-while conditions.
4,782
JetBrains/kotlin
51,705
Kotlin
madsager
madsager
Review this pull request change. Language: Kotlin File: compiler/testData/checkLocalVariablesTable/underscoreNames.kt PR Title: [JVM IR] Limit local variables in do-while conditions. BEFORE CODE: data class A(val x: Double = 1.0, val y: String = "", val z: Char = '0') fun foo(a: A, block: (A, String, Int) -> Strin...
The change here is that in fact there is no place where the q is visible in the debugger before and after this change. The code is: ``` for ((_, q) in arrayOfA) { } ``` The q is in the local variable table covering exactly one `iinc` instruction in the generated code before this change. That `iinc` instr...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assertEquals(abs(exact), acosh(cosh(exact))) } for (approx in listOf(Double.MIN_VALUE, 0.00001, 1.0, 100.0, 710.0)) { assertAlmostEquals(approx, acosh(cosh(approx))) assertAlmostEquals(approx, acosh(cosh(-approx))) } for (invalid in listOf(-1.0, 0.0, 0...
I believe there's no need duplicating these tests for Native. The common MathTest should be run in Native as well.
assertEquals(abs(exact), acosh(cosh(exact))) } for (approx in listOf(Double.MIN_VALUE, 0.00001, 1.0, 100.0, 710.0)) { assertAlmostEquals(approx, acosh(cosh(approx))) assertAlmostEquals(approx, acosh(cosh(-approx))) } for (invalid in listOf(-1.0, 0.0, 0...
@@ -121,6 +121,42 @@ class DoubleMathTest { } } + @Test + fun cubeRoots() {
kotlin-native/backend.native/tests/stdlib_external/numbers/MathTest.kt
26
Kotlin
0.429
suggestion
114
51
51
false
KT-48232: Implement kotlin.math.cbrt() (cubic roots)
4,790
JetBrains/kotlin
51,705
Kotlin
ilya-g
romainguy
Review this pull request change. Language: Kotlin File: kotlin-native/backend.native/tests/stdlib_external/numbers/MathTest.kt PR Title: KT-48232: Implement kotlin.math.cbrt() (cubic roots) BEFORE CODE: assertEquals(abs(exact), acosh(cosh(exact))) } for (approx in listOf(Double.MIN_VALUE...
I believe there's no need duplicating these tests for Native. The common MathTest should be run in Native as well.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
assertEquals(abs(exact), acosh(cosh(exact))) } for (approx in listOf(Double.MIN_VALUE, 0.00001, 1.0, 100.0, 710.0)) { assertAlmostEquals(approx, acosh(cosh(approx))) assertAlmostEquals(approx, acosh(cosh(-approx))) } for (invalid in listOf(-1.0, 0.0, 0...
I propose to restructure this test a bit by introducing a list of pairs of source value and the corresponding expected result. These values can all be positive and later be used in the second part of test ensuring `cbrt(-x) == -cbrt(x)` Please add more numbers, not necessary round ones, from various ranges of Double...
@Test fun inverseHyperbolicSin() { for (exact in listOf(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0, Double.MIN_VALUE, -Double.MIN_VALUE, 0.00001)) { assertEquals(exact, asinh(sinh(exact))) } for (approx in listOf(Double.MIN_VALUE, 0.1, 1.0, 100.0, 710.0)) { ...
@@ -121,6 +121,41 @@ class DoubleMathTest { } } + @Test fun cubeRoots() { + assertEquals(3.0, cbrt(27.0))
libraries/stdlib/test/numbers/MathTest.kt
26
Kotlin
0.643
suggestion
340
51
51
false
KT-48232: Implement kotlin.math.cbrt() (cubic roots)
4,790
JetBrains/kotlin
51,705
Kotlin
ilya-g
romainguy
Review this pull request change. Language: Kotlin File: libraries/stdlib/test/numbers/MathTest.kt PR Title: KT-48232: Implement kotlin.math.cbrt() (cubic roots) BEFORE CODE: assertEquals(abs(exact), acosh(cosh(exact))) } for (approx in listOf(Double.MIN_VALUE, 0.00001, 1.0, 100.0, 710.0)...
I propose to restructure this test a bit by introducing a list of pairs of source value and the corresponding expected result. These values can all be positive and later be used in the second part of test ensuring `cbrt(-x) == -cbrt(x)` Please add more numbers, not necessary round ones, from various ranges of Double...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} /** * Returns the greater of two values. * * If either value is `NaN`, then the result is `NaN`. */ @SinceKotlin("1.2") public actual fun max(a: Double, b: Double): Double = when { a.isNaN() || b.isNaN() -> Double.NaN a == 0.0 && b == 0.0 -> if (!a.signBit()) a else b // -0.0 < +0.0 else -> if (a > b...
Minor: while other existing functions here might be `external public`, a more correct identifier order would be `public external`, so it makes sense to use it for the new functions.
} /** * Returns the greater of two values. * * If either value is `NaN`, then the result is `NaN`. */ @SinceKotlin("1.2") public actual fun max(a: Double, b: Double): Double = when { a.isNaN() || b.isNaN() -> Double.NaN a == 0.0 && b == 0.0 -> if (!a.signBit()) a else b // -0.0 < +0.0 else -> if (a > b...
@@ -384,6 +384,21 @@ public actual fun max(a: Double, b: Double): Double = when { else -> if (a > b) a else b } + +/** + * Returns the cube root of [x]. For positive finite `x`, `cbrt(-x) == -cbrt(x)`; + * that is, the cube root of a negative value is the negative of the cube root + * of that value's magnitude....
kotlin-native/runtime/src/main/kotlin/kotlin/math/math.kt
26
Kotlin
0.571
nitpick
182
51
51
false
KT-48232: Implement kotlin.math.cbrt() (cubic roots)
4,790
JetBrains/kotlin
51,705
Kotlin
ilya-g
romainguy
Review this pull request change. Language: Kotlin File: kotlin-native/runtime/src/main/kotlin/kotlin/math/math.kt PR Title: KT-48232: Implement kotlin.math.cbrt() (cubic roots) BEFORE CODE: } /** * Returns the greater of two values. * * If either value is `NaN`, then the result is `NaN`. */ @SinceKotlin("1.2") ...
Minor: while other existing functions here might be `external public`, a more correct identifier order would be `public external`, so it makes sense to use it for the new functions.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
* Special case: * - `sign(NaN)` is `NaN` */ @SinceKotlin("1.2") public expect fun sign(x: Double): Double /** * Returns the smaller of two values. * * If either value is `NaN`, then the result is `NaN`. */ @SinceKotlin("1.2") public expect fun min(a: Double, b: Double): Double /** * Returns the greater of ...
> For positive finite `x`, `cbrt(-x) == -cbrt(x)` Doesn't it hold for any `x` (maybe except NaN)?
* Special case: * - `sign(NaN)` is `NaN` */ @SinceKotlin("1.2") public expect fun sign(x: Double): Double /** * Returns the smaller of two values. * * If either value is `NaN`, then the result is `NaN`. */ @SinceKotlin("1.2") public expect fun min(a: Double, b: Double): Double /** * Returns the greater of ...
@@ -354,6 +354,20 @@ public expect fun min(a: Double, b: Double): Double @SinceKotlin("1.2") public expect fun max(a: Double, b: Double): Double + +/** + * Returns the cube root of [x]. For positive finite `x`, `cbrt(-x) == -cbrt(x)`;
libraries/stdlib/common/src/kotlin/MathH.kt
26
Kotlin
0.5
question
100
51
51
false
KT-48232: Implement kotlin.math.cbrt() (cubic roots)
4,790
JetBrains/kotlin
51,705
Kotlin
ilya-g
romainguy
Review this pull request change. Language: Kotlin File: libraries/stdlib/common/src/kotlin/MathH.kt PR Title: KT-48232: Implement kotlin.math.cbrt() (cubic roots) BEFORE CODE: * Special case: * - `sign(NaN)` is `NaN` */ @SinceKotlin("1.2") public expect fun sign(x: Double): Double /** * Returns the smaller ...
> For positive finite `x`, `cbrt(-x) == -cbrt(x)` Doesn't it hold for any `x` (maybe except NaN)?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.