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
} else { "()V" } invokespecial(superType, "<init>", desc, false) return 0 to propStartVar } else { val superProps = bindingContext.serializablePropertiesFor(superClass).serializableProperties val creator = buildInternalConst...
It looks like this solution does not work if we have optional fields. In this case, seen mask contains more one bits than the golden one, and therefore they're not equal.
invokespecial(superType, "<init>", desc, false) return 0 to propStartVar } else { val superProps = bindingContext.serializablePropertiesFor(superClass).serializableProperties val creator = buildInternalConstructorDesc(propStartVar, maskVar, classCodegen, superProp...
@@ -261,12 +277,94 @@ class SerializableCodegenImpl( return 0 to propStartVar } else { val superProps = bindingContext.serializablePropertiesFor(superClass).serializableProperties - val creator = buildInternalConstructorDesc(propStartVar, 1, classCodegen, superProps) + ...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/jvm/SerializableCodegenImpl.kt
26
Kotlin
0.357
suggestion
170
51
51
false
Optimize check for missing fields in deserialization
3,862
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/jvm/SerializableCodegenImpl.kt PR Title: Optimize check for missing fields in deserialization BEFORE CODE: } else { ...
It looks like this solution does not work if we have optional fields. In this case, seen mask contains more one bits than the golden one, and therefore they're not equal.
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.
dup() iconst(i) iconst(goldenMaskArray[i]) astore(OPT_MASK_TYPE) } load(descVar, descType) invokestatic( "kotlinx/serialization/internal/$PLUGIN_UTILS_LIBRARY_CLASS", THROW_MISSING_FIELD_EXCEPTION_METHOD,...
```suggestion return goldenMaskArray ```
) } visitLabel(allPresentsLabel) } private fun InstructionAdapter.stackSerialDescriptor() { if (serializableDescriptor.shouldHaveGeneratedSerializer && staticDescriptor) { val serializer = serializableDescriptor.classSerializer!! StackValue.singleton(...
@@ -261,12 +277,94 @@ class SerializableCodegenImpl( return 0 to propStartVar } else { val superProps = bindingContext.serializablePropertiesFor(superClass).serializableProperties - val creator = buildInternalConstructorDesc(propStartVar, 1, classCodegen, superProps) + ...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/jvm/SerializableCodegenImpl.kt
26
Kotlin
0.571
suggestion
50
51
51
false
Optimize check for missing fields in deserialization
3,862
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/jvm/SerializableCodegenImpl.kt PR Title: Optimize check for missing fields in deserialization BEFORE CODE: dup() ...
```suggestion return goldenMaskArray ```
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.
ificmpeq(allPresentsLabel) load(maskVar, OPT_MASK_TYPE) iconst(goldenMask) load(descVar, descType) invokestatic( "kotlinx/serialization/internal/$PLUGIN_UTILS_LIBRARY_CLASS", THROW_MISSING_FIELD_EXCEPTION_METHOD, "(IILkotlinx/s...
Maybe you'll find `InstructionAdapter.fillArray` function from JVMCodegenUtil.kt useful
stackSerialDescriptor() invokestatic( pluginUtilsType.internalName, SINGLE_MASK_FIELD_MISSING_FUNC_NAME.asString(), "(II${descType.descriptor})V", false ) } else { val fieldsMissingLabel = Label() ...
@@ -261,12 +277,94 @@ class SerializableCodegenImpl( return 0 to propStartVar } else { val superProps = bindingContext.serializablePropertiesFor(superClass).serializableProperties - val creator = buildInternalConstructorDesc(propStartVar, 1, classCodegen, superProps) + ...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/jvm/SerializableCodegenImpl.kt
26
Kotlin
0.429
suggestion
87
51
51
false
Optimize check for missing fields in deserialization
3,862
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/jvm/SerializableCodegenImpl.kt PR Title: Optimize check for missing fields in deserialization BEFORE CODE: ificmpeq(allPresentsLabel...
Maybe you'll find `InstructionAdapter.fillArray` function from JVMCodegenUtil.kt useful
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.kotlinx.serialization.compiler.backend.jvm import org.jetbrains.kotlin.codegen.* import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.Prop...
This val can also be a member of `SerializableCodegenImpl`, no need to be top-level for it
package org.jetbrains.kotlinx.serialization.compiler.backend.jvm import org.jetbrains.kotlin.codegen.* import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.js....
@@ -28,18 +29,25 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassOrAny import org.jetbrains.kotlin.resolve.descriptorUtil.module +import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin ...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/jvm/SerializableCodegenImpl.kt
26
Kotlin
0.357
suggestion
90
51
51
false
Optimize check for missing fields in deserialization
3,862
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/jvm/SerializableCodegenImpl.kt PR Title: Optimize check for missing fields in deserialization BEFORE CODE: package org.jetbrains.kotlinx.seriali...
This val can also be a member of `SerializableCodegenImpl`, no need to be top-level 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.
// classes val KSERIALIZER_NAME = Name.identifier(KSERIALIZER_CLASS) val SERIAL_CTOR_MARKER_NAME = Name.identifier("SerializationConstructorMarker") val KSERIALIZER_NAME_FQ = SerializationPackages.packageFqName.child(KSERIALIZER_NAME) val SERIALIZER_CLASS_NAME = Name.identifier(SERIALIZER_CLASS) ...
Sorry for late notice, but that just came into my mind: by calling this file 'utils', we risk ending up with long file with a lot of unrelated stuff. I'd suggest avoid such technique and name files using logical groups, e.g. 'PluginExceptions'
const val initializedDescriptorFieldName = "\$initializedDescriptor" // classes val KSERIALIZER_NAME = Name.identifier(KSERIALIZER_CLASS) val SERIAL_CTOR_MARKER_NAME = Name.identifier("SerializationConstructorMarker") val KSERIALIZER_NAME_FQ = SerializationPackages.packageFqName.child(KSERIALIZER_...
@@ -68,6 +68,8 @@ object SerialEntityNames { const val SERIAL_DESCRIPTOR_CLASS_IMPL = "PluginGeneratedSerialDescriptor" const val SERIAL_DESCRIPTOR_FOR_ENUM = "EnumDescriptor" + const val PLUGIN_UTILS_FILE = "PluginUtils"
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/resolve/NamingConventions.kt
26
Kotlin
0.643
suggestion
243
51
51
false
Optimize check for missing fields in deserialization
3,862
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/resolve/NamingConventions.kt PR Title: Optimize check for missing fields in deserialization BEFORE CODE: // classes val KSERIALIZER_NAME = Name...
Sorry for late notice, but that just came into my mind: by calling this file 'utils', we risk ending up with long file with a lot of unrelated stuff. I'd suggest avoid such technique and name files using logical groups, e.g. 'PluginExceptions'
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.
).also { call -> typeArguments.forEachIndexed(call::putTypeArgument) } fun IrBuilderWithScope.createArrayOfExpression( arrayElementType: IrType, arrayElements: List<IrExpression> ): IrExpression { val arrayType = compilerContext.irBuiltIns.arrayClass.typeWith(arrayElementType) ...
Are you sure that this creates correct array of unboxed values? Shouldn't it be `intArrayOf` instead of `arrayOf`?
typeHint = returnTypeHint ).also { call -> typeArguments.forEachIndexed(call::putTypeArgument) } fun IrBuilderWithScope.createArrayOfExpression( arrayElementType: IrType, arrayElements: List<IrExpression> ): IrExpression { val arrayType = compilerContext.irBuiltIns....
@@ -108,6 +133,19 @@ interface IrBuilderExtension { } } + fun IrBuilderWithScope.createPrimitiveArrayOfExpression( + elementPrimitiveType: IrType, + arrayElements: List<IrExpression> + ): IrExpression { + val arrayType = compilerContext.irBuiltIns.primitiveArrayForType.getValu...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt
26
Kotlin
0.571
question
114
51
51
false
Optimize check for missing fields in deserialization
3,862
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: Optimize check for missing fields in deserialization BEFORE CODE: ).also { call -> typeArguments.forEac...
Are you sure that this creates correct array of unboxed values? Shouldn't it be `intArrayOf` instead of `arrayOf`?
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.builders.declarations.addField import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImpl import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains...
Why another one? All serialization plugin-generated origins should be the same one
import org.jetbrains.kotlin.ir.builders.declarations.addField import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImpl import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains...
@@ -8,32 +8,53 @@ package org.jetbrains.kotlinx.serialization.compiler.backend.ir import org.jetbrains.kotlin.backend.common.deepCopyWithVariables import org.jetbrains.kotlin.backend.common.lower.irThrow import org.jetbrains.kotlin.codegen.CompilationException -import org.jetbrains.kotlin.descriptors.ClassConstructo...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt
26
Kotlin
0.286
question
82
51
51
false
Optimize check for missing fields in deserialization
3,862
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: Optimize check for missing fields in deserialization BEFORE CODE: import org.jetbrains.kotlin.ir.builder...
Why another one? All serialization plugin-generated origins should be the same one
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.
getSerialDescriptorExpr(), typeHint = compilerContext.irBuiltIns.unitType ) } } +irIfThen(compilerContext.irBuiltIns.unitType, fieldsMissedTest, throwErrorExpr) } private fun IrBlockBodyBuilder.getSerialDescriptorExpr(): IrExp...
Why there is a need in inlined function?
typeHint = compilerContext.irBuiltIns.unitType ) } } +irIfThen(compilerContext.irBuiltIns.unitType, fieldsMissedTest, throwErrorExpr) } private fun IrBlockBodyBuilder.getSerialDescriptorExpr(): IrExpression { return if (serializableDescri...
@@ -116,6 +148,153 @@ class SerializableIrGenerator( } } + private fun IrBlockBodyBuilder.generateOptimizedGoldenMaskCheck(seenVars: List<IrValueParameter>) { + if (serializableDescriptor.isAbstractSerializableClass() || serializableDescriptor.isSealedSerializableClass()) { + ...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt
26
Kotlin
0.071
question
40
51
51
false
Optimize check for missing fields in deserialization
3,862
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: Optimize check for missing fields in deserialization BEFORE CODE: getSerialDescripto...
Why there is a need in inlined function?
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.
// FILE: test.kt inline fun alsoInline() = "OK" inline fun ifoo(s: String = alsoInline()): String { return s } fun box(): String { return ifoo() } // `alsoInline` is inlined in the `ifoo$default` stub. When exiting the inline // codegen, the line number is reset. Therefore any code generated with line // nu...
Looks like this sentence is a bit misleading. The line number after the default value is not caused by the parameter non-null checks because if we suppress their generation by making `ifoo` private, we still generate that line number. I still think that JVM IR is correct, it's just that the comment should be slightly m...
// FILE: test.kt inline fun alsoInline() = "OK" inline fun ifoo(s: String = alsoInline()): String { return s } fun box(): String { return ifoo() } // `alsoInline` is inlined in the `ifoo$default` stub. When exiting the inline // codegen, the line number is reset. Therefore any code generated with line // nu...
@@ -10,9 +10,29 @@ fun box(): String { return ifoo() } +// `alsoInline` is inlined in the `ifoo$default` stub. When exiting the inline +// codegen, the line number is reset. Therefore any code generated with line +// number information will emit a new line number so that stepping continues +// in the caller. +/...
compiler/testData/debug/stepping/simpleInlineDefaultArg.kt
23
Kotlin
0.786
suggestion
327
38
38
false
[JVM_IR] Rebase inline function and defaults args stepping test.
3,867
JetBrains/kotlin
51,705
Kotlin
udalov
madsager
Review this pull request change. Language: Kotlin File: compiler/testData/debug/stepping/simpleInlineDefaultArg.kt PR Title: [JVM_IR] Rebase inline function and defaults args stepping test. BEFORE CODE: // FILE: test.kt inline fun alsoInline() = "OK" inline fun ifoo(s: String = alsoInline()): String { return ...
Looks like this sentence is a bit misleading. The line number after the default value is not caused by the parameter non-null checks because if we suppress their generation by making `ifoo` private, we still generate that line number. I still think that JVM IR is correct, it's just that the comment should be slightly m...
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.
suspend fun box() = foo(A()) { (x_param, _, y_param) -> x_param + y_param } // Parameters (including anonymous destructuring parameters) are moved to fields in the Continuation class for the suspend lambda class. // However, in non-IR, the fields are first stored in local variables, and they are not read directly ...
Instead of rebasing this, we should probably remove (or have an empty) local variable table for synthetic methods with no line numbers?
suspend fun box() = foo(A()) { (x_param, _, y_param) -> x_param + y_param } // Parameters (including anonymous destructuring parameters) are moved to fields in the Continuation class for the suspend lambda class. // However, in non-IR, the fields are first stored in local variables, and they are not read directly ...
@@ -17,36 +17,50 @@ suspend fun box() = foo(A()) { (x_param, _, y_param) -> // However, in non-IR, the fields are first stored in local variables, and they are not read directly (even for destructuring components). // In IR, the fields are directly read from. -// METHOD : UnderscoreNamesKt$test$2.invokeSuspend(Ljav...
compiler/testData/debug/localVariables/suspend/underscoreNames.kt
26
Kotlin
0.429
question
135
51
51
false
[JVM+IR] Rebase LVT test of destructuring in lambda params
3,871
JetBrains/kotlin
51,705
Kotlin
madsager
kandersen
Review this pull request change. Language: Kotlin File: compiler/testData/debug/localVariables/suspend/underscoreNames.kt PR Title: [JVM+IR] Rebase LVT test of destructuring in lambda params BEFORE CODE: suspend fun box() = foo(A()) { (x_param, _, y_param) -> x_param + y_param } // Parameters (including anonym...
Instead of rebasing this, we should probably remove (or have an empty) local variable table for synthetic methods with no line numbers?
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 // WITH_COROUTINES // FILE: test.kt class A { operator fun component1() = "O" operator fun component2(): String = throw RuntimeException("fail 0") operator fun component3() = "K" } suspend fun foo(a: A, block: suspend (A) -> String): String = block(a) suspend fun box() = foo(A()) { (x_para...
Is it right only for suspend lambdas? Or for general one too?
// WITH_RUNTIME // WITH_COROUTINES // FILE: test.kt class A { operator fun component1() = "O" operator fun component2(): String = throw RuntimeException("fail 0") operator fun component3() = "K" } suspend fun foo(a: A, block: suspend (A) -> String): String = block(a) suspend fun box() = foo(A()) { (x_para...
@@ -17,36 +17,50 @@ suspend fun box() = foo(A()) { (x_param, _, y_param) -> // However, in non-IR, the fields are first stored in local variables, and they are not read directly (even for destructuring components). // In IR, the fields are directly read from. -// METHOD : UnderscoreNamesKt$test$2.invokeSuspend(Ljav...
compiler/testData/debug/localVariables/suspend/underscoreNames.kt
21
Kotlin
0.214
question
61
46
46
false
[JVM+IR] Rebase LVT test of destructuring in lambda params
3,871
JetBrains/kotlin
51,705
Kotlin
max-kammerer
kandersen
Review this pull request change. Language: Kotlin File: compiler/testData/debug/localVariables/suspend/underscoreNames.kt PR Title: [JVM+IR] Rebase LVT test of destructuring in lambda params BEFORE CODE: // WITH_RUNTIME // WITH_COROUTINES // FILE: test.kt class A { operator fun component1() = "O" operator f...
Is it right only for suspend lambdas? Or for general one 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.
// But we only need the following type-erased version to generate correct calls. klass.addFunction("valueOf", klass.defaultType, isStatic = true).apply { addValueParameter("enumType", javaLangClass.starProjectedType) addValueParameter("name", irBuiltIns.stringType...
It would be great to use the same IR class symbol instance as in psi2ir, at least to avoid code duplication. I propose to pass the `JvmGeneratorExtensions` instance to `JvmBackendContext` (instead of `classNameOverride`), and use `context.generatorExtensions.rawTypeAnnotationConstructor` in `rawType`.
} } val enumValueOfFunction: IrSimpleFunctionSymbol = javaLangEnum.functionByName("valueOf") private val kotlinCoroutinesJvmInternalRunSuspendKt = createClass(FqName("kotlin.coroutines.jvm.internal.RunSuspendKt")) { klass -> klass.addFunction("runSuspend", irBui...
@@ -723,6 +727,16 @@ class JvmSymbols( val runSuspendFunction: IrSimpleFunctionSymbol = kotlinCoroutinesJvmInternalRunSuspendKt.functionByName("runSuspend") + + val rawTypeAnnotationClass: IrClassSymbol =
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt
26
Kotlin
0.786
suggestion
302
42
28
false
JVM IR: SAM wrapper ABI fixes
3,873
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt PR Title: JVM IR: SAM wrapper ABI fixes BEFORE CODE: // But we only need the following type-erased version to generate correct calls. klass.addFunction("valueOf"...
It would be great to use the same IR class symbol instance as in psi2ir, at least to avoid code duplication. I propose to pass the `JvmGeneratorExtensions` instance to `JvmBackendContext` (instead of `classNameOverride`), and use `context.generatorExtensions.rawTypeAnnotationConstructor` in `rawType`.
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 IrFunction.allTypeParameters: List<IrTypeParameter> get() = if (this is IrConstructor) parentAsClass.typeParameters + typeParameters else typeParameters fun IrMemberAccessExpression<*>.getTypeSubstitutionMap(irFunction: IrFunction): Map<IrTypeParameterSymbol, IrType> { val typeP...
(`associateTo` returns destination) ```suggestion return typeParameters.withIndex().associateTo(result) { ```
is IrDeclaration -> it.parentClassOrNull else -> null } } val IrFunction.allTypeParameters: List<IrTypeParameter> get() = if (this is IrConstructor) parentAsClass.typeParameters + typeParameters else typeParameters fun IrMemberAccessExpression<*>.getTypeSub...
@@ -515,11 +512,27 @@ val IrFunction.allTypeParameters: List<IrTypeParameter> else typeParameters + fun IrMemberAccessExpression<*>.getTypeSubstitutionMap(irFunction: IrFunction): Map<IrTypeParameterSymbol, IrType> { val typeParameters = irFunction.allTypeParameters - return if (typeParameters....
compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt
26
Kotlin
0.857
suggestion
116
51
51
false
[JVM_IR] Determine correct type of empty varargs array.
3,874
JetBrains/kotlin
51,705
Kotlin
udalov
madsager
Review this pull request change. Language: Kotlin File: compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt PR Title: [JVM_IR] Determine correct type of empty varargs array. BEFORE CODE: } val IrFunction.allTypeParameters: List<IrTypeParameter> get() = if (this is IrConstructor) parentA...
(`associateTo` returns destination) ```suggestion return typeParameters.withIndex().associateTo(result) { ```
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 -> null } } val IrFunction.allTypeParameters: List<IrTypeParameter> get() = if (this is IrConstructor) parentAsClass.typeParameters + typeParameters else typeParameters fun IrMemberAccessExpression<*>.getTypeSubstitutionMap(irFunction: IrFunction): Map<IrTypeParam...
Can we make this `typeOrNull!!` or would it fail in some case?
when (it) { is IrClass -> it is IrDeclaration -> it.parentClassOrNull else -> null } } val IrFunction.allTypeParameters: List<IrTypeParameter> get() = if (this is IrConstructor) parentAsClass.typeParameters + typeParameters else typeParame...
@@ -515,11 +512,27 @@ val IrFunction.allTypeParameters: List<IrTypeParameter> else typeParameters + fun IrMemberAccessExpression<*>.getTypeSubstitutionMap(irFunction: IrFunction): Map<IrTypeParameterSymbol, IrType> { val typeParameters = irFunction.allTypeParameters - return if (typeParameters....
compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt
26
Kotlin
0.5
bug
62
51
51
false
[JVM_IR] Determine correct type of empty varargs array.
3,874
JetBrains/kotlin
51,705
Kotlin
udalov
madsager
Review this pull request change. Language: Kotlin File: compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt PR Title: [JVM_IR] Determine correct type of empty varargs array. BEFORE CODE: else -> null } } val IrFunction.allTypeParameters: List<IrTypeParameter> get() = if (thi...
Can we make this `typeOrNull!!` or would it fail in some case?
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.
/* Borrowed from inlineOnly.kt */ fun IrDeclarationWithVisibility.isInlineOnlyOrReifiable(): Boolean = this is IrFunction && (isReifiable() || isInlineOnly()) fun IrDeclarationWithVisibility.isEffectivelyInlineOnly(): Boolean = isInlineOnlyOrReifiable() || isInlineOnlyPrivateInBytecode() || isInlineOnlyProper...
This is a really minor nitpick, but maybe make this `internal` and use it in `FunctionCodegen.calculateMethodFlags`? And possibly also in `MethodSignatureMapper.mapOverriddenSpecialBuiltinIfNeeded`
fun IrDeclarationWithVisibility.isInlineOnlyOrReifiable(): Boolean = this is IrFunction && (isReifiable() || isInlineOnly()) fun IrDeclarationWithVisibility.isEffectivelyInlineOnly(): Boolean = isInlineOnlyOrReifiable() || isInlineOnlyPrivateInBytecode() || isInlineOnlyPropertyAccessor() fun IrDeclarationWit...
@@ -304,6 +253,8 @@ fun IrFunction.isInlineOnly() = fun IrFunction.isReifiable() = typeParameters.any { it.isReified } +private fun IrFunction.isBridge() = origin == IrDeclarationOrigin.BRIDGE || origin == IrDeclarationOrigin.BRIDGE_SPECIAL
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt
26
Kotlin
0.571
nitpick
197
51
51
false
[JVM_IR] Follow old backend in bridge visibility and varargs marking.
3,879
JetBrains/kotlin
51,705
Kotlin
udalov
madsager
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt PR Title: [JVM_IR] Follow old backend in bridge visibility and varargs marking. BEFORE CODE: /* Borrowed from inlineOnly.kt */ fun IrDeclarationWithVisibility.isInlineOnlyO...
This is a really minor nitpick, but maybe make this `internal` and use it in `FunctionCodegen.calculateMethodFlags`? And possibly also in `MethodSignatureMapper.mapOverriddenSpecialBuiltinIfNeeded`
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.
if (this is IrConstructor) it else it or Opcodes.ACC_STATIC } } val isVararg = valueParameters.lastOrNull()?.varargElementType != null val isBridge = origin == IrDeclarationOrigin.BRIDGE || origin == IrDeclarationOrigin.BRIDGE_SPECIAL val modalityFlag = when ...
Another minor nitpick, but I'd prefer if `&& !isBridge` was a part of the `isVararg` value declaration, just to avoid misusing `isVararg` between its declaration and this usage
if (this is IrConstructor) it else it or Opcodes.ACC_STATIC } } val isVararg = valueParameters.lastOrNull()?.varargElementType != null && !isBridge() val modalityFlag = when ((this as? IrSimpleFunction)?.modality) { Modality.FINAL -> when { ...
@@ -170,7 +170,7 @@ class FunctionCodegen( return getVisibilityAccessFlag() or modalityFlag or functionDeprecationFlags or (if (isStatic) Opcodes.ACC_STATIC else 0) or - (if (isVararg) Opcodes.ACC_VARARGS else 0) or + (if (isVararg && !isBridge) Opcodes.ACC_VARA...
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt
26
Kotlin
0.571
suggestion
176
51
51
false
[JVM_IR] Follow old backend in bridge visibility and varargs marking.
3,879
JetBrains/kotlin
51,705
Kotlin
udalov
madsager
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt PR Title: [JVM_IR] Follow old backend in bridge visibility and varargs marking. BEFORE CODE: if (this is IrConstructor) it else it or Opcodes.ACC_STATIC ...
Another minor nitpick, but I'd prefer if `&& !isBridge` was a part of the `isVararg` value declaration, just to avoid misusing `isVararg` between its declaration and this usage
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.
withDaemon: Boolean = true ): File { val wrapper = gradleWrappers.getOrPut(version) { createNewWrapperDir(version) } if (withDaemon) { DaemonRegistry.register(version) if (DaemonRegistry.activeDaemons.size > MAX_ACTIVE_GRADLE_PROCESSES) { ...
Rename to "maybeUpdateSettingsScript"?
withDaemon: Boolean = true ): File { val wrapper = gradleWrappers.getOrPut(version) { createNewWrapperDir(version) } if (withDaemon) { DaemonRegistry.register(version) if (DaemonRegistry.activeDaemons.size > MAX_ACTIVE_GRADLE_PROCESSES) { ...
@@ -153,6 +153,20 @@ abstract class BaseGradleIT { return wrapper } + fun mightUpdateSettingsScript(wrapperVersion: String, settingsScript: File) {
libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt
26
Kotlin
0.143
question
38
51
51
false
MPP plugin: add expectedBy deps to "api" configuration
3,909
JetBrains/kotlin
51,705
Kotlin
gavra0
bingranl
Review this pull request change. Language: Kotlin File: libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt PR Title: MPP plugin: add expectedBy deps to "api" configuration BEFORE CODE: withDaemon: Boolean = true ): File { ...
Rename to "maybeUpdateSettingsScript"?
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 open fun getSuppressed(exception: Throwable): List<Throwable> { @Suppress("UNCHECKED_CAST") return ReflectThrowable.getSuppressed?.invoke(exception)?.let { (it as Array<Throwable>).asList() } ?: emptyList() } public open fun getMatchResultNamedGroup(matchResult: Ma...
Please revert formatting changes unrelated to the code regions you have changed.
public open fun getSuppressed(exception: Throwable): List<Throwable> { @Suppress("UNCHECKED_CAST") return ReflectThrowable.getSuppressed?.invoke(exception)?.let { (it as Array<Throwable>).asList() } ?: emptyList() } public open fun getMatchResultNamedGroup(matchResult: MatchRes...
@@ -51,20 +52,28 @@ internal val IMPLEMENTATIONS: PlatformImplementations = run { val version = getJavaVersion() if (version >= 0x10008) { try { - return@run castToBaseType<PlatformImplementations>(Class.forName("kotlin.internal.jdk8.JDK8PlatformImplementations").newInstance()) - } ...
libraries/stdlib/jvm/src/kotlin/internal/PlatformImplementations.kt
26
Kotlin
0.286
style
80
51
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jvm/src/kotlin/internal/PlatformImplementations.kt PR Title: Make random implementations serializable BEFORE CODE: } public open fun getSuppressed(exception: Throwable): List<Throwable> { @Suppress("UNCHECKED_CAST") re...
Please revert formatting changes unrelated to the code regions you have changed.
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. */ package kotlin.random.jdk8 import java.util.concurrent.ThreadLocalRandom @Suppress("INVISIBLE_REFERENCE", "I...
Why such `serialVersionUID` values, do they mean something? I believe we can start with `serialVersionUID = 1L` for all serializable entities.
/* * 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. */ package kotlin.random.jdk8 import java.util.concurrent.ThreadLocalRandom @Suppress("INVISIBLE_REFERENCE", "I...
@@ -8,15 +8,20 @@ package kotlin.random.jdk8 import java.util.concurrent.ThreadLocalRandom @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") -internal class PlatformThreadLocalRandom : kotlin.random.AbstractPlatformRandom() { +internal object PlatformThreadLocalRandom : kotlin...
libraries/stdlib/jdk8/src/kotlin/random/jdk8/PlatformThreadLocalRandom.kt
12
Kotlin
0.5
question
142
28
22
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jdk8/src/kotlin/random/jdk8/PlatformThreadLocalRandom.kt PR Title: Make random implementations serializable BEFORE CODE: /* * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is gov...
Why such `serialVersionUID` values, do they mean something? I believe we can start with `serialVersionUID = 1L` for all serializable entities.
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. */ package kotlin.random.jdk8 import java.util.concurrent.ThreadLocalRandom @Suppress("INVISIBLE_REFERENCE", "I...
I think such internal implementations should not be serializable at all. `Random.Default` manages its singleton serialization entirely and therefore it shouldn't expose any implementation details in a serialized form.
/* * 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. */ package kotlin.random.jdk8 import java.util.concurrent.ThreadLocalRandom @Suppress("INVISIBLE_REFERENCE", "I...
@@ -8,15 +8,20 @@ package kotlin.random.jdk8 import java.util.concurrent.ThreadLocalRandom @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") -internal class PlatformThreadLocalRandom : kotlin.random.AbstractPlatformRandom() { +internal object PlatformThreadLocalRandom : kotlin...
libraries/stdlib/jdk8/src/kotlin/random/jdk8/PlatformThreadLocalRandom.kt
26
Kotlin
0.643
suggestion
219
28
22
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jdk8/src/kotlin/random/jdk8/PlatformThreadLocalRandom.kt PR Title: Make random implementations serializable BEFORE CODE: /* * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is gov...
I think such internal implementations should not be serializable at all. `Random.Default` manages its singleton serialization entirely and therefore it shouldn't expose any implementation details in a serialized form.
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 nextInt(): Int = impl.nextInt() override fun nextInt(until: Int): Int = impl.nextInt(until) override fun nextLong(): Long = impl.nextLong() override fun nextBoolean(): Boolean = impl.nextBoolean() override fun nextDouble(): Double = impl.nextDouble() override fun nextFloat(): Float ...
Companion object with just a single private const should be private.
override fun nextInt(): Int = impl.nextInt() override fun nextInt(until: Int): Int = impl.nextInt(until) override fun nextLong(): Long = impl.nextLong() override fun nextBoolean(): Boolean = impl.nextBoolean() override fun nextDouble(): Double = impl.nextDouble() override fun nextFloat(): Float ...
@@ -47,17 +47,26 @@ internal abstract class AbstractPlatformRandom : Random() { override fun nextBytes(array: ByteArray): ByteArray = array.also { impl.nextBytes(it) } } -internal class FallbackThreadLocalRandom : AbstractPlatformRandom() { +internal object FallbackThreadLocalRandom : AbstractPlatformRandom(), ...
libraries/stdlib/jvm/src/kotlin/random/PlatformRandom.kt
26
Kotlin
0.286
suggestion
68
51
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jvm/src/kotlin/random/PlatformRandom.kt PR Title: Make random implementations serializable BEFORE CODE: override fun nextInt(): Int = impl.nextInt() override fun nextInt(until: Int): Int = impl.nextInt(until) override fun nextLong(...
Companion object with just a single private const should be private.
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.
/** * Fills the specified byte [array] with random bytes and returns it. * * @return [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(array: ByteArray): ByteArray = nextBytes(array, 0, array.size) /** * Creates a ...
Better to use `writeReplace` to avoid exposing `defaultRandom` field.
/** * Fills the specified byte [array] with random bytes and returns it. * * @return [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(array: ByteArray): ByteArray = nextBytes(array, 0, array.size) /** * Creates a ...
@@ -267,10 +267,12 @@ public abstract class Random { * * @sample samples.random.Randoms.defaultRandom */ - companion object Default : Random() { - + companion object Default : Random(), Serializable { + private const val serialVersionUID = 6449517406788167720L private val default...
libraries/stdlib/src/kotlin/random/Random.kt
26
Kotlin
0.429
suggestion
69
51
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/src/kotlin/random/Random.kt PR Title: Make random implementations serializable BEFORE CODE: /** * Fills the specified byte [array] with random bytes and returns it. * * @return [array] filled with random bytes. * *...
Better to use `writeReplace` to avoid exposing `defaultRandom` 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.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ @file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") package kotlin.internal.jdk8 import jav...
This change should be in a separate commit, or even better, in a separate PR.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ @file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") package kotlin.internal.jdk8 import jav...
@@ -29,13 +29,13 @@ internal open class JDK8PlatformImplementations : JDK7PlatformImplementations() override fun getMatchResultNamedGroup(matchResult: MatchResult, name: String): MatchGroup? { val matcher = matchResult as? Matcher ?: throw UnsupportedOperationException("Retrieving groups by name is not su...
libraries/stdlib/jdk8/src/kotlin/internal/jdk8/JDK8PlatformImplementations.kt
26
Kotlin
0.286
suggestion
77
31
31
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jdk8/src/kotlin/internal/jdk8/JDK8PlatformImplementations.kt PR Title: Make random implementations serializable BEFORE CODE: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific langua...
This change should be in a separate commit, or even better, in a separate PR.
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. */ package kotlin.random.jdk8 import java.util.concurrent.ThreadLocalRandom @Suppress("INVISIBLE_REFERENCE", "I...
I don't see much sense in transforming it to `object`. It is instantiated once and then is kept in a private property of `Random` companion object. So no need to have another instance where its reference is stored. Same for `FallbackThreadLocalRandom`
/* * 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. */ package kotlin.random.jdk8 import java.util.concurrent.ThreadLocalRandom @Suppress("INVISIBLE_REFERENCE", "I...
@@ -8,7 +8,7 @@ package kotlin.random.jdk8 import java.util.concurrent.ThreadLocalRandom @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") -internal class PlatformThreadLocalRandom : kotlin.random.AbstractPlatformRandom() { +internal object PlatformThreadLocalRandom : kotlin.r...
libraries/stdlib/jdk8/src/kotlin/random/jdk8/PlatformThreadLocalRandom.kt
11
Kotlin
0.714
suggestion
252
22
22
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jdk8/src/kotlin/random/jdk8/PlatformThreadLocalRandom.kt PR Title: Make random implementations serializable BEFORE CODE: /* * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is gov...
I don't see much sense in transforming it to `object`. It is instantiated once and then is kept in a private property of `Random` companion object. So no need to have another instance where its reference is stored. Same for `FallbackThreadLocalRandom`
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.
/** * Fills the specified byte [array] with random bytes and returns it. * * @return [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(array: ByteArray): ByteArray = nextBytes(array, 0, array.size) /** * Creates a ...
I still don't get what bad can happen if we set `serialVersionUID = 1L` in all such classes?
/** * Fills the specified byte [array] with random bytes and returns it. * * @return [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(array: ByteArray): ByteArray = nextBytes(array, 0, array.size) /** * Creates a ...
@@ -267,10 +267,12 @@ public abstract class Random { * * @sample samples.random.Randoms.defaultRandom */ - companion object Default : Random() { - + companion object Default : Random(), Serializable { + private const val serialVersionUID = 6449517406788167720L
libraries/stdlib/src/kotlin/random/Random.kt
26
Kotlin
0.357
question
92
51
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/src/kotlin/random/Random.kt PR Title: Make random implementations serializable BEFORE CODE: /** * Fills the specified byte [array] with random bytes and returns it. * * @return [array] filled with random bytes. * *...
I still don't get what bad can happen if we set `serialVersionUID = 1L` in all such classes?
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 [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(array: ByteArray): ByteArray = nextBytes(array, 0, array.size) /** * Creates a byte array of the specified [size], filled with random bytes. * * @sample sampl...
We definitely do not want to evaluate this again on each call to Random.Default's methods. Please revert to storing the implementation here and resort to serialization surrogate approach.
* @return [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(array: ByteArray): ByteArray = nextBytes(array, 0, array.size) /** * Creates a byte array of the specified [size], filled with random bytes. * * @sample sampl...
@@ -267,9 +267,13 @@ public abstract class Random { * * @sample samples.random.Randoms.defaultRandom */ - companion object Default : Random() { + companion object Default : Random(), Serializable { + private const val serialVersionUID = 0L - private val defaultRandom: Random = de...
libraries/stdlib/src/kotlin/random/Random.kt
26
Kotlin
0.357
style
187
51
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/src/kotlin/random/Random.kt PR Title: Make random implementations serializable BEFORE CODE: * @return [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(array: By...
We definitely do not want to evaluate this again on each call to Random.Default's methods. Please revert to storing the implementation here and resort to serialization surrogate approach.
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.random.asJavaRandom import kotlin.random.asKotlinRandom import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertSame class RandomSerializationTest { @Test fun defaultIsSerializable() { val instance = Random assertSame(instance, serializeAndDeserialize(inst...
In this test we should use `assertSame` check. In the test with predictable Random, we can compare several `next*` values with the expected instance.
import kotlin.random.asJavaRandom import kotlin.random.asKotlinRandom import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertSame import kotlin.test.assertTrue class RandomSerializationTest { @Test fun defaultIsSerializable() { val instance = Random discardSomeValues(i...
@@ -0,0 +1,53 @@ +/* + * 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 random + +import test.io.deserializeFromHex +import test.io.serializeAndDeseria...
libraries/stdlib/jvm/test/random/RandomSerializationTest.kt
26
Kotlin
0.571
suggestion
149
44
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jvm/test/random/RandomSerializationTest.kt PR Title: Make random implementations serializable BEFORE CODE: import kotlin.random.asJavaRandom import kotlin.random.asKotlinRandom import kotlin.test.Test import kotlin.test.assertEquals import kot...
In this test we should use `assertSame` check. In the test with predictable Random, we can compare several `next*` values with the expected instance.
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 random import test.io.deserializeFromHex import test.io.serializeAndDeserialize import kotlin.random....
@ilya-g this test already checks that Random.default instances are same when serialized.
/* * 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 random import test.io.deserializeFromHex import test.io.serializeAndDeserialize import kotlin.random....
@@ -0,0 +1,53 @@ +/* + * 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 random + +import test.io.deserializeFromHex +import test.io.serializeAndDeseria...
libraries/stdlib/jvm/test/random/RandomSerializationTest.kt
23
Kotlin
0.214
suggestion
88
48
48
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
CommanderTvis
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jvm/test/random/RandomSerializationTest.kt PR Title: Make random implementations serializable BEFORE CODE: /* * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the A...
@ilya-g this test already checks that Random.default instances are same when serialized.
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.random.asKotlinRandom import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertSame class RandomSerializationTest { @Test fun defaultIsSerializable() { val instance = Random assertSame(instance, serializeAndDeserialize(instance)) } private fun test...
@ilya-g of course, we can check more than first 4 bytes the deserialized random produces.
import kotlin.random.asKotlinRandom import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertSame import kotlin.test.assertTrue class RandomSerializationTest { @Test fun defaultIsSerializable() { val instance = Random discardSomeValues(instance) assertSame(instan...
@@ -0,0 +1,53 @@ +/* + * 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 random + +import test.io.deserializeFromHex +import test.io.serializeAndDeseria...
libraries/stdlib/jvm/test/random/RandomSerializationTest.kt
26
Kotlin
0.214
suggestion
89
43
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
CommanderTvis
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jvm/test/random/RandomSerializationTest.kt PR Title: Make random implementations serializable BEFORE CODE: import kotlin.random.asKotlinRandom import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertSame class RandomS...
@ilya-g of course, we can check more than first 4 bytes the deserialized random produces.
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 random import test.io.deserializeFromHex import test.io.serializeAndDeserialize import kotlin.random....
Please use `assertSame` here. Also the entire method `testPersistedDeserialization` can be inlined.
/* * 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 random import test.io.deserializeFromHex import test.io.serializeAndDeserialize import kotlin.random....
@@ -0,0 +1,61 @@ +/* + * 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 random + +import test.io.deserializeFromHex +import test.io.serializeAndDeseria...
libraries/stdlib/jvm/test/random/RandomSerializationTest.kt
26
Kotlin
0.429
suggestion
99
51
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jvm/test/random/RandomSerializationTest.kt PR Title: Make random implementations serializable BEFORE CODE: /* * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the A...
Please use `assertSame` here. Also the entire method `testPersistedDeserialization` can be inlined.
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.
} @Test fun deserializeDefault() = testPersistedDeserialization( "ac ed 00 05 73 72 00 1c 6b 6f 74 6c 69 6e 2e 72 61 6e 64 6f 6d 2e 52 61 6e 64 6f 6d 24 44 65 66 61 75 6c 74 59 81 49 e9 14 4e a8 28 02 00 00 78 70", Random ) @Test fun xorwowIsSerializable() { val instanc...
Makes sense to advance the internal state before serializing/deserializing. This way we'll ensure that the state is restored correctly.
private fun testRandomsHaveSameState(first: Random, second: Random) { assertEquals(first.nextInt(), second.nextInt()) assertEquals(first.nextDouble(), second.nextDouble()) assertEquals(first.nextLong(), second.nextLong()) assertTrue(first.nextBytes(64).contentEquals(second.nextBytes(...
@@ -0,0 +1,61 @@ +/* + * 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 random + +import test.io.deserializeFromHex +import test.io.serializeAndDeseria...
libraries/stdlib/jvm/test/random/RandomSerializationTest.kt
26
Kotlin
0.357
suggestion
135
30
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jvm/test/random/RandomSerializationTest.kt PR Title: Make random implementations serializable BEFORE CODE: } @Test fun deserializeDefault() = testPersistedDeserialization( "ac ed 00 05 73 72 00 1c 6b 6f 74 6c 69 6e 2e 72 6...
Makes sense to advance the internal state before serializing/deserializing. This way we'll ensure that the state is restored correctly.
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 readResolve(): Any = Default override fun nextBits(bitCount: Int): Int = defaultRandom.nextBits(bitCount) override fun nextInt(): Int = defaultRandom.nextInt() override fun nextInt(until: Int): Int = defaultRandom.nextInt(until) override fun nextInt(from: Int, until:...
This change is not related. Better to keep it consistent with the other function definitions.
} private fun writeReplace(): Any = Dummy override fun nextBits(bitCount: Int): Int = defaultRandom.nextBits(bitCount) override fun nextInt(): Int = defaultRandom.nextInt() override fun nextInt(until: Int): Int = defaultRandom.nextInt(until) override fun nextInt(from: I...
@@ -290,7 +295,11 @@ public abstract class Random { override fun nextBytes(array: ByteArray): ByteArray = defaultRandom.nextBytes(array) override fun nextBytes(size: Int): ByteArray = defaultRandom.nextBytes(size) - override fun nextBytes(array: ByteArray, fromIndex: Int, toIndex: Int): ByteA...
libraries/stdlib/src/kotlin/random/Random.kt
26
Kotlin
0.286
suggestion
93
51
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/src/kotlin/random/Random.kt PR Title: Make random implementations serializable BEFORE CODE: private fun readResolve(): Any = Default override fun nextBits(bitCount: Int): Int = defaultRandom.nextBits(bitCount) override...
This change is not related. Better to keep it consistent with the other function definitions.
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 [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(array: ByteArray): ByteArray = nextBytes(array, 0, array.size) /** * Creates a byte array of the specified [size], filled with random bytes. * * @sampl...
Ok, I think the variant with all transient fields and `readResolve` will do (without introducing a serialization surrogate). :+1:
* @return [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(array: ByteArray): ByteArray = nextBytes(array, 0, array.size) /** * Creates a byte array of the specified [size], filled with random bytes. * * @sample sampl...
@@ -267,10 +268,14 @@ public abstract class Random { * * @sample samples.random.Randoms.defaultRandom */ - companion object Default : Random() { + companion object Default : Random(), Serializable { + private const val serialVersionUID = 0L + @Transient
libraries/stdlib/src/kotlin/random/Random.kt
26
Kotlin
0.5
suggestion
129
51
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/src/kotlin/random/Random.kt PR Title: Make random implementations serializable BEFORE CODE: * * @return [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(ar...
Ok, I think the variant with all transient fields and `readResolve` will do (without introducing a serialization surrogate). :+1:
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.
/** * Fills the specified byte [array] with random bytes and returns it. * * @return [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(array: ByteArray): ByteArray = nextBytes(array, 0, array.size) /** * Creates a ...
Bad news: this const doesn't work as we intended it to. The reason is that it is compiled as a static field to the `Random` class, and not to the `Random.Default`. So changing its value doesn't fail the test with persistent deserialization, and on the opposite, adding a public method to `Random.Default` fails the test...
* Fills the specified byte [array] with random bytes and returns it. * * @return [array] filled with random bytes. * * @sample samples.random.Randoms.nextBytes */ public open fun nextBytes(array: ByteArray): ByteArray = nextBytes(array, 0, array.size) /** * Creates a byte arr...
@@ -267,10 +268,14 @@ public abstract class Random { * * @sample samples.random.Randoms.defaultRandom */ - companion object Default : Random() { + companion object Default : Random(), Serializable { + private const val serialVersionUID = 0L
libraries/stdlib/src/kotlin/random/Random.kt
26
Kotlin
0.643
bug
483
51
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/src/kotlin/random/Random.kt PR Title: Make random implementations serializable BEFORE CODE: /** * Fills the specified byte [array] with random bytes and returns it. * * @return [array] filled with random bytes. * *...
Bad news: this const doesn't work as we intended it to. The reason is that it is compiled as a static field to the `Random` class, and not to the `Random.Default`. So changing its value doesn't fail the test with persistent deserialization, and on the opposite, adding a public method to `Random.Default` fails the test...
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.
class RandomSerializationTest { @Test fun defaultIsSerializable() { val instance = Random discardSomeValues(instance) assertSame(instance, serializeAndDeserialize(instance)) } private fun discardSomeValues(instance: Random) { instance.nextInt() instance.nextDoubl...
Please also add a similar test for XorwowRandom.
class RandomSerializationTest { @Test fun defaultIsSerializable() { val instance = Random discardSomeValues(instance) assertSame(instance, serializeAndDeserialize(instance)) } private fun discardSomeValues(instance: Random) { instance.nextInt() instance.nextDoubl...
@@ -0,0 +1,72 @@ +/* + * 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 random + +import test.io.deserializeFromHex +import test.io.serializeAndDeseria...
libraries/stdlib/jvm/test/random/RandomSerializationTest.kt
26
Kotlin
0.071
suggestion
48
51
51
false
Make random implementations serializable
3,912
JetBrains/kotlin
51,705
Kotlin
ilya-g
CommanderTvis
Review this pull request change. Language: Kotlin File: libraries/stdlib/jvm/test/random/RandomSerializationTest.kt PR Title: Make random implementations serializable BEFORE CODE: class RandomSerializationTest { @Test fun defaultIsSerializable() { val instance = Random discardSomeValues(inst...
Please also add a similar test for XorwowRandom.
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.
interface A { fun foo(): String = "OK" } abstract class B : A { abstract override fun foo(): String } abstract class C : B() fun box() = "OK"
Let's change the test case a little bit to use the classes from the hierarchy. (If the classes aren't loaded at runtime, they are not verified by the JVM and thus may contain invalid bytecode, which the test wouldn't catch) ``` interface A { fun foo(): String = "Fail" } abstract class B : A { abstract o...
interface A { fun foo(): String = "Fail" } abstract class B : A { abstract override fun foo(): String } abstract class C : B() class D : C() { override fun foo(): String = "OK" } fun box() = D().foo()
@@ -0,0 +1,11 @@ +interface A { + fun foo(): String = "OK" +} + +abstract class B : A { + abstract override fun foo(): String +} + +abstract class C : B() + +fun box() = "OK"
compiler/testData/codegen/box/traits/abstractClassWithFakeOverride.kt
11
Kotlin
0.857
bug
465
11
15
false
Use separate logic for filtering and skipping in collectAndFilterRealOverrides [KT-43487]
3,921
JetBrains/kotlin
51,705
Kotlin
udalov
LepilkinaElena
Review this pull request change. Language: Kotlin File: compiler/testData/codegen/box/traits/abstractClassWithFakeOverride.kt PR Title: Use separate logic for filtering and skipping in collectAndFilterRealOverrides [KT-43487] BEFORE CODE: interface A { fun foo(): String = "OK" } abstract class B : A { abst...
Let's change the test case a little bit to use the classes from the hierarchy. (If the classes aren't loaded at runtime, they are not verified by the JVM and thus may contain invalid bytecode, which the test wouldn't catch) ``` interface A { fun foo(): String = "Fail" } abstract class B : A { abstract 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.
protected fun IrTypeParametersContainer.copyTypeParametersFrom(other: IrTypeParametersContainer) { this.typeParameters = other.typeParameters.map { copyTypeParameter(it) } typeRemapper.withinScope(this) { for ((thisTypeParameter, otherTypeParameter) in this.typeParam...
This was the bug. declaration.isAssignable was passed in the isHidden position.
protected fun IrTypeParametersContainer.copyTypeParametersFrom(other: IrTypeParametersContainer) { this.typeParameters = other.typeParameters.map { copyTypeParameter(it) } typeRemapper.withinScope(this) { for ((thisTypeParameter, otherTypeParameter) in this.typeParam...
@@ -351,6 +351,7 @@ open class DeepCopyIrTreeWithSymbols( declaration.varargElementType?.remapType(), declaration.isCrossinline, declaration.isNoinline, + declaration.isHidden,
compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt
26
Kotlin
0.357
bug
79
51
51
false
[IR] Make isHidden and isAssignable explicit on IrValueParameter.
3,939
JetBrains/kotlin
51,705
Kotlin
madsager
madsager
Review this pull request change. Language: Kotlin File: compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt PR Title: [IR] Make isHidden and isAssignable explicit on IrValueParameter. BEFORE CODE: protected fun IrTypeParametersContainer.copyTypeParametersFrom(other: IrTypeParameter...
This was the bug. declaration.isAssignable was passed in the isHidden position.
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 typeContext: TypeSystemCommonBackendContextForTypeMapping = IrTypeCheckerContextForTypeMapping(typeSystem, context) override fun mapClass(classifier: ClassifierDescriptor): Type = when (classifier) { is ClassDescriptor -> mapClass(context.referenceClass(classifi...
I suppose the problem started happening after f2b0d057b9ec17686deb5d25990624b378ef3e3a where I've tried to optimize this code to minimize string concatenations and map lookups for deeply nested classes. Is there any way we could keep the optimization and also fix the class names, maybe by storing the class names in the...
override val typeContext: TypeSystemCommonBackendContextForTypeMapping = IrTypeCheckerContextForTypeMapping(typeSystem, context) override fun mapClass(classifier: ClassifierDescriptor): Type = when (classifier) { is ClassDescriptor -> mapClass(context.referenceClass(classifi...
@@ -65,10 +65,10 @@ class IrTypeMapper(private val context: JvmBackendContext) : KotlinTypeMapperBas append(shortName) } is IrClass -> - return computeClassInternalName(parent).append("$").append(shortName) + return StringBuilder(classInte...
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt
26
Kotlin
0.786
performance
479
51
51
false
[JVM] Do not put the name of default lambda parameter in LVT.
3,946
JetBrains/kotlin
51,705
Kotlin
udalov
madsager
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt PR Title: [JVM] Do not put the name of default lambda parameter in LVT. BEFORE CODE: override val typeContext: TypeSystemCommonBackendContextForTypeMapping = IrTypeChecker...
I suppose the problem started happening after f2b0d057b9ec17686deb5d25990624b378ef3e3a where I've tried to optimize this code to minimize string concatenations and map lookups for deeply nested classes. Is there any way we could keep the optimization and also fix the class names, maybe by storing the class names in the...
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 createToOverride = suspendLambda.symbol.functions.singleOrNull { it.owner.valueParameters.size == arity + 1 && it.owner.name.asString() == "create" } val invokeSuspend = addInvokeSuspendForLambda(function, suspendLambda, parametersFields) ...
Maybe refactor this variable creation to `buildVariable`?
} val createToOverride = suspendLambda.symbol.functions.singleOrNull { it.owner.valueParameters.size == arity + 1 && it.owner.name.asString() == "create" } val invokeSuspend = addInvokeSuspendForLambda(function, suspendLambda, parametersFields) ...
@@ -209,19 +208,43 @@ private class SuspendLambdaLowering(context: JvmBackendContext) : SuspendLowerin it.valueParameters[0].type.isKotlinResult() } return addFunctionOverride(superMethod, irFunction.startOffset, irFunction.endOffset).apply { - body = irFunction.moveBod...
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SuspendLambdaLowering.kt
26
Kotlin
0.429
refactor
57
51
51
false
[IR] Align debugging of suspend lambdas with old BE
3,951
JetBrains/kotlin
51,705
Kotlin
udalov
kandersen
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SuspendLambdaLowering.kt PR Title: [IR] Align debugging of suspend lambdas with old BE BEFORE CODE: } val createToOverride = suspendLambda.symbol.functions.singleOrNull ...
Maybe refactor this variable creation to `buildVariable`?
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.
if (noStdlib) args.add("-no-stdlib") if (noReflect) args.add("-no-reflect") if (includeRuntime) args.add("-include-runtime") } override fun execute() { if (!fork) super.execute() else { val compilerClass = KotlinAntTaskUtil.getOrCreateClassLoader(...
Did you mean `pathSeparator` here?
if (includeRuntime) args.add("-include-runtime") } override fun execute() { if (!fork) super.execute() else { exec() } } private fun exec() { val javaHome = System.getProperty("java.home") val javaBin = javaHome + separator + "bin...
@@ -73,4 +81,43 @@ class Kotlin2JvmTask : KotlinCompilerBaseTask() { if (noReflect) args.add("-no-reflect") if (includeRuntime) args.add("-include-runtime") } + + override fun execute() { + if (!fork) + super.execute() + else { + val compilerClass = KotlinAn...
ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt
26
Kotlin
0.214
question
34
45
47
false
Ant: Add support for fork-mode
3,958
JetBrains/kotlin
51,705
Kotlin
ilya-g
scaventz
Review this pull request change. Language: Kotlin File: ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt PR Title: Ant: Add support for fork-mode BEFORE CODE: if (noStdlib) args.add("-no-stdlib") if (noReflect) args.add("-no-reflect") if (includeRuntime) args.add("-include-runtime") } ...
Did you mean `pathSeparator` 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.
setClasspath(classpath) } override fun fillSpecificArguments() { args.add("-d") args.add(output!!.canonicalPath) compileClasspath?.let { args.add("-classpath") args.add(it.list().joinToString(pathSeparator)) } if (moduleName == null) { ...
It seems that overriding `execute` resulted in the fork mode not having all the logic that was there, such as: * filling different compiler arguments (`-nowarn`, `-verbose`, `-include-runtime`, `-module-name`, etc.) * running the compiler with `execFullPathsInMessages` as opposed to the default mode when paths in com...
override fun fillSpecificArguments() { args.add("-d") args.add(output!!.canonicalPath) compileClasspath?.let { args.add("-classpath") args.add(it.list().joinToString(pathSeparator)) } if (moduleName == null) { moduleName = defaultModule...
@@ -73,4 +81,42 @@ class Kotlin2JvmTask : KotlinCompilerBaseTask() { if (noReflect) args.add("-no-reflect") if (includeRuntime) args.add("-include-runtime") } + + override fun execute() {
ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt
26
Kotlin
0.714
suggestion
430
51
51
false
Ant: Add support for fork-mode
3,958
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Kotlin File: ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt PR Title: Ant: Add support for fork-mode BEFORE CODE: setClasspath(classpath) } override fun fillSpecificArguments() { args.add("-d") args.add(output!!.canonicalPath) ...
It seems that overriding `execute` resulted in the fork mode not having all the logic that was there, such as: * filling different compiler arguments (`-nowarn`, `-verbose`, `-include-runtime`, `-module-name`, etc.) * running the compiler with `execFullPathsInMessages` as opposed to the default mode when paths in com...
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.
moduleName = defaultModuleName } moduleName?.let { args.add("-module-name") args.add(moduleName!!) } if (noStdlib) args.add("-no-stdlib") if (noReflect) args.add("-no-reflect") if (includeRuntime) args.add("-include-runtime") } ...
Please fix the warning here and on `exitCode` below ("Variable is never modified and can be declared immutable using 'val'")
moduleName = defaultModuleName } moduleName?.let { args.add("-module-name") args.add(moduleName!!) } if (noStdlib) args.add("-no-stdlib") if (noReflect) args.add("-no-reflect") if (includeRuntime) args.add("-include-runtime") } ...
@@ -73,4 +79,48 @@ class Kotlin2JvmTask : KotlinCompilerBaseTask() { if (noReflect) args.add("-no-reflect") if (includeRuntime) args.add("-include-runtime") } + + override fun execute() { + if (!fork) + super.execute() + else { + exec() + } + } + +...
ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt
26
Kotlin
0.5
suggestion
124
51
51
false
Ant: Add support for fork-mode
3,958
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Kotlin File: ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt PR Title: Ant: Add support for fork-mode BEFORE CODE: moduleName = defaultModuleName } moduleName?.let { args.add("-module-name") args.add(moduleName!!) ...
Please fix the warning here and on `exitCode` below ("Variable is never modified and can be declared immutable using 'val'")
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.
if (noStdlib) args.add("-no-stdlib") if (noReflect) args.add("-no-reflect") if (includeRuntime) args.add("-include-runtime") } override fun execute() { if (!fork) super.execute() else { exec() } } private fun exec() { val ...
Is `classpath` really necessary? If I understand correctly, it's the classpath of the currently-running Ant task, which is not needed for the compiler to work
if (noStdlib) args.add("-no-stdlib") if (noReflect) args.add("-no-reflect") if (includeRuntime) args.add("-include-runtime") } override fun execute() { if (!fork) super.execute() else { exec() } } private fun exec() { val ...
@@ -73,4 +79,48 @@ class Kotlin2JvmTask : KotlinCompilerBaseTask() { if (noReflect) args.add("-no-reflect") if (includeRuntime) args.add("-include-runtime") } + + override fun execute() { + if (!fork) + super.execute() + else { + exec() + } + } + +...
ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt
26
Kotlin
0.5
suggestion
158
50
49
false
Ant: Add support for fork-mode
3,958
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Kotlin File: ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt PR Title: Ant: Add support for fork-mode BEFORE CODE: if (noStdlib) args.add("-no-stdlib") if (noReflect) args.add("-no-reflect") if (includeRuntime) args.add("-include-runtime") } ...
Is `classpath` really necessary? If I understand correctly, it's the classpath of the currently-running Ant task, which is not needed for the compiler to work
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 = "Kotlin Ant Tools" plugins { kotlin("jvm") } dependencies { compile(commonDep("org.apache.ant", "ant")) compile(project(":kotlin-preloader")) compile(kotlinStdlib()) compileOnly(project(":compiler:cli")) } sourceSets { "main" { projectDefault() } "test" {} } runtimeJar { ...
The modifications of this file is used to support of setting property: ```org.jetbrains.kotlin.cliMessageRenderer=FullPath```. This property is used in ```CLITool.kt```, line 189, to get the instance ```MessageRenderer.PLAIN_FULL_PATHS```, which is the same MessageRenderer as non-forking mode.
description = "Kotlin Ant Tools" plugins { kotlin("jvm") } dependencies { compile(commonDep("org.apache.ant", "ant")) compile(project(":kotlin-preloader")) compile(kotlinStdlib()) } sourceSets { "main" { projectDefault() } "test" {} } runtimeJar { manifest.attributes["Class-Path"] = "$c...
@@ -17,5 +18,5 @@ sourceSets { } runtimeJar { - manifest.attributes["Class-Path"] = "$compilerManifestClassPath kotlin-preloader.jar" + manifest.attributes["Class-Path"] = "$compilerManifestClassPath kotlin-preloader.jar kotlin-compiler.jar"
ant/build.gradle.kts
21
Kotlin
0.857
suggestion
294
23
22
false
Ant: Add support for fork-mode
3,958
JetBrains/kotlin
51,705
Kotlin
scaventz
scaventz
Review this pull request change. Language: Kotlin File: ant/build.gradle.kts PR Title: Ant: Add support for fork-mode BEFORE CODE: description = "Kotlin Ant Tools" plugins { kotlin("jvm") } dependencies { compile(commonDep("org.apache.ant", "ant")) compile(project(":kotlin-preloader")) compile(ko...
The modifications of this file is used to support of setting property: ```org.jetbrains.kotlin.cliMessageRenderer=FullPath```. This property is used in ```CLITool.kt```, line 189, to get the instance ```MessageRenderer.PLAIN_FULL_PATHS```, which is the same MessageRenderer as non-forking 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.
} """.trimIndent() ) testResolveAllConfigurations("sample-lib") } @Test fun testJvmWithJavaProjectCanBeResolvedInAllConfigurations() = with(Project("new-mpp-jvm-with-java-multi-module", GradleVersionRequired.FOR_MPP_SUPPORT)) { testResolveAllConfigura...
@h0tk3y I am not sure about your intention of this test, could you double check this change?
} """.trimIndent() ) testResolveAllConfigurations("sample-lib") } @Test fun testJvmWithJavaProjectCanBeResolvedInAllConfigurations() = with(Project("new-mpp-jvm-with-java-multi-module", GradleVersionRequired.FOR_MPP_SUPPORT)) { testResolveAllConfigura...
@@ -287,13 +283,13 @@ class VariantAwareDependenciesIT : BaseGradleIT() { // variants chosen over the runtime ones when resolving a configuration with no required Usage: with(Project("simpleProject")) { setupWorkingDir() - gradleBuildScript().appendText("\ndependencies { compil...
libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt
26
Kotlin
0.286
question
93
51
51
false
Avoid resolving deprecated configurations in tests
3,970
JetBrains/kotlin
51,705
Kotlin
bingranl
bingranl
Review this pull request change. Language: Kotlin File: libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt PR Title: Avoid resolving deprecated configurations in tests BEFORE CODE: } """.trimIndent() ) ...
@h0tk3y I am not sure about your intention of this test, could you double check this 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 fun visitCall(expression: IrCall): IrExpression { expression.transformChildrenVoid(this) val callee = expression.symbol.owner val property = callee.correspondingPropertySymbol?.owner ?: return expression // Some devirtualization required here ...
An interesting question is what should print this program? ```kotlin object C { init { println("C::<init>") } const val x = 42 } fun main() { println("1") println(C.x) println("2") val c = C println(c.x) println("3") } ```
override fun visitCall(expression: IrCall): IrExpression { expression.transformChildrenVoid(this) val callee = expression.symbol.owner val property = callee.correspondingPropertySymbol?.owner ?: return expression // Some devirtualization required here ...
@@ -46,13 +48,25 @@ class PropertyAccessorInlineLowering(private val context: CommonBackendContext) } if (property.isEffectivelyExternal()) return expression + val backingField = property.backingField ?: return expression + if (property.isConst) { val...
compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/optimizations/PropertyAccessorInlineLowering.kt
26
Kotlin
0.857
nitpick
286
51
51
false
[IR] Fix saving function calls during inlining const properties in PropertyAccessorInlineLowering
3,971
JetBrains/kotlin
51,705
Kotlin
bashor
LepilkinaElena
Review this pull request change. Language: Kotlin File: compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/optimizations/PropertyAccessorInlineLowering.kt PR Title: [IR] Fix saving function calls during inlining const properties in PropertyAccessorInlineLowering BEFORE CODE: override f...
An interesting question is what should print this program? ```kotlin object C { init { println("C::<init>") } const val x = 42 } fun main() { println("1") println(C.x) println("2") val c = C println(c.x) println("3") } ```
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 visitCall(expression: IrCall): IrExpression { expression.transformChildrenVoid(this) val callee = expression.symbol.owner val property = callee.correspondingPropertySymbol?.owner ?: return expression // Some devirtualization required here ...
I think instead of `receiver is IrCall` I'd rather go with `!receiver.isPure()`
override fun visitCall(expression: IrCall): IrExpression { expression.transformChildrenVoid(this) val callee = expression.symbol.owner val property = callee.correspondingPropertySymbol?.owner ?: return expression // Some devirtualization required here ...
@@ -46,13 +48,25 @@ class PropertyAccessorInlineLowering(private val context: CommonBackendContext) } if (property.isEffectivelyExternal()) return expression + val backingField = property.backingField ?: return expression + if (property.isConst) { val...
compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/optimizations/PropertyAccessorInlineLowering.kt
26
Kotlin
0.429
suggestion
79
51
51
false
[IR] Fix saving function calls during inlining const properties in PropertyAccessorInlineLowering
3,971
JetBrains/kotlin
51,705
Kotlin
romanart
LepilkinaElena
Review this pull request change. Language: Kotlin File: compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/optimizations/PropertyAccessorInlineLowering.kt PR Title: [IR] Fix saving function calls during inlining const properties in PropertyAccessorInlineLowering BEFORE CODE: override f...
I think instead of `receiver is IrCall` I'd rather go with `!receiver.isPure()`
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.
proto: ProtoBuf.Property.Builder, versionRequirementTable: MutableVersionRequirementTable?, childSerializer: DescriptorSerializer ) { descriptorFileId(descriptor)?.let { proto.setExtension(KlibMetadataProtoBuf.propertyFile, it) } descriptor.findKDoc()?.let { proto.setExtensio...
IIUC, (secondary) constructors aren't supported (here and in other parts of the machinery).
descriptor: ConstructorDescriptor, proto: ProtoBuf.Constructor.Builder, childSerializer: DescriptorSerializer ) { if (exportKDoc) descriptor.findKDocString()?.let { proto.setExtension(KlibMetadataProtoBuf.constructorKdoc, it) } super.serializeConstructor(descriptor, proto, ch...
@@ -68,9 +76,28 @@ class KlibMetadataSerializerExtension( childSerializer: DescriptorSerializer ) { descriptorFileId(descriptor)?.let { proto.setExtension(KlibMetadataProtoBuf.functionFile, it) } + descriptor.findKDoc()?.let { proto.setExtension(KlibMetadataProtoBuf.functionKdoc, it.render...
compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/metadata/KlibMetadataSerializerExtension.kt
26
Kotlin
0.214
suggestion
91
42
47
false
Rra/ivanov/kdoc2klib
3,978
JetBrains/kotlin
51,705
Kotlin
SvyatoslavScherbina
knebekaizer
Review this pull request change. Language: Kotlin File: compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/metadata/KlibMetadataSerializerExtension.kt PR Title: Rra/ivanov/kdoc2klib BEFORE CODE: proto: ProtoBuf.Property.Builder, versionRequirementTable: MutableVer...
IIUC, (secondary) constructors aren't supported (here and in other parts of the machinery).
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 addConfiguredClasspath(classpath: Path) { setClasspath(classpath) } override fun fillSpecificArguments() { args.add("-d") args.add(output!!.canonicalPath) compileClasspath?.let { args.add("-classpath") args.add(it.list().joinToString(pathSeparato...
Could you explain this change? I think that in the case of an incorrect config, such as `includeRuntime` enabled + directory output, it's better to still pass everything to the compiler as specified by the user, in order for the compiler to handle it in an expected way, such as for example report a warning, than to ...
if (compileClasspath == null) { compileClasspath = Path(getProject()) } compileClasspath!!.createPath().refid = ref } fun addConfiguredClasspath(classpath: Path) { setClasspath(classpath) } override fun fillSpecificArguments() { args.add("-d") ...
@@ -71,6 +71,6 @@ class Kotlin2JvmTask : KotlinCompilerBaseTask() { if (noStdlib) args.add("-no-stdlib") if (noReflect) args.add("-no-reflect") - if (includeRuntime) args.add("-include-runtime") + if (includeRuntime && output?.extension == "jar") args.add("-include-runtime")
ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt
26
Kotlin
0.786
bug
544
29
51
false
Ant task: do not include runtime by default if destination is a jar
3,990
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Kotlin File: ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt PR Title: Ant task: do not include runtime by default if destination is a jar BEFORE CODE: fun addConfiguredClasspath(classpath: Path) { setClasspath(classpath) } override fun fillSpecific...
Could you explain this change? I think that in the case of an incorrect config, such as `includeRuntime` enabled + directory output, it's better to still pass everything to the compiler as specified by the user, in order for the compiler to handle it in an expected way, such as for example report a warning, than to ...
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.util.module import org.jetbrains.kotlin.ir.util.patchDeclarationParents import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.compo...
```suggestion private val lazySafeModeClassDescriptor = irClass.module.findClassAcrossModuleDependencies( ```
import org.jetbrains.kotlin.ir.util.module import org.jetbrains.kotlin.ir.util.patchDeclarationParents import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.compo...
@@ -34,6 +36,25 @@ class SerializableCompanionIrGenerator( bindingContext: BindingContext ) : SerializableCompanionCodegen(irClass.descriptor, bindingContext), IrBuilderExtension { + private val lazyDescriptor = irClass.module.findClassAcrossModuleDependencies( + ClassId(FqName("kotlin"), Name.identif...
plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableCompanionIrGenerator.kt
26
Kotlin
0.714
suggestion
115
51
51
false
Lazy delegate for serializer in objects, sealed and abstract classes
3,996
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/SerializableCompanionIrGenerator.kt PR Title: Lazy delegate for serializer in objects, sealed and abstract classes BEFORE CODE: import org.je...
```suggestion private val lazySafeModeClassDescriptor = irClass.module.findClassAcrossModuleDependencies( ```
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.
throw new CompileEnvironmentException("Invalid jar path " + jarPath, e); } catch (IOException e) { throw ExceptionUtilsKt.rethrow(e); } finally { ExceptionUtilsKt.closeQuietly(outputStream); } } private static void writeRuntimeToJar(Ja...
Let's just check that the simple name of the file is `module-info.class` via something like this: ``` StringsKt.substringAfterLast(e.getName(), '/', e.getName()).equals("module-info.class") ``` Also, we need a test to ensure that this won't break once we obsolete the JDK 8 support some time in the distant future, a...
catch (FileNotFoundException e) { throw new CompileEnvironmentException("Invalid jar path " + jarPath, e); } catch (IOException e) { throw ExceptionUtilsKt.rethrow(e); } finally { ExceptionUtilsKt.closeQuietly(outputStream); } } ...
@@ -131,6 +131,9 @@ private static void copyJarImpl(JarOutputStream stream, File jarPath, boolean re if (e == null) { break; } + if ("META-INF/versions/9/module-info.class".equals(e.getName())) {
compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CompileEnvironmentUtil.java
26
Java
0.857
suggestion
380
40
39
false
Kotlinc: Exclude module-info.class from resulting jar when "-include-…
3,998
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Java File: compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CompileEnvironmentUtil.java PR Title: Kotlinc: Exclude module-info.class from resulting jar when "-include-… BEFORE CODE: throw new CompileEnvironmentException("Invalid jar path " + jarPath, e); ...
Let's just check that the simple name of the file is `module-info.class` via something like this: ``` StringsKt.substringAfterLast(e.getName(), '/', e.getName()).equals("module-info.class") ``` Also, we need a test to ensure that this won't break once we obsolete the JDK 8 support some time in the distant future, 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.
assertNoModuleInfoClass(jar) } private fun assertAllTimestampsAreReset(jar: File) { val zis = JarInputStream(FileInputStream(jar)) var entry: ZipEntry? = zis.nextEntry while (entry != null) { assertEquals(entry.time, DOS_EPOCH, "$entry timestamp should be reset") ...
I think we can iterate over all entries a bit easier with `for (entry in JarFile(jar).entries())`. Consider maybe improving the code of the other test functions in this file similarly as well
/* * Copyright 2010-2020 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agre...
@@ -80,4 +96,16 @@ class DeterministicOutputTest : TestCaseWithTmpdir() { entry = zis.nextEntry } } + + private fun assertNoModuleInfoClass(jar: File) { + val zis = JarInputStream(FileInputStream(jar)) + var entry: ZipEntry? = zis.nextEntry + while (entry != null) {
compiler/tests/org/jetbrains/kotlin/cli/JarOutputTest.kt
26
Kotlin
0.571
suggestion
191
35
101
false
Kotlinc: Exclude module-info.class from resulting jar when "-include-…
3,998
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Kotlin File: compiler/tests/org/jetbrains/kotlin/cli/JarOutputTest.kt PR Title: Kotlinc: Exclude module-info.class from resulting jar when "-include-… BEFORE CODE: assertNoModuleInfoClass(jar) } private fun assertAllTimestampsAreReset(jar: File) { ...
I think we can iterate over all entries a bit easier with `for (entry in JarFile(jar).entries())`. Consider maybe improving the code of the other test functions in this file similarly 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.
Attributes mainAttributes = manifest.getMainAttributes(); mainAttributes.putValue("Manifest-Version", "1.0"); mainAttributes.putValue("Created-By", "JetBrains Kotlin"); if (mainClass != null) { mainAttributes.putValue("Main-Class", mainClass.asString()); ...
As I mentioned in [KT-17344](https://youtrack.jetbrains.com/issue/KT-17344), I think we shouldn't pack kotlin-reflect if `-no-reflect` is specified. Having kotlin-reflect in the classpath can change the program behavior quite visibly, for example `toString` on lambdas will behave differently. Could you take a look i...
Attributes mainAttributes = manifest.getMainAttributes(); mainAttributes.putValue("Manifest-Version", "1.0"); mainAttributes.putValue("Created-By", "JetBrains Kotlin"); if (mainClass != null) { mainAttributes.putValue("Main-Class", mainClass.asString()); ...
@@ -88,6 +89,7 @@ private static void doWriteToJar( } if (includeRuntime) { writeRuntimeToJar(stream, resetJarTimestamps); + writeReflectToJar(stream, resetJarTimestamps);
compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CompileEnvironmentUtil.java
26
Java
0.643
suggestion
447
51
51
false
Kotlinc: Exclude module-info.class from resulting jar when "-include-…
3,998
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Java File: compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CompileEnvironmentUtil.java PR Title: Kotlinc: Exclude module-info.class from resulting jar when "-include-… BEFORE CODE: Attributes mainAttributes = manifest.getMainAttributes(); mai...
As I mentioned in [KT-17344](https://youtrack.jetbrains.com/issue/KT-17344), I think we shouldn't pack kotlin-reflect if `-no-reflect` is specified. Having kotlin-reflect in the classpath can change the program behavior quite visibly, for example `toString` on lambdas will behave differently. Could you take a look 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.
val irFileClass = createFileClass(irFile, fileClassMembers) classes.add(irFileClass) irFile.declarations.clear() irFile.declarations.addAll(classes) } private fun createFileClass(irFile: IrFile, fileClassMembers: List<IrDeclaration>): IrClass { val fileEntry = irFile.fi...
Please use `DescriptorVisibilities.isPrivate`
irFile.declarations.clear() irFile.declarations.addAll(classes) } private fun createFileClass(irFile: IrFile, fileClassMembers: List<IrDeclaration>): IrClass { val fileEntry = irFile.fileEntry val fileClassInfo = when (fileEntry) { is PsiSourceManager.PsiFileEntry -...
@@ -92,14 +93,22 @@ private class FileClassLowering(val context: JvmBackendContext) : FileLoweringPa else -> error("unknown kind of file entry: $fileEntry") } val isMultifilePart = fileClassInfo.withJvmMultifileClass + + val hasOnlyPrivateDeclarations = fileClassMembers + ...
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FileClassLowering.kt
26
Kotlin
0.286
suggestion
45
51
51
false
[JVM_IR] Make file classes with all private members package-private
4,000
JetBrains/kotlin
51,705
Kotlin
udalov
CommanderTvis
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FileClassLowering.kt PR Title: [JVM_IR] Make file classes with all private members package-private BEFORE CODE: val irFileClass = createFileClass(irFile, fileClassMembers) class...
Please use `DescriptorVisibilities.isPrivate`
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 private fun f() { } private val a = Unit private val b by lazy { Unit }
Please add explicit `// !LANGUAGE: -PackagePrivateFileClassesWithAllPrivateMembers` here for clarity. :)
// WITH_RUNTIME // IGNORE_BACKEND: JVM // !LANGUAGE: -PackagePrivateFileClassesWithAllPrivateMembers private fun f() { } private val a = Unit private val b by lazy { Unit } @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.InlineOnly public fun g() { }
@@ -0,0 +1,8 @@ +// WITH_RUNTIME +// IGNORE_BACKEND: JVM
compiler/testData/codegen/bytecodeListing/fileClassWithPrivateDeclarationsOnly_before.kt
2
Kotlin
0.5
suggestion
104
9
15
false
[JVM_IR] Make file classes with all private members package-private
4,000
JetBrains/kotlin
51,705
Kotlin
udalov
CommanderTvis
Review this pull request change. Language: Kotlin File: compiler/testData/codegen/bytecodeListing/fileClassWithPrivateDeclarationsOnly_before.kt PR Title: [JVM_IR] Make file classes with all private members package-private BEFORE CODE: // WITH_RUNTIME // IGNORE_BACKEND: JVM private fun f() { } private val a = Uni...
Please add explicit `// !LANGUAGE: -PackagePrivateFileClassesWithAllPrivateMembers` here for clarity. :)
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.
ProperIeee754Comparisons(KOTLIN_1_4, kind = BUG_FIX), FunctionalInterfaceConversion(KOTLIN_1_4, kind = UNSTABLE_FEATURE), GenerateJvmOverloadsAsFinal(KOTLIN_1_4), MangleClassMembersReturningInlineClasses(KOTLIN_1_4), ImproveReportingDiagnosticsOnProtectedMembersOfBaseClass(KOTLIN_1_4, kind = BUG_FIX...
Could you please add a comment mentioning that this is about KT-10884? Otherwise looks good :).
ProperIeee754Comparisons(KOTLIN_1_4, kind = BUG_FIX), FunctionalInterfaceConversion(KOTLIN_1_4, kind = UNSTABLE_FEATURE), GenerateJvmOverloadsAsFinal(KOTLIN_1_4), MangleClassMembersReturningInlineClasses(KOTLIN_1_4), ImproveReportingDiagnosticsOnProtectedMembersOfBaseClass(KOTLIN_1_4, kind = BUG_FIX...
@@ -144,6 +144,7 @@ enum class LanguageFeature( AllowSealedInheritorsInDifferentFilesOfSamePackage(KOTLIN_1_5), SealedInterfaces(KOTLIN_1_5), + PackagePrivateFileClassesWithAllPrivateMembers(KOTLIN_1_5, defaultState = State.DISABLED),
compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt
26
Kotlin
0.286
question
95
51
51
false
[JVM_IR] Make file classes with all private members package-private
4,000
JetBrains/kotlin
51,705
Kotlin
udalov
CommanderTvis
Review this pull request change. Language: Kotlin File: compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt PR Title: [JVM_IR] Make file classes with all private members package-private BEFORE CODE: ProperIeee754Comparisons(KOTLIN_1_4, kind = BUG_FIX), FunctionalInterfaceConversion(KOTL...
Could you please add a comment mentioning that this is about KT-10884? Otherwise looks good :).
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.
classes.add(irFileClass) irFile.declarations.clear() irFile.declarations.addAll(classes) } private fun createFileClass(irFile: IrFile, fileClassMembers: List<IrDeclaration>): IrClass { val fileEntry = irFile.fileEntry val fileClassInfo = when (fileEntry) { i...
It would be great to also rewrite this to that it wouldn't create extra collections
irFile.declarations.addAll(classes) } private fun createFileClass(irFile: IrFile, fileClassMembers: List<IrDeclaration>): IrClass { val fileEntry = irFile.fileEntry val fileClassInfo = when (fileEntry) { is PsiSourceManager.PsiFileEntry -> { val ktFile = cont...
@@ -79,27 +81,36 @@ private class FileClassLowering(val context: JvmBackendContext) : FileLoweringPa private fun createFileClass(irFile: IrFile, fileClassMembers: List<IrDeclaration>): IrClass { val fileEntry = irFile.fileEntry - val fileClassInfo: JvmFileClassInfo? - when (fileEntry) { + ...
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FileClassLowering.kt
26
Kotlin
0.214
suggestion
83
51
51
false
[JVM_IR] Make file classes with all private members package-private
4,000
JetBrains/kotlin
51,705
Kotlin
udalov
CommanderTvis
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FileClassLowering.kt PR Title: [JVM_IR] Make file classes with all private members package-private BEFORE CODE: classes.add(irFileClass) irFile.declarations.clear() irF...
It would be great to also rewrite this to that it wouldn't create extra collections
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.
//FILE: test.kt fun foo() { fun bar() { } } fun box() { foo() } // IGNORE_BACKEND: JVM_IR // LOCAL VARIABLES // test.kt:9 box: // test.kt:4 foo: // test.kt:6 foo: $fun$bar$1:TestKt$foo$1=TestKt$foo$1 // test.kt:10 box:
Change in file header looks strange
//FILE: test.kt fun foo() { val x = 1 fun bar() { val y = x } bar() } fun box() { foo() } // Local functions are compiled to private static functions on the class // containing the local funtion. This has a number of consequences observable // from a debugging perspective, for this test...
@@ -1,16 +1,54 @@ -//FILE: test.kt
compiler/testData/debug/localVariables/localFun.kt
1
Kotlin
0.143
suggestion
35
16
26
false
[IR+Tests] Improve Local Function Debugging Experience
4,002
JetBrains/kotlin
51,705
Kotlin
max-kammerer
kandersen
Review this pull request change. Language: Kotlin File: compiler/testData/debug/localVariables/localFun.kt PR Title: [IR+Tests] Improve Local Function Debugging Experience BEFORE CODE: //FILE: test.kt fun foo() { fun bar() { } } fun box() { foo() } // IGNORE_BACKEND: JVM_IR // LOCAL VARIABLES // test...
Change in file header looks strange
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 static void writeReflectToJar(JarOutputStream stream, boolean resetJarTimestamps) throws IOException { File reflectPath = PathUtil.getKotlinPathsForCompiler().getReflectPath(); if (!reflectPath.exists()) { throw new CompileEnvironmentException("Couldn't find kotlin-reflect...
Some changes around here, are used to avoid complicating the conditional statements.
copyJarImpl(stream, stdlibPath, resetJarTimestamps); } private static void writeReflectToJar(JarOutputStream stream, boolean resetJarTimestamps) throws IOException { File reflectPath = PathUtil.getKotlinPathsForCompiler().getReflectPath(); if (!reflectPath.exists()) { throw ...
@@ -125,21 +129,30 @@ private static void writeRuntimeToJar(JarOutputStream stream, boolean resetJarTi copyJarImpl(stream, stdlibPath, resetJarTimestamps); } + private static void writeReflectToJar(JarOutputStream stream, boolean resetJarTimestamps) throws IOException { + File reflectPath = Pa...
compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CompileEnvironmentUtil.java
26
Java
0.286
suggestion
86
31
32
false
kotlinc: Include kotlin-reflect to resulting jar when option -include-runtime is specified and option -no-reflect is not
4,033
JetBrains/kotlin
51,705
Kotlin
scaventz
scaventz
Review this pull request change. Language: Java File: compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CompileEnvironmentUtil.java PR Title: kotlinc: Include kotlin-reflect to resulting jar when option -include-runtime is specified and option -no-reflect is not BEFORE CODE: } private static void writ...
Some changes around here, are used to avoid complicating the conditional statements.
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 noReflect fun main() { String::class.annotations }
Please catch the exception here and print something like "OK" in the `catch` block, and "Fail" otherwise. Having a stacktrace in the expected output, like it is right now, is a bit inconvenient because the test data needs to be changed every time there's any slight refactoring to the affected files (`ClassReference....
package noReflect fun main() { try { String::class.annotations } catch (e: KotlinReflectionNotSupportedError) { println("KotlinReflectionNotSupportedError has been caught") } }
@@ -0,0 +1,5 @@ +package noReflect + +fun main() { + String::class.annotations
compiler/testData/integration/smoke/noReflect/noReflect.kt
4
Kotlin
0.786
bug
337
5
9
false
kotlinc: Include kotlin-reflect to resulting jar when option -include-runtime is specified and option -no-reflect is not
4,033
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Kotlin File: compiler/testData/integration/smoke/noReflect/noReflect.kt PR Title: kotlinc: Include kotlin-reflect to resulting jar when option -include-runtime is specified and option -no-reflect is not BEFORE CODE: package noReflect fun main() { String::class.annotat...
Please catch the exception here and print something like "OK" in the `catch` block, and "Fail" otherwise. Having a stacktrace in the expected output, like it is right now, is a bit inconvenient because the test data needs to be changed every time there's any slight refactoring to the affected files (`ClassReference....
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 static final CompilerConfigurationKey<Boolean> DO_NOT_CLEAR_BINDING_CONTEXT = CompilerConfigurationKey.create("When using the IR backend, do not clear BindingContext between psi2ir and lowerings"); public static final CompilerConfigurationKey<Boolean> NO_OPTIMIZED_CALLABLE_REFERENCES = ...
```suggestion CompilerConfigurationKey.create("Don't automatically include kotlin-reflect.jar into the output if the output is a jar"); ```
public static final CompilerConfigurationKey<JvmAbiStability> ABI_STABILITY = CompilerConfigurationKey.create("ABI stability of class files produced by JVM IR and/or FIR"); public static final CompilerConfigurationKey<Boolean> DO_NOT_CLEAR_BINDING_CONTEXT = CompilerConfigurationKey.crea...
@@ -143,4 +143,7 @@ private JVMConfigurationKeys() { public static final CompilerConfigurationKey<Boolean> ENABLE_JVM_PREVIEW = CompilerConfigurationKey.create("Enable Java language preview features"); + + public static final CompilerConfigurationKey<Boolean> NO_REFLECT = + CompilerCon...
compiler/config.jvm/src/org/jetbrains/kotlin/config/JVMConfigurationKeys.java
26
Java
0.714
suggestion
153
28
31
false
kotlinc: Include kotlin-reflect to resulting jar when option -include-runtime is specified and option -no-reflect is not
4,033
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Java File: compiler/config.jvm/src/org/jetbrains/kotlin/config/JVMConfigurationKeys.java PR Title: kotlinc: Include kotlin-reflect to resulting jar when option -include-runtime is specified and option -no-reflect is not BEFORE CODE: public static final CompilerConfigur...
```suggestion CompilerConfigurationKey.create("Don't automatically include kotlin-reflect.jar into the output if the output is a jar"); ```
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 static void writeRuntimeToJar(JarOutputStream stream, boolean resetJarTimestamps) throws IOException { File stdlibPath = PathUtil.getKotlinPathsForCompiler().getStdlibPath(); if (!stdlibPath.exists()) { throw new CompileEnvironmentException("Couldn't find kotlin-stdlib at ...
```suggestion !FileUtilRt.extensionEquals(e.getName(), BuiltInSerializerProtocol.BUILTINS_FILE_EXTENSION)) || ```
} } private static void writeRuntimeToJar(JarOutputStream stream, boolean resetJarTimestamps) throws IOException { File stdlibPath = PathUtil.getKotlinPathsForCompiler().getStdlibPath(); if (!stdlibPath.exists()) { throw new CompileEnvironmentException("Couldn't find kotlin-...
@@ -125,13 +129,22 @@ private static void writeRuntimeToJar(JarOutputStream stream, boolean resetJarTi copyJarImpl(stream, stdlibPath, resetJarTimestamps); } + private static void writeReflectToJar(JarOutputStream stream, boolean resetJarTimestamps) throws IOException { + File reflectPath = Pa...
compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CompileEnvironmentUtil.java
26
Java
0.714
suggestion
136
39
40
false
kotlinc: Include kotlin-reflect to resulting jar when option -include-runtime is specified and option -no-reflect is not
4,033
JetBrains/kotlin
51,705
Kotlin
udalov
scaventz
Review this pull request change. Language: Java File: compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CompileEnvironmentUtil.java PR Title: kotlinc: Include kotlin-reflect to resulting jar when option -include-runtime is specified and option -no-reflect is not BEFORE CODE: } private static void writ...
```suggestion !FileUtilRt.extensionEquals(e.getName(), BuiltInSerializerProtocol.BUILTINS_FILE_EXTENSION)) || ```
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 IrClass.addFunction( name: String, returnType: IrType, modality: Modality = Modality.FINAL, visibility: DescriptorVisibility = DescriptorVisibilities.PUBLIC, isStatic: Boolean = false, isSuspend: Boolean = false, isFakeOverride: Boolean = false, origi...
without this I got exception later in _remapTypeParameters_
inline fun IrClass.addFunction(builder: IrFunctionBuilder.() -> Unit): IrSimpleFunction = factory.addFunction(this, builder) fun IrClass.addFunction( name: String, returnType: IrType, modality: Modality = Modality.FINAL, visibility: DescriptorVisibility = DescriptorVisibilities.PUBLIC, isStati...
@@ -164,6 +165,7 @@ fun IrClass.addFunction( this.origin = origin }.apply { if (!isStatic) { + copyTypeParametersFrom(parentAsClass)
compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/builders/declarations/declarationBuilders.kt
26
Kotlin
0.357
suggestion
59
51
51
false
KT-42652 parcelize fix codegen for generic classes
4,047
JetBrains/kotlin
51,705
Kotlin
zveznicht
zveznicht
Review this pull request change. Language: Kotlin File: compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/builders/declarations/declarationBuilders.kt PR Title: KT-42652 parcelize fix codegen for generic classes BEFORE CODE: fun IrClass.addFunction( name: String, returnType: IrType, mo...
without this I got exception later in _remapTypeParameters_
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.
if (function.origin == IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER) { assert(newName.endsWith(JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX)) { "Default adapter should end with \$default: ${function.render()}" } return newName.substringBeforeLast(JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX) + "$" + su...
Maybe remove the commented code?
if (function.origin == IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER) { assert(newName.endsWith(JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX)) { "Default adapter should end with \$default: ${function.render()}" } return newName.substringBeforeLast(JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX) + "$" + su...
@@ -134,7 +134,20 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { origin != JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_OR_TYPEALIAS_ANNOTATIONS && !isPublishedApi() ) { + return originalFunction.takeIf { it != this } + ...
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt
26
Kotlin
0.143
question
32
51
51
false
JVM IR: Fix inline class mangling for calls to internal functions in a different module
4,059
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt PR Title: JVM IR: Fix inline class mangling for calls to internal functions in a different module BEFORE CODE: if (function.origin == IrDeclarationOrigin.FUN...
Maybe remove the commented code?
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.
Type.BOOLEAN_TYPE -> false Type.CHAR_TYPE -> '\u0000' Type.SHORT_TYPE -> 0 Type.INT_TYPE -> 0 Type.LONG_TYPE -> 0L Type.FLOAT_TYPE -> 0.0F Type.DOUBLE_TYPE -> 0.0 else -> null } private fun <T : JCTree> T.keepKdocComments(node: Any): T { k...
After this commit `convertKotlinType()` will be always used for properties with delegates. Using it only for anonymous-type delegates would be safer, I think.
Type.BOOLEAN_TYPE -> false Type.CHAR_TYPE -> '\u0000' Type.SHORT_TYPE -> 0 Type.INT_TYPE -> 0 Type.LONG_TYPE -> 0L Type.FLOAT_TYPE -> 0.0F Type.DOUBLE_TYPE -> 0.0 else -> null } private fun <T : JCTree> T.keepKdocComments(node: Any): T { k...
@@ -1420,6 +1423,20 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati lineMappings.registerSignature(this, node) return this } + + private fun fieldType(field: FieldNode, origin: JvmDeclarationOrigin?): Type { + val signType = Type.getType(field.desc) +...
plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt
26
Kotlin
0.714
style
159
49
51
false
KT-34838 replace anonymous classes with superclass in delegate properties
4,079
JetBrains/kotlin
51,705
Kotlin
yanex
zveznicht
Review this pull request change. Language: Kotlin File: plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt PR Title: KT-34838 replace anonymous classes with superclass in delegate properties BEFORE CODE: Type.BOOLEAN_TYPE -> false Type.CHAR_TYPE -> '...
After this commit `convertKotlinType()` will be always used for properties with delegates. Using it only for anonymous-type delegates would be safer, I think.
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 getDefaultValue(type: Type): Any? = when (type) { Type.BYTE_TYPE -> 0 Type.BOOLEAN_TYPE -> false Type.CHAR_TYPE -> '\u0000' Type.SHORT_TYPE -> 0 Type.INT_TYPE -> 0 Type.LONG_TYPE -> 0L Type.FLOAT_TYPE -> 0.0F Type.DOUBLE_TY...
Minor: we usually start function names with verbs, such as `get`.
} } private fun getDefaultValue(type: Type): Any? = when (type) { Type.BYTE_TYPE -> 0 Type.BOOLEAN_TYPE -> false Type.CHAR_TYPE -> '\u0000' Type.SHORT_TYPE -> 0 Type.INT_TYPE -> 0 Type.LONG_TYPE -> 0L Type.FLOAT_TYPE -> 0.0F Type.DOUBLE_TY...
@@ -1420,6 +1423,20 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati lineMappings.registerSignature(this, node) return this } + + private fun fieldType(field: FieldNode, origin: JvmDeclarationOrigin?): Type {
plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt
26
Kotlin
0.357
nitpick
65
51
51
false
KT-34838 replace anonymous classes with superclass in delegate properties
4,079
JetBrains/kotlin
51,705
Kotlin
yanex
zveznicht
Review this pull request change. Language: Kotlin File: plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt PR Title: KT-34838 replace anonymous classes with superclass in delegate properties BEFORE CODE: } } private fun getDefaultValue(type: Type): ...
Minor: we usually start function names with verbs, such as `get`.
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.configurations.create(KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME).apply { target.getKotlinPluginVersion()?.let { kotlinPluginVersion -> val kaptDependency = getPluginArtifact().run { "$groupId:$artifactId:$kotlinPluginVersion" } dependencies.add(target.depende...
VERBOSE_OPTION_NAME -> VERBOSE_OPTION?
target.configurations.create(KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME).apply { target.getKotlinPluginVersion()?.let { kotlinPluginVersion -> val kaptDependency = getPluginArtifact().run { "$groupId:$artifactId:$kotlinPluginVersion" } dependencies.add(target.depende...
@@ -74,12 +74,20 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To fun getKaptGeneratedKotlinSourcesDir(project: Project, sourceSetName: String) = File(project.buildDir, "generated/source/kaptKotlin/$sourceSetName") - private val VERBOSE_OPTION_NAME = "ka...
libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/Kapt3KotlinGradleSubplugin.kt
26
Kotlin
0.071
question
38
51
51
false
Kapt: Ensure flag names and default values are consistent
4,083
JetBrains/kotlin
51,705
Kotlin
zveznicht
hungvietnguyen
Review this pull request change. Language: Kotlin File: libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/Kapt3KotlinGradleSubplugin.kt PR Title: Kapt: Ensure flag names and default values are consistent BEFORE CODE: target.configurations.create(KAPT_WORKER_DEPEN...
VERBOSE_OPTION_NAME -> VERBOSE_OPTION?
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.getKotlinPluginVersion()?.let { kotlinPluginVersion -> val kaptDependency = getPluginArtifact().run { "$groupId:$artifactId:$kotlinPluginVersion" } dependencies.add(target.dependencies.create(kaptDependency)) } ?: throw GradleException("Kotlin plugin should...
[minor] instead of Pair maybe introduce explicit data class (eg KaptOption), so you won't have to use .first/second calls
target.getKotlinPluginVersion()?.let { kotlinPluginVersion -> val kaptDependency = getPluginArtifact().run { "$groupId:$artifactId:$kotlinPluginVersion" } dependencies.add(target.dependencies.create(kaptDependency)) } ?: throw GradleException("Kotlin plugin should...
@@ -74,12 +74,20 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To fun getKaptGeneratedKotlinSourcesDir(project: Project, sourceSetName: String) = File(project.buildDir, "generated/source/kaptKotlin/$sourceSetName") - private val VERBOSE_OPTION_NAME = "ka...
libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/Kapt3KotlinGradleSubplugin.kt
26
Kotlin
0.429
suggestion
123
51
51
false
Kapt: Ensure flag names and default values are consistent
4,083
JetBrains/kotlin
51,705
Kotlin
zveznicht
hungvietnguyen
Review this pull request change. Language: Kotlin File: libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/Kapt3KotlinGradleSubplugin.kt PR Title: Kapt: Ensure flag names and default values are consistent BEFORE CODE: target.getKotlinPluginVersion()?.let { kot...
[minor] instead of Pair maybe introduce explicit data class (eg KaptOption), so you won't have to use .first/second 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.
// Should not be available for consumption from other projects during variant-aware dependency resolution: isCanBeConsumed = false attributes.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, Usage.JAVA_RUNTIME)) } if (aptC...
at least warn in log would be nice
fun isEnabled(project: Project) = project.plugins.any { it is Kapt3GradleSubplugin } private fun Project.getBooleanOptionValue(booleanOption: BooleanOption): Boolean { return when (val value = findProperty(booleanOption.optionName)) { is Boolean -> value ...
@@ -149,6 +158,18 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To fun isEnabled(project: Project) = project.plugins.any { it is Kapt3GradleSubplugin } + + private fun Project.getBooleanProperty(name: String, defaultValue: Boolean): Boolean { + ...
libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/Kapt3KotlinGradleSubplugin.kt
26
Kotlin
0.071
suggestion
34
51
51
false
Kapt: Ensure flag names and default values are consistent
4,083
JetBrains/kotlin
51,705
Kotlin
zveznicht
hungvietnguyen
Review this pull request change. Language: Kotlin File: libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/Kapt3KotlinGradleSubplugin.kt PR Title: Kapt: Ensure flag names and default values are consistent BEFORE CODE: // Should not be available for consump...
at least warn in log would be nice
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.
@Suppress("UselessCallOnNotNull") // nullable toString(), KT-27724 private val JAVA_KEYWORDS = Tokens.TokenKind.values() .filter { JAVA_KEYWORD_FILTER_REGEX.matches(it.toString().orEmpty()) } .mapTo(hashSetOf(), Any::toString) } private val correctErrorTypes = kaptContex...
Can be replaced with a lazy value.
@Suppress("UselessCallOnNotNull") // nullable toString(), KT-27724 private val JAVA_KEYWORDS = Tokens.TokenKind.values() .filter { JAVA_KEYWORD_FILTER_REGEX.matches(it.toString().orEmpty()) } .mapTo(hashSetOf(), Any::toString) } private val correctErrorTypes = kaptContex...
@@ -130,6 +131,8 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati private val kdocCommentKeeper = KDocCommentKeeper(kaptContext) + private val importsFromRoot = collectImportsFromRootPackage()
plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt
26
Kotlin
0.143
suggestion
34
51
51
false
[KAPT] KT-36743 Warn about usage of types from default package
4,094
JetBrains/kotlin
51,705
Kotlin
yanex
zveznicht
Review this pull request change. Language: Kotlin File: plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt PR Title: [KAPT] KT-36743 Warn about usage of types from default package BEFORE CODE: @Suppress("UselessCallOnNotNull") // nullable toString(), KT-27724...
Can be replaced with a lazy 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.
return this } private fun getFieldType(field: FieldNode, origin: JvmDeclarationOrigin?): Type { val fieldType = Type.getType(field.desc) return when (val declaration = origin?.element) { is KtProperty -> { //replace anonymous type in delegate (if any) ...
I suppose aliased imports (`import X as Y`) are not supported here.
return this } private fun getFieldType(field: FieldNode, origin: JvmDeclarationOrigin?): Type { val fieldType = Type.getType(field.desc) return when (val declaration = origin?.element) { is KtProperty -> { //replace anonymous type in delegate (if any) ...
@@ -1441,6 +1471,28 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati private fun convertKotlinType(type: KotlinType): Type = typeMapper.mapType(type, null, TypeMappingMode.GENERIC_ARGUMENT) + private fun getFileForClass(c: ClassNode): KtFile? = kaptContext.origins[c]?.elem...
plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt
26
Kotlin
0.357
suggestion
67
51
51
false
[KAPT] KT-36743 Warn about usage of types from default package
4,094
JetBrains/kotlin
51,705
Kotlin
yanex
zveznicht
Review this pull request change. Language: Kotlin File: plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt PR Title: [KAPT] KT-36743 Warn about usage of types from default package BEFORE CODE: return this } private fun getFieldType(field: FieldNode, ...
I suppose aliased imports (`import X as Y`) are not supported 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.
}?.let(::convertKotlinType) ?: fieldType } else -> fieldType } } private fun convertKotlinType(type: KotlinType): Type = typeMapper.mapType(type, null, TypeMappingMode.GENERIC_ARGUMENT) private fun getFileForClass(c: ClassNode): KtFile? = kaptContext.origins...
I suppose we should handle only `!isAllUnder` imports here.
}?.let(::convertKotlinType) ?: fieldType } else -> fieldType } } private fun convertKotlinType(type: KotlinType): Type = typeMapper.mapType(type, null, TypeMappingMode.GENERIC_ARGUMENT) private fun getFileForClass(c: ClassNode): KtFile? = kaptContext.origins...
@@ -1441,6 +1471,28 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati private fun convertKotlinType(type: KotlinType): Type = typeMapper.mapType(type, null, TypeMappingMode.GENERIC_ARGUMENT) + private fun getFileForClass(c: ClassNode): KtFile? = kaptContext.origins[c]?.elem...
plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt
26
Kotlin
0.571
suggestion
59
46
48
false
[KAPT] KT-36743 Warn about usage of types from default package
4,094
JetBrains/kotlin
51,705
Kotlin
yanex
zveznicht
Review this pull request change. Language: Kotlin File: plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt PR Title: [KAPT] KT-36743 Warn about usage of types from default package BEFORE CODE: }?.let(::convertKotlinType) ?: fieldType } ...
I suppose we should handle only `!isAllUnder` imports 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.
// CORRECT_ERROR_TYPES // STRICT //FILE: test/ClassRefAnnotation.java package test; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.annotation.ElementType; @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionP...
I would also add tests with the `correctErrorTypes` option being enabled.
// STRICT //FILE: test/ClassRefAnnotation.java package test; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.annotation.ElementType; @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) public @...
@@ -0,0 +1,40 @@ +// CORRECT_ERROR_TYPES +// STRICT + +//FILE: test/ClassRefAnnotation.java + +package test; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target({ ElementType.TYPE, ElementType.M...
plugins/kapt3/kapt3-compiler/testData/converter/defaultPackage.kt
18
Kotlin
0.5
suggestion
73
41
43
false
[KAPT] KT-36743 Warn about usage of types from default package
4,094
JetBrains/kotlin
51,705
Kotlin
yanex
zveznicht
Review this pull request change. Language: Kotlin File: plugins/kapt3/kapt3-compiler/testData/converter/defaultPackage.kt PR Title: [KAPT] KT-36743 Warn about usage of types from default package BEFORE CODE: // CORRECT_ERROR_TYPES // STRICT //FILE: test/ClassRefAnnotation.java package test; import java.lang.anno...
I would also add tests with the `correctErrorTypes` option being enabled.
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( "\$enum\$name", context.irBuiltIns.stringType, JvmLoweredDeclarationOrigin.ENUM_CONSTRUCTOR_SYNTHETIC_PARAMETER ) addValueParameter( "\$enum\$ordinal", context.irBuiltIns.intType, JvmLoweredDec...
Let's use `single` instead of `first`, just in case. :)
addValueParameter( "\$enum\$name", context.irBuiltIns.stringType, JvmLoweredDeclarationOrigin.ENUM_CONSTRUCTOR_SYNTHETIC_PARAMETER ) addValueParameter( "\$enum\$ordinal", context.irBuiltIns.intType, JvmLoweredDec...
@@ -156,8 +153,14 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP declaration.body = context.createJvmIrBuilder(declaration.symbol).run { irExprBody( when (body.kind) { - IrSyntheticBodyKind.ENU...
compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt
26
Kotlin
0.429
suggestion
55
51
51
false
JVM IR: Minor changes to Enum codegen to align with the JVM backend
4,096
JetBrains/kotlin
51,705
Kotlin
udalov
sfs
Review this pull request change. Language: Kotlin File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt PR Title: JVM IR: Minor changes to Enum codegen to align with the JVM backend BEFORE CODE: addValueParameter( "\$enum\$name", co...
Let's use `single` instead of `first`, just in case. :)
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.idea.fir.api.fixes.KtQuickFixRegistrar import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesList import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesListBuilder import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic import org.jetbrains.kotlin.idea.quickfi...
Maybe not necessary at the moment, but I guess we eventually need, say, `ValOrVarNodeFix` (and `createChangeVariableMutability` or something like that) so that, e.g., var-to-val suggestion can be created via the same factory. Btw, I'm referring to the positioning strategy we use in the checkers: https://github.com/J...
import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixRegistrar import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesList import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesListBuilder import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic import org.jetbrains.kotlin.idea.quickfi...
@@ -27,6 +29,9 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { isRedundant = true ) ) + + // ChangeVariableMutabilityFix + registerPsiQuickFix<PsiElement, KtFirDiagnostic.VarOverriddenByVal>(VAR_OVERRIDDEN_BY_VAL_FACTORY)
idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt
26
Kotlin
0.643
suggestion
485
39
39
false
FIR IDE: Add quickfix for VAR_OVERRIDDEN_BY_VAL
4,103
JetBrains/kotlin
51,705
Kotlin
jsjeon
punzki
Review this pull request change. Language: Kotlin File: idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt PR Title: FIR IDE: Add quickfix for VAR_OVERRIDDEN_BY_VAL BEFORE CODE: import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixRegistrar import org.jetbrains.kotlin.idea.fir.api.f...
Maybe not necessary at the moment, but I guess we eventually need, say, `ValOrVarNodeFix` (and `createChangeVariableMutability` or something like that) so that, e.g., var-to-val suggestion can be created via the same factory. Btw, I'm referring to the positioning strategy we use in the checkers: https://github.com/J...
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.idea.quickfix import com.intellij.psi.PsiElement import org.jetbrains.kotlin.ide...
If you need a visual separation of quickfixes blocks, it is better to create a new `KtQuickFixesList` like it's done now for `modifiers` and `overrides`. `KtQuickFixesList.createCombined` was created exactly for that reason :)
/* * 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.idea.quickfix import com.intellij.psi.PsiElement import org.jetbrains.kotlin.ide...
@@ -10,12 +10,14 @@ import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixRegistrar import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesList import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesListBuilder import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic +import org.jetbr...
idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt
20
Kotlin
0.643
suggestion
226
45
45
false
FIR IDE: Add quickfix for VAR_OVERRIDDEN_BY_VAL
4,103
JetBrains/kotlin
51,705
Kotlin
darthorimar
punzki
Review this pull request change. Language: Kotlin File: idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt PR Title: FIR IDE: Add quickfix for VAR_OVERRIDDEN_BY_VAL BEFORE CODE: /* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this sourc...
If you need a visual separation of quickfixes blocks, it is better to create a new `KtQuickFixesList` like it's done now for `modifiers` and `overrides`. `KtQuickFixesList.createCombined` was created exactly for that 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.
} companion object { val VAL_WITH_SETTER_FACTORY: KotlinSingleIntentionActionFactory = object : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): IntentionAction? { val accessor = diagnostic.psiElement as KtPropertyAccessor ...
Please move the whole file into `idea-front-end-independent` module as it is used now by `idea-fir`. We a trying to keep dependencies to FE1.0 plugin classes to the minimum. Unfortunately, we can not remove the dependencies to the FE1.0 plugin modules right now, but I hope we can do it soon
/* * Copyright 2010-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agre...
@@ -86,15 +88,13 @@ class ChangeVariableMutabilityFix( val CAPTURED_MEMBER_VAL_INITIALIZATION_FACTORY = ReassignmentActionFactory(Errors.CAPTURED_MEMBER_VAL_INITIALIZATION) - val VAR_OVERRIDDEN_BY_VAL_FACTORY: KotlinSingleIntentionActionFactory = object : KotlinSingleIntentionActionFactory() { - ...
idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt
26
Kotlin
0.643
suggestion
292
51
60
false
FIR IDE: Add quickfix for VAR_OVERRIDDEN_BY_VAL
4,103
JetBrains/kotlin
51,705
Kotlin
darthorimar
punzki
Review this pull request change. Language: Kotlin File: idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt PR Title: FIR IDE: Add quickfix for VAR_OVERRIDDEN_BY_VAL BEFORE CODE: } companion object { val VAL_WITH_SETTER_FACTORY: KotlinSingleIntentionActionFactory = object : K...
Please move the whole file into `idea-front-end-independent` module as it is used now by `idea-fir`. We a trying to keep dependencies to FE1.0 plugin classes to the minimum. Unfortunately, we can not remove the dependencies to the FE1.0 plugin modules right now, but I hope we can do it soon
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.
// First and second parameters in enum constructors are synthetic, we should ignore them val isEnumConstructor = (name == "<init>") && containingClass.isEnum() val startParameterIndex = if (isEnumConstructor) 2 else if (isInnerClassMember && name == "<init>") 1 else 0 val parameter...
You can avoid additional assignment here: ``` name = name ?: localVariables.getOrNull(index + localVariableIndexOffset)?.name ?: originalDescriptor.valueParameters.getOrNull(index)?.name?.identifier ?: "p${index - startParameterIndex}" ```
// First and second parameters in enum constructors are synthetic, we should ignore them val isEnumConstructor = (name == "<init>") && containingClass.isEnum() val startParameterIndex = if (isEnumConstructor) 2 else if (isInnerClassMember && name == "<init>") 1 else 0 val parameterT...
@@ -67,6 +72,8 @@ internal fun MethodNode.getParametersInfo(containingClass: ClassNode, isInnerCla // @JvmOverloads constructors and ordinary methods don't have "this" local variable name = name ?: localVariables.getOrNull(index + localVariableIndexOffset)?.name
plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/parseParameters.kt
26
Kotlin
1
suggestion
261
43
42
false
[KAPT] KT-43804 take argument names from original descriptor
4,111
JetBrains/kotlin
51,705
Kotlin
yanex
zveznicht
Review this pull request change. Language: Kotlin File: plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/parseParameters.kt PR Title: [KAPT] KT-43804 take argument names from original descriptor BEFORE CODE: // First and second parameters in enum constructors are synthetic, we should ignore th...
You can avoid additional assignment here: ``` name = name ?: localVariables.getOrNull(index + localVariableIndexOffset)?.name ?: originalDescriptor.valueParameters.getOrNull(index)?.name?.identifier ?: "p${index - startParameterIndex}" ```
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 KotlinBundleIndependent.message("fix.add.modifier.text.generic", modifier.value) } override fun getFamilyName() = KotlinBundleIndependent.message("fix.add.modifier.family") protected fun invokeOnElement(element: KtModifierListOwner?) { element?.addModifier(modifier) ...
Makes sense that `invokeImpl` was changed from the original implementation since that has the MPP-checking parts, but why was this one changed too?
} return KotlinBundle.message("fix.add.modifier.text.generic", modifier.value) } override fun getFamilyName() = KotlinBundle.message("fix.add.modifier.family") protected fun invokeOnElement(element: KtModifierListOwner?) { element?.addModifier(modifier) if (modifier == KtT...
@@ -0,0 +1,112 @@ +/* + * 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.idea.quickfix + +import com.intellij.openapi.editor.Edito...
idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt
26
Kotlin
0.571
question
147
51
51
false
FIR IDE: Split and AddModifierFix to fe-independent
4,115
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/AddModifierFix.kt PR Title: FIR IDE: Split and AddModifierFix to fe-independent BEFORE CODE: } return KotlinBundleIndependent.message("fix.add.modifier.text.generic", modifie...
Makes sense that `invokeImpl` was changed from the original implementation since that has the MPP-checking parts, but why was this one changed 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.
init { if (step == 0) throw kotlin.IllegalArgumentException("Step must be non-zero.") if (step == Int.MIN_VALUE) throw kotlin.IllegalArgumentException("Step must be greater than Int.MIN_VALUE to avoid overflow on negation.") } /** * The first element in the progression. */ pub...
It can be confusing when such documentation is shown in the `*Range` docs being inherited from Progression there. Given that we override `isEmpty` in ranges, it makes sense to refine the documentation as well. Please update `isEmpty` docs in `ClosedRange` and its public inheritors.
init { if (step == 0) throw kotlin.IllegalArgumentException("Step must be non-zero.") if (step == Int.MIN_VALUE) throw kotlin.IllegalArgumentException("Step must be greater than Int.MIN_VALUE to avoid overflow on negation.") } /** * The first element in the progression. */ pub...
@@ -41,7 +41,12 @@ public open class CharProgression override fun iterator(): CharIterator = CharProgressionIterator(first, last, step) - /** Checks if the progression is empty. */ + /** + * Checks if the progression is empty. + * + * Increasing progression is empty if its start value is grea...
core/builtins/src/kotlin/Progressions.kt
26
Kotlin
0.571
suggestion
282
51
51
false
KT-33783 KDoc: Detail when a range is empty
4,118
JetBrains/kotlin
51,705
Kotlin
ilya-g
shadrina
Review this pull request change. Language: Kotlin File: core/builtins/src/kotlin/Progressions.kt PR Title: KT-33783 KDoc: Detail when a range is empty BEFORE CODE: init { if (step == 0) throw kotlin.IllegalArgumentException("Step must be non-zero.") if (step == Int.MIN_VALUE) throw kotlin.Illega...
It can be confusing when such documentation is shown in the `*Range` docs being inherited from Progression there. Given that we override `isEmpty` in ranges, it makes sense to refine the documentation as well. Please update `isEmpty` docs in `ClosedRange` and its public inheritors.
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.
if (step == 0) throw kotlin.IllegalArgumentException("Step must be non-zero.") if (step == Int.MIN_VALUE) throw kotlin.IllegalArgumentException("Step must be greater than Int.MIN_VALUE to avoid overflow on negation.") } /** * The first element in the progression. */ public val fir...
A progression doesn't have start and end values. It has the properties returning `first` and `last` elements. The difference is explained here: https://kotlinlang.org/docs/ranges.html#progression
if (step == 0) throw kotlin.IllegalArgumentException("Step must be non-zero.") if (step == Int.MIN_VALUE) throw kotlin.IllegalArgumentException("Step must be greater than Int.MIN_VALUE to avoid overflow on negation.") } /** * The first element in the progression. */ public val fir...
@@ -98,7 +103,12 @@ public open class IntProgression override fun iterator(): IntIterator = IntProgressionIterator(first, last, step) - /** Checks if the progression is empty. */ + /** + * Checks if the progression is empty. + * + * Increasing progression is empty if its start value is greate...
core/builtins/src/kotlin/Progressions.kt
26
Kotlin
0.5
suggestion
195
51
51
false
KT-33783 KDoc: Detail when a range is empty
4,118
JetBrains/kotlin
51,705
Kotlin
ilya-g
shadrina
Review this pull request change. Language: Kotlin File: core/builtins/src/kotlin/Progressions.kt PR Title: KT-33783 KDoc: Detail when a range is empty BEFORE CODE: if (step == 0) throw kotlin.IllegalArgumentException("Step must be non-zero.") if (step == Int.MIN_VALUE) throw kotlin.IllegalArgumentEx...
A progression doesn't have start and end values. It has the properties returning `first` and `last` elements. The difference is explained here: https://kotlinlang.org/docs/ranges.html#progression
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.
init { if (step == 0.to$stepType()) throw kotlin.IllegalArgumentException("Step must be non-zero.") if (step == $stepMinValue) throw kotlin.IllegalArgumentException("Step must be greater than $stepMinValue to avoid overflow on negation.") } /** * The first element in the progression. ...
Either here should be an article as in Progression docs, "... with _a_ positive step". Or vice versa.
init { if (step == 0.to$stepType()) throw kotlin.IllegalArgumentException("Step must be non-zero.") if (step == $stepMinValue) throw kotlin.IllegalArgumentException("Step must be greater than $stepMinValue to avoid overflow on negation.") } /** * The first element in the progression. ...
@@ -579,7 +584,12 @@ internal constructor( override fun iterator(): ${elementType}Iterator = ${elementType}ProgressionIterator(first, last, step) - /** Checks if the progression is empty. */ + /** + * Checks if the progression is empty. + + * Progression with positive step is empty if its f...
generators/builtins/unsignedTypes.kt
26
Kotlin
0.429
suggestion
101
51
51
false
KT-33783 KDoc: Detail when a range is empty
4,118
JetBrains/kotlin
51,705
Kotlin
ilya-g
shadrina
Review this pull request change. Language: Kotlin File: generators/builtins/unsignedTypes.kt PR Title: KT-33783 KDoc: Detail when a range is empty BEFORE CODE: init { if (step == 0.to$stepType()) throw kotlin.IllegalArgumentException("Step must be non-zero.") if (step == $stepMinValue) throw kot...
Either here should be an article as in Progression docs, "... with _a_ positive step". Or vice versa.
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 kotlin.ranges /** * Represents a range of values (for example, numbers or characters). * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/ranges.html) for more information. */ public interface ClosedRange<T: Comparable<T>> { /** * The minimum value in the range. */...
"equal to" is not correct, see the condition below.
package kotlin.ranges /** * Represents a range of values (for example, numbers or characters). * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/ranges.html) for more information. */ public interface ClosedRange<T: Comparable<T>> { /** * The minimum value in the range. */...
@@ -27,6 +27,8 @@ public interface ClosedRange<T: Comparable<T>> { /** * Checks whether the range is empty. + * + * The closed range is empty if its start value is greater than or equal to the end value.
core/builtins/src/kotlin/Range.kt
26
Kotlin
0.214
suggestion
51
30
30
false
KT-33783 KDoc: Detail when a range is empty
4,118
JetBrains/kotlin
51,705
Kotlin
ilya-g
shadrina
Review this pull request change. Language: Kotlin File: core/builtins/src/kotlin/Range.kt PR Title: KT-33783 KDoc: Detail when a range is empty BEFORE CODE: package kotlin.ranges /** * Represents a range of values (for example, numbers or characters). * See the [Kotlin language documentation](https://kotlinlang....
"equal to" is not correct, see the condition below.
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.
// Note that the class that contains the currently visiting declaration will *not* be in the context's containing declarations *yet*. internal fun isInsideExpectClass(containingDeclaration: FirRegularClass, context: CheckerContext): Boolean = containingDeclaration.isExpect || context.containingDeclarations.asRevers...
Perhaps this is quite personal/cosmetic issue, but I still prefer to separate stuff in some logical chunk, like checkPropertyInitializer, checkPropertyAccessors, etc., then you can still use this, checkProperty, as a one entry point.
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef import org.jetbrains.kotlin.lexer.KtTokens // Note that the class that contains the currently visiting declaration will *not* be in the context's containing declarations *yet*. internal fun isInsideExpectClass(containingDeclaration: FirRegularClass, context: Che...
@@ -38,16 +38,14 @@ internal fun checkExpectDeclarationVisibilityAndBody( } } -internal fun checkPropertyInitializer( +internal fun checkProperty(
compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerUtils.kt
26
Kotlin
0.5
suggestion
233
51
51
false
FIR checker/IDE: Add checker and quickfix for VAL_WITH_SETTER
4,125
JetBrains/kotlin
51,705
Kotlin
jsjeon
punzki
Review this pull request change. Language: Kotlin File: compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerUtils.kt PR Title: FIR checker/IDE: Add checker and quickfix for VAL_WITH_SETTER BEFORE CODE: // Note that the class that contains the currently visiting decl...
Perhaps this is quite personal/cosmetic issue, but I still prefer to separate stuff in some logical chunk, like checkPropertyInitializer, checkPropertyAccessors, etc., then you can still use this, checkProperty, as a one entry point.
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.
symbol = FirPropertySymbol(callableIdForName(propertyName)) dispatchReceiverType = currentDispatchReceiverType() withCapturedTypeParameters { typeParameters += firTypeParameters addCapturedTypeParameters(firTypeParameters) ...
Minor, but isn't it still worth leaving some comments here (and corresponding part in `RawFirBuilder`) that we still need to build a setter for `val` to report `VAL_WITH_SETTER`?
symbol = FirPropertySymbol(callableIdForName(propertyName)) dispatchReceiverType = currentDispatchReceiverType() withCapturedTypeParameters { typeParameters += firTypeParameters addCapturedTypeParameters(firTypeParameters) ...
@@ -1017,16 +1017,15 @@ class DeclarationsConverter( it.containingClassAttr = lookupTag } } - this.setter = - if (isVar) { - convertedAccessors.find { it.isSetter }...
compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt
26
Kotlin
0.5
question
178
51
51
false
FIR checker/IDE: Add checker and quickfix for VAL_WITH_SETTER
4,125
JetBrains/kotlin
51,705
Kotlin
jsjeon
punzki
Review this pull request change. Language: Kotlin File: compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt PR Title: FIR checker/IDE: Add checker and quickfix for VAL_WITH_SETTER BEFORE CODE: symbol = FirPropertySymbol(callableIdForName(prop...
Minor, but isn't it still worth leaving some comments here (and corresponding part in `RawFirBuilder`) that we still need to build a setter for `val` to report `VAL_WITH_SETTER`?
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.
this.source = source.fakeElement(FirFakeSourceElementKind.DefaultAccessor) session = baseSession origin = FirDeclarationOrigin.Source returnTypeRef = propertyTypeRef ...
IIUC there is no logic change in this file. Is this change just to improve the readability?
if (!isGetter && valueParameters.isEmpty()) { valueParameters += buildDefaultSetterValueParameter { this.source = source.fakeElement(FirFakeSourceElementKind.DefaultAccessor) session = baseSession ...
@@ -345,68 +345,73 @@ class RawFirBuilder( isExternal = property.hasModifier(EXTERNAL_KEYWORD) || this@toFirPropertyAccessor?.hasModifier(EXTERNAL_KEYWORD) == true } - if (this == null || !hasBody()) { - val propertySource = - ...
compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt
26
Kotlin
0.286
question
91
51
51
false
FIR checker/IDE: Add checker and quickfix for VAL_WITH_SETTER
4,125
JetBrains/kotlin
51,705
Kotlin
tgeng
punzki
Review this pull request change. Language: Kotlin File: compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt PR Title: FIR checker/IDE: Add checker and quickfix for VAL_WITH_SETTER BEFORE CODE: this.source = source.fakeElement(FirFakeSourceElementKind.De...
IIUC there is no logic change in this file. Is this change just to improve the readability?
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.
as HLDiagnosticFixFactory<PsiElement, KtDiagnosticWithPsi<PsiElement>, PsiElement, HLApplicatorInput> createPlatformQuickFixes(diagnostic, factory) } is HLQuickFixFactory.HLQuickFixesPsiBasedFactory -> quickFixFactory.psiFactory.createQuickFix(diagnostic.psi) } ...
Why not removing `inline` modifier instead? :)
as HLDiagnosticFixFactory<PsiElement, KtDiagnosticWithPsi<PsiElement>, PsiElement, HLApplicatorInput> createPlatformQuickFixes(diagnostic, factory) } is HLQuickFixFactory.HLQuickFixesPsiBasedFactory -> quickFixFactory.psiFactory.createQuickFix(diagnostic.psi) } ...
@@ -55,11 +55,15 @@ class KtQuickFixesListBuilder private constructor() { @OptIn(PrivateForInline::class) private val quickFixes = mutableMapOf<KClass<out KtDiagnosticWithPsi<*>>, MutableList<HLQuickFixFactory>>() + @Suppress("NOTHING_TO_INLINE")
idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/fixes/KtQuickFixesList.kt
26
Kotlin
0.286
question
46
51
51
false
FIR IDE: Simplify registerPsiQuickFixes
4,127
JetBrains/kotlin
51,705
Kotlin
jsjeon
tgeng
Review this pull request change. Language: Kotlin File: idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/fixes/KtQuickFixesList.kt PR Title: FIR IDE: Simplify registerPsiQuickFixes BEFORE CODE: as HLDiagnosticFixFactory<PsiElement, KtDiagnosticWithPsi<PsiElement>, PsiElement, HLApplicatorInpu...
Why not removing `inline` modifier 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-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.idea.quickfix import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixRegistrar...
Let's move those factories to `RemoveModifierFix.Companion`
/* * 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.idea.quickfix import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixRegistrar...
@@ -5,24 +5,24 @@ package org.jetbrains.kotlin.idea.quickfix -import com.intellij.psi.PsiElement import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixRegistrar import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesList import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesListBuilder import org.j...
idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt
18
Kotlin
0.429
suggestion
59
43
43
false
FIR IDE: Simplify registerPsiQuickFixes
4,127
JetBrains/kotlin
51,705
Kotlin
darthorimar
tgeng
Review this pull request change. Language: Kotlin File: idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt PR Title: FIR IDE: Simplify registerPsiQuickFixes BEFORE CODE: /* * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code i...
Let's move those factories to `RemoveModifierFix.Companion`
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.
when { isRedundant -> KotlinBundle.message("remove.redundant.0.modifier", modifierText) modifier === KtTokens.ABSTRACT_KEYWORD || modifier === KtTokens.OPEN_KEYWORD -> KotlinBundle.message("make.0.not.1", getElementName(element), modifierText) ...
Super minor: I couldn't find a definitive answer on this, but the factories in `ChangeVariableMutabilityFix.Companion` have `UPPER_CASE_NAMES`. Which one is the correct naming convention? 🙂 https://kotlinlang.org/docs/coding-conventions.html#property-names seems to indicate it should be `removeRedundantModifier` sinc...
when { isRedundant -> KotlinBundle.message("remove.redundant.0.modifier", modifierText) modifier === KtTokens.ABSTRACT_KEYWORD || modifier === KtTokens.OPEN_KEYWORD -> KotlinBundle.message("make.0.not.1", getElementName(element), modifierText) ...
@@ -51,6 +51,9 @@ class RemoveModifierFix( } companion object { + val removeRedundantModifier = createRemoveModifierFactory(isRedundant = true)
idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt
26
Kotlin
0.643
suggestion
353
51
51
false
FIR IDE: Simplify registerPsiQuickFixes
4,127
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/RemoveModifierFix.kt PR Title: FIR IDE: Simplify registerPsiQuickFixes BEFORE CODE: when { isRedundant -> KotlinBundle.message("remove.redundant.0.modifie...
Super minor: I couldn't find a definitive answer on this, but the factories in `ChangeVariableMutabilityFix.Companion` have `UPPER_CASE_NAMES`. Which one is the correct naming convention? 🙂 https://kotlinlang.org/docs/coding-conventions.html#property-names seems to indicate it should be `removeRedundantModifier` sinc...
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 com.intellij.openapi.project.Project import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType class AddFunctionBodyFix(element: KtF...
I know you didn't change this, but I'm a little confused here. If `psiElement` is the function without a body, why do we even need to get the parent? Shouldn't this just be `return listOf(AddFunctionBodyFix(psiElement)`? I think `getNonStrictParentOfType` returns the argument if it matches the type (`KtFunction`) so...
import com.intellij.openapi.project.Project import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.KtPsiFactory class AddFunctionBodyFix(element: KtFunction) : KotlinPsiOnlyQuickFixAction<KtFunction>(element) { ...
@@ -30,9 +30,9 @@ class AddFunctionBodyFix(element: KtFunction) : KotlinPsiOnlyQuickFixAction<KtFu } } - companion object : KotlinSingleIntentionActionFactory() { - public override fun createAction(diagnostic: Diagnostic): AddFunctionBodyFix? { - return diagnostic.psiElement.getNonS...
idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt
26
Kotlin
0.786
suggestion
355
30
27
false
FIR IDE: register quickfix related to abstract members
4,131
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/AddFunctionBodyFix.kt PR Title: FIR IDE: register quickfix related to abstract members BEFORE CODE: import com.intellij.openapi.project.Project import org.jetbrains.kotlin.idea.KotlinBundle ...
I know you didn't change this, but I'm a little confused here. If `psiElement` is the function without a body, why do we even need to get the parent? Shouldn't this just be `return listOf(AddFunctionBodyFix(psiElement)`? I think `getNonStrictParentOfType` returns the argument if it matches the type (`KtFunction`) so...
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.idea.fir.api.fixes.KtQuickFixesListBuilder import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic import org.jetbrains.kotlin.idea.quickfix.fixes.ChangeTypeQuickFix import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtClassOrObject class MainKt...
Let's not mix up factories creation and registration. E.g, factories can be moved to `AddModifierFix`/`RemoveModifierFix` companions
import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesListBuilder import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic import org.jetbrains.kotlin.idea.quickfix.fixes.ChangeTypeQuickFix class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { private val modifiers = KtQuickFixesListBui...
@@ -26,6 +27,22 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { isRedundant = true ) ) + + val addAbstractModifierFactory = AddModifierFix.createFactory(KtTokens.ABSTRACT_KEYWORD) + registerPsiQuickFixes(KtFirDiagnostic.NonAbstractFunctionWithNoBody::class...
idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt
26
Kotlin
0.571
suggestion
132
51
44
false
FIR IDE: register quickfix related to abstract members
4,131
JetBrains/kotlin
51,705
Kotlin
darthorimar
tgeng
Review this pull request change. Language: Kotlin File: idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt PR Title: FIR IDE: register quickfix related to abstract members BEFORE CODE: import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesListBuilder import org.jetbrains.kotlin.ide...
Let's not mix up factories creation and registration. E.g, factories can be moved to `AddModifierFix`/`RemoveModifierFix` companions
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.resolve.jvm.checkers import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtDeclarationWithBody import org.jetbrains.kotlin.psi.KtPro...
Is this if condition redundant?
package org.jetbrains.kotlin.resolve.jvm.checkers import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtDeclarationWithBody import org.jetbrains.kotlin.psi.KtPro...
@@ -39,7 +39,11 @@ class ExternalFunChecker : DeclarationChecker { is ClassDescriptor -> "class" else -> "non-function declaration" } - trace.report(Errors.WRONG_MODIFIER_TARGET.on(declaration, KtTokens.EXTERNAL_KEYWORD, target)) + if (declaration.mod...
compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ExternalFunChecker.kt
26
Kotlin
0.071
question
31
51
51
false
Provide quickfix for wrong `external` modifier on declarations
4,133
JetBrains/kotlin
51,705
Kotlin
tgeng
punzki
Review this pull request change. Language: Kotlin File: compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/ExternalFunChecker.kt PR Title: Provide quickfix for wrong `external` modifier on declarations BEFORE CODE: package org.jetbrains.kotlin.resolve.jvm.checkers import org.jetbrains.kotlin.desc...
Is this if condition redundant?
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: FirDeclaration, moduleFileCache: ModuleFileCache, toPhase: FirResolvePhase, towerDataContextCollector: FirTowerDataContextCollector? = null, checkPCE: Boolean = false, reresolveFile: Boolean = false, ) { if (declaration.resolvePhase >= toPhase) re...
Maybe out of scope this PR/commit, but was it intentional to say `reresolveFile`? Like resolving file again?
towerDataContextCollector: FirTowerDataContextCollector? = null, checkPCE: Boolean = false, reresolveFile: Boolean = false, ) { if (declaration.resolvePhase >= toPhase) return if (declaration is FirPropertyAccessor || declaration is FirTypeParameter || declaration is FirValu...
@@ -56,7 +56,7 @@ internal class FirLazyDeclarationResolver( val firFile = declaration.getContainingFile() ?: error("FirFile was not found for\n${declaration.render()}") val provider = firFile.session.firIdeProvider - val fromPhase = if (reresolveFile) declaration.resolvePhase else...
idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/lazy/resolve/FirLazyDeclarationResolver.kt
26
Kotlin
0.5
question
108
51
51
false
FIR IDE: fix redundant resolve [#KT-45121]
4,140
JetBrains/kotlin
51,705
Kotlin
jsjeon
tgeng
Review this pull request change. Language: Kotlin File: idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/lazy/resolve/FirLazyDeclarationResolver.kt PR Title: FIR IDE: fix redundant resolve [#KT-45121] BEFORE CODE: declaration: FirDeclaration, moduleFileCa...
Maybe out of scope this PR/commit, but was it intentional to say `reresolveFile`? Like resolving file again?
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: FirDeclaration, moduleFileCache: ModuleFileCache, toPhase: FirResolvePhase, towerDataContextCollector: FirTowerDataContextCollector? = null, checkPCE: Boolean = false, reresolveFile: Boolean = false, ) { if (declaration.resolvePhase >= toPhase) re...
I'm trying to understand how this change could resolve the race condition, and it seems to me, the timing of evaluating `fromPhase` matters. Previously, it's computed before any of resolvers ran, and now with this change, it could be computed when it's needed. Does this sound like `lazy`? How about this? ```kt val ...
towerDataContextCollector: FirTowerDataContextCollector? = null, checkPCE: Boolean = false, reresolveFile: Boolean = false, ) { if (declaration.resolvePhase >= toPhase) return if (declaration is FirPropertyAccessor || declaration is FirTypeParameter || declaration is FirValu...
@@ -56,7 +56,7 @@ internal class FirLazyDeclarationResolver( val firFile = declaration.getContainingFile() ?: error("FirFile was not found for\n${declaration.render()}") val provider = firFile.session.firIdeProvider - val fromPhase = if (reresolveFile) declaration.resolvePhase else...
idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/lazy/resolve/FirLazyDeclarationResolver.kt
26
Kotlin
1
bug
455
51
51
false
FIR IDE: fix redundant resolve [#KT-45121]
4,140
JetBrains/kotlin
51,705
Kotlin
jsjeon
tgeng
Review this pull request change. Language: Kotlin File: idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/lazy/resolve/FirLazyDeclarationResolver.kt PR Title: FIR IDE: fix redundant resolve [#KT-45121] BEFORE CODE: declaration: FirDeclaration, moduleFileCa...
I'm trying to understand how this change could resolve the race condition, and it seems to me, the timing of evaluating `fromPhase` matters. Previously, it's computed before any of resolvers ran, and now with this change, it could be computed when it's needed. Does this sound like `lazy`? How about this? ```kt val ...
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: FirDeclaration, moduleFileCache: ModuleFileCache, toPhase: FirResolvePhase, towerDataContextCollector: FirTowerDataContextCollector? = null, checkPCE: Boolean = false, reresolveFile: Boolean = false, ) { if (declaration.resolvePhase >= toPhase) re...
We do not need thread safe lazy here :) let's use one with `LazyThreadSafetyMode.NONE`
declaration: FirDeclaration, moduleFileCache: ModuleFileCache, toPhase: FirResolvePhase, towerDataContextCollector: FirTowerDataContextCollector? = null, checkPCE: Boolean = false, reresolveFile: Boolean = false, ) { if (declaration.resolvePhase >= toPhase) re...
@@ -56,7 +53,9 @@ internal class FirLazyDeclarationResolver( val firFile = declaration.getContainingFile() ?: error("FirFile was not found for\n${declaration.render()}") val provider = firFile.session.firIdeProvider - val fromPhase = if (reresolveFile) declaration.resolvePhase else...
idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/lazy/resolve/FirLazyDeclarationResolver.kt
26
Kotlin
0.571
suggestion
86
51
51
false
FIR IDE: fix redundant resolve [#KT-45121]
4,140
JetBrains/kotlin
51,705
Kotlin
darthorimar
tgeng
Review this pull request change. Language: Kotlin File: idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/lazy/resolve/FirLazyDeclarationResolver.kt PR Title: FIR IDE: fix redundant resolve [#KT-45121] BEFORE CODE: declaration: FirDeclaration, moduleFileCa...
We do not need thread safe lazy here :) let's use one with `LazyThreadSafetyMode.NONE`
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 getFamilyName() = KotlinBundle.message("remove.modifier") override fun getText() = text override fun isAvailableImpl(project: Project, editor: Editor?, file: PsiFile) = element?.hasModifier(modifier) == true override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) { ...
Nit: explicit type for `val` seems not necessary (as the similar one above didn't specify that).
override fun getFamilyName() = KotlinBundle.message("remove.modifier") override fun getText() = text override fun isAvailableImpl(project: Project, editor: Editor?, file: PsiFile) = element?.hasModifier(modifier) == true override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) { ...
@@ -61,6 +61,7 @@ class RemoveModifierFix( isRedundant = true ) val removeOpenModifier = createRemoveModifierFromListOwnerPsiBasedFactory(KtTokens.OPEN_KEYWORD) + val removePrivateModifier: QuickFixesPsiBasedFactory<PsiElement> = createRemoveModifierFromListOwnerPsiBasedFac...
idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt
26
Kotlin
0.5
nitpick
96
51
51
false
FIR IDE: Add quickfix for PRIVATE_SETTER_FOR_(OPEN|ABSTRACT)_PROPERTY
4,156
JetBrains/kotlin
51,705
Kotlin
jsjeon
tgeng
Review this pull request change. Language: Kotlin File: idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt PR Title: FIR IDE: Add quickfix for PRIVATE_SETTER_FOR_(OPEN|ABSTRACT)_PROPERTY BEFORE CODE: override fun getFamilyName() = KotlinBundle.message("remove.modifier") ...
Nit: explicit type for `val` seems not necessary (as the similar one above didn't specify that).
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.
// TODO: Move this to different, JVM-specific module? object FirJvmExternalDeclarationChecker : FirBasicDeclarationChecker() { override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { val source = declaration.source ?: return if (source.kind is FirFak...
You can turn on Settings > Editor > General > On Save > "Ensure every saved file ends with a line break" to avoid this. Learned from @tgeng :)
// TODO: Move this to different, JVM-specific module? object FirJvmExternalDeclarationChecker : FirMemberDeclarationChecker() { override fun check(declaration: FirMemberDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { if (!declaration.isExternal) return val source = declaration....
@@ -0,0 +1,45 @@ +/* + * 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.fir.analysis.checkers.declaration.jvm + +import org.jetbra...
compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/jvm/FirJvmExternalDeclarationChecker.kt
26
Kotlin
0.429
suggestion
142
26
28
false
FIR checker/IDE: Add checker and quickfixes for WRONG_MODIFIER_TARGET
4,164
JetBrains/kotlin
51,705
Kotlin
jsjeon
punzki
Review this pull request change. Language: Kotlin File: compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/jvm/FirJvmExternalDeclarationChecker.kt PR Title: FIR checker/IDE: Add checker and quickfixes for WRONG_MODIFIER_TARGET BEFORE CODE: // TODO: Move this to different, JVM-specific...
You can turn on Settings > Editor > General > On Save > "Ensure every saved file ends with a line break" to avoid this. Learned from @tgeng :)
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.FirFakeSourceElementKind import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirMemberDeclarationChecker import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirModifierList import org.jetbrains.k...
Widely used pattern in checkes, mind extracting it into a util function like`FirDeclaration.getModifierOfType(tokenType: KtModifierKeywordToken)` ?
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirMemberDeclarationChecker import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirModifierList import org.jetbrains.k...
@@ -0,0 +1,45 @@ +/* + * 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.fir.analysis.checkers.declaration.jvm + +import org.jetbra...
compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/jvm/FirJvmExternalDeclarationChecker.kt
26
Kotlin
0.714
refactor
147
39
40
false
FIR checker/IDE: Add checker and quickfixes for WRONG_MODIFIER_TARGET
4,164
JetBrains/kotlin
51,705
Kotlin
darthorimar
punzki
Review this pull request change. Language: Kotlin File: compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/jvm/FirJvmExternalDeclarationChecker.kt PR Title: FIR checker/IDE: Add checker and quickfixes for WRONG_MODIFIER_TARGET BEFORE CODE: import org.jetbrains.kotlin.fir.FirFakeSourceE...
Widely used pattern in checkes, mind extracting it into a util function like`FirDeclaration.getModifierOfType(tokenType: KtModifierKeywordToken)` ?
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.
if (modifierListOwner is KtObjectDeclaration) return null if (modifierListOwner is KtClass) { if (modifierListOwner.isInterface() || modifierListOwner.isSealed() || modifierListOwner.isEnum() || ...
Nit: we should probably unify on one style here. Either put in types on the other lines or simplify the other lines as well (I prefer the latter)?
if (modifierListOwner is KtObjectDeclaration) return null if (modifierListOwner is KtClass) { if (modifierListOwner.isInterface() || modifierListOwner.isSealed() || modifierListOwner.isEnum() || ...
@@ -113,6 +113,7 @@ open class AddModifierFix( AddModifierFix.createFactory(KtTokens.OPEN_KEYWORD, KtClassOrObject::class.java) val addFinalToProperty: QuickFixesPsiBasedFactory<PsiElement> = AddModifierFix.createFactory(KtTokens.FINAL_KEYWORD, KtProperty::class.java) + val add...
idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt
26
Kotlin
0.571
refactor
146
38
36
false
FIR IDE: add quickfix for NESTED_CLASS_NOT_ALLOWED
4,173
JetBrains/kotlin
51,705
Kotlin
madsager
tgeng
Review this pull request change. Language: Kotlin File: idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt PR Title: FIR IDE: add quickfix for NESTED_CLASS_NOT_ALLOWED BEFORE CODE: if (modifierListOwner is KtObjectDeclaration) return null ...
Nit: we should probably unify on one style here. Either put in types on the other lines or simplify the other lines as well (I prefer the latter)?
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 capturedValues = localClassContext.closure.capturedValues val newDeclaration = context.irFactory.buildConstructor { updateFrom(oldDeclaration) visibility = visibilityPolicy.forConstructor(oldDeclaration, constructorContext.inInlineFunctionScope) ...
Am I correct that the old declaration is dropped?
val capturedValues = localClassContext.closure.capturedValues val newDeclaration = context.irFactory.buildConstructor { updateFrom(oldDeclaration) visibility = visibilityPolicy.forConstructor(oldDeclaration, constructorContext.inInlineFunctionScope) ...
@@ -726,6 +726,8 @@ class LocalDeclarationsLowering( ) newDeclaration.recordTransformedValueParameters(constructorContext) + newDeclaration.annotations = oldDeclaration.annotations
compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt
26
Kotlin
0.071
question
50
51
51
false
[IR] Move annotations from original to new constructor declarations.
4,175
JetBrains/kotlin
51,705
Kotlin
romanart
madsager
Review this pull request change. Language: Kotlin File: compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt PR Title: [IR] Move annotations from original to new constructor declarations. BEFORE CODE: val capturedValues = localClassContext.closure.capture...
Am I correct that the old declaration is dropped?
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.