Tomasz Krakowiak
12/06/2021, 9:00 AMmax.kammerer
12/08/2021, 10:45 AM-Xjvm-default=disable
mode to -Xjvm-default=all
. This change will keep source compatibility but could break binary one if you are using compiler internals. If you use some compiler internal interfaces could you please list them in thread. In such case we will try to also ship binary compatible stubs for DefaultImpls
classes (that would gone away in all
mode)
UPD: this post is not about switching default value for -Xjvm-default
. The aim of it to avoid any occasional breakage for compiler extension, pluginsThiago
12/08/2021, 2:58 PMa > 0 && a < 10
and replace with range as a in 1..9
?
Why "primitive" comparisons are not recommended in favor of Ranges instances to call a contains operator?
Is there any article/resources explaining the recomendation?Alex
12/10/2021, 9:09 AMjava.lang.IllegalStateException: Symbol for kotlin.collections/mutableMapOf|-4813910536206556932[0] is unbound
at org.jetbrains.kotlin.ir.symbols.impl.IrBindablePublicSymbolBase.getOwner(IrPublicSymbolBase.kt:52)
...
Carl Hickman
12/10/2021, 5:42 PMRoshad Guerrier
12/14/2021, 11:20 PMExerosis
12/17/2021, 8:30 PMZac Sweers
12/17/2021, 10:14 PMholgerbrandl
12/18/2021, 11:25 AMkotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
in my grade build definition?Andy Himberger
12/20/2021, 4:59 AMjava.lang.IllegalStateException: Symbol for kotlin.collections/mutableMapOf|-4813910536206556932[0] is unbound
at org.jetbrains.kotlin.ir.symbols.impl.IrBindablePublicSymbolBase.getOwner(IrPublicSymbolBase.kt:52)
at org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionPublicSymbolImpl.getOwner(IrPublicSymbolBase.kt:74)
at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitCall(LiveLiteralTransformer.kt:663)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:199)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:24)
at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
at org.jetbrains.kotlin.ir.expressions.IrExpressionBody.transformChildren(IrBody.kt:46)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBody(IrElementTransformerVoid.kt:108)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpressionBody(IrElementTransformerVoid.kt:114)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpressionBody(IrElementTransformerVoid.kt:115)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpressionBody(IrElementTransformerVoid.kt:24)
at org.jetbrains.kotlin.ir.expressions.IrExpressionBody.accept(IrBody.kt:36)
at org.jetbrains.kotlin.ir.expressions.IrExpressionBody.transform(IrBody.kt:39)
at org.jetbrains.kotlin.ir.declarations.IrField.transformChildren(IrField.kt:41)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:57)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitField(IrElementTransformerVoid.kt:81)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitField(IrElementTransformerVoid.kt:82)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitField(IrElementTransformerVoid.kt:24)
at org.jetbrains.kotlin.ir.declarations.IrField.accept(IrField.kt:34)
at org.jetbrains.kotlin.ir.IrElement$DefaultImpls.transform(IrElement.kt:32)
at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:19)
at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
at org.jetbrains.kotlin.ir.declarations.IrClass.transformChildren(IrClass.kt:66)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:57)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:66)
at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitClass$s780614737(LiveLiteralTransformer.kt:158)
at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitClass$1.invoke(LiveLiteralTransformer.kt:466)
at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitClass$1.invoke(LiveLiteralTransformer.kt:465)
at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:117)
at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor$siblings$1.invoke(DurableKeyVisitor.kt:131)
at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:131)
at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.siblings(LiveLiteralTransformer.kt:194)
at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitClass(LiveLiteralTransformer.kt:465)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:67)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:24)
at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:55)
at org.jetbrains.kotlin.ir.IrElement$DefaultImpls.transform(IrElement.kt:32)
at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:19)
at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.transformChildren(IrFileImpl.kt:89)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitPackageFragment(IrElementTransformerVoid.kt:41)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:47)
at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitFile$s780614737(LiveLiteralTransformer.kt:158)
at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitFile$1.invoke(LiveLiteralTransformer.kt:549)
at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitFile$1.invoke(LiveLiteralTransformer.kt:479)
at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:117)
at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.root(DurableKeyVisitor.kt:152)
at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitFile(LiveLiteralTransformer.kt:479)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:48)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:24)
at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.accept(IrFileImpl.kt:81)
at org.jetbrains.kotlin.ir.declarations.IrFile.transform(IrFile.kt:52)
at org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl.transformChildren(IrModuleFragmentImpl.kt:45)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:330)
at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.lower(LiveLiteralTransformer.kt:171)
at androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:96)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$lambda-1(JvmIrCodegenFactory.kt:121)
at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:88)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:146)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$default(JvmIrCodegenFactory.kt:64)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:59)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:331)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:123)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:58)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:170)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:434)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:120)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:357)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:299)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:118)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:169)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:80)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:622)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:100)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1713)
at jdk.internal.reflect.GeneratedMethodAccessor109.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
PHondogo
12/21/2021, 10:10 AMvar b : Byte = 10.toByte()
b += 10.toByte()
Complains about type mismatch: Required Byte got Int.
Why?martmists
12/23/2021, 10:33 PMmartmists
12/25/2021, 6:34 PMursus
12/26/2021, 3:03 PMgradlew clean
fails on windows due to files being locked, but works on linux/mac
https://github.com/square/anvil/issues/458#issue-1088683292
any ideas?Chachako
12/28/2021, 2:59 PMIrGenerationExtension
to process all files, then access all expressions through IrElementTransformer
, then find out the corresponding references and replace them, but I’m a little worried about its performance.
I would be grateful if someone could give me a some advice! 🙏🏻Chachako
12/29/2021, 3:00 PMSmartCastManager
at the compiler-frontend, but I don’t know how to start. I want to smart cast type after an expression, for example:
class CallBlock(private val types: KClass<*>) {
fun resultAt(index: Int): Any = results[index]
}
fun call(vararg types: KClass<*>, block: CallBlock.() -> Unit) = ...
call(Int::class, String::class) {
val a = resultAt(0) // Implicit: Int
val b = resultAt(1) // Implicit: String
}
---
As shown in the code, I want to smart cast the type result of resultAt()
callYoussef Shoaib [MOD]
12/31/2021, 2:38 AMPiotr Krzemiński
01/03/2022, 10:50 AMCraig
01/03/2022, 10:00 PMComposableCallChecker
runs, which I think means it needs to happen in the frontend.
I tried this is in a AnalysisHandlerExtension
myKtNamedFunction.addAnnotationEntry(KtPsiFactory(project).createAnnotationEntry("@androidx.compose.runtime.Composable"))
but it throws "Cannot modify a read-only file 'main.kt'"Chachako
01/05/2022, 3:20 PMConstantExpressionEvaluator
in the frontend. Is there something similar in the backend?Rob Elliot
01/05/2022, 4:13 PM<T>
as <T & Any>
in some circumstances if you also use it as <T?>
.Rob Elliot
01/06/2022, 1:38 PMFoo<String>
to be a subtype of Foo<Any>
, and if you favour immutable data types then covariance often Just Works™.
I try and remember to use <out T>
as my starting point, until I need something else, but I often forget...server
01/10/2022, 6:44 AMRob Elliot
01/10/2022, 3:11 PMthen
blocks in a compiler plugin?
I still really miss the sheer simplicity of the syntax of Spock's tests.andylamax
01/11/2022, 5:35 AMCould not find "kotlin" in [/home/andylamax/.local/share/kotlin/daemon]
and previously I also had
Could not find "kotlinx-serialization-core" in [/home/andylamax/.local/share/kotlin/daemon]
Has anyone come across this? or better yet, found a solution to this??jianbing
01/11/2022, 2:52 PM@MetaData
data class A (val x: String, val y: String)
after applying compiler plugin, the .class file will be altered to something like below (from source perspective), basically, I will add implicitly MetaData into the primary constructor for all source Kotlin so long as it is with annonation @MetaData in place, plus a new method fun getMetaData()
get generated.
data class A(val x: String, val y:String, val myMeta: MetaData) {
fun getMetaData() {
//some logic check
return myMeta
}
}
now when it comes to use the new synthetic ".class" file manipulated as below, IntelliJ complains it cannot find resolve A (it has only the constructor with 2 parameters not 3) and cannot resolve the the synthetic method getMetaData() either.
val x = A("ba", "fo", MetaData(..))
val y = x.getMetaData()
can somebody shed some light on it?
I know lombok seems no problem with it after adding its @Getter annotation for example into Java source code, IntelliJ can recognize its getXXX method (which is generated by lombok). I don't know how to implement the same for my case for kotlin language. please include the detailed steps if possible.PHondogo
01/12/2022, 1:30 PMChachako
01/12/2022, 5:58 PMIrModuleFragment.transformChildrenVoid
🤯
* What went wrong:
Execution failed for task ':api:compileKotlinJvm'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Internal compiler error. See log for more details
e: java.util.ConcurrentModificationException
at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1043)
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:997)
at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.transformChildren(IrFileImpl.kt:97)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitPackageFragment(IrElementTransformerVoid.kt:41)
......
at org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl.transformChildren(IrModuleFragmentImpl.kt:45)
at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:330)
at com.meowool.sweekt.lazyinit.LazyInitTransformer.lower(LazyInitTransformer.kt:73)
at com.meowool.sweekt.SweektComponentRegistrar$registerProjectComponents$1.generate(SweektCompilerPlugin.kt:86)
Sasha Shpota
01/12/2022, 8:22 PMIdSignature.PublicSignature
was in 1.5, but is removed in 1.6).
Will my plugin (built on 1.5) work with applications using Kotlin 1.6? And vice versa, let's say I update my plugin to use Kotlin 1.6, will the clients with 1.5 be able to use the plugin version based on 1.6? How should I handle such changes?sindrenm
01/13/2022, 4:17 PM(() -> Unit)?
doesn't always allow calling in the “natural” way. Is this a known issue? (Kotlin 1.6.0.)sindrenm
01/13/2022, 4:17 PM(() -> Unit)?
doesn't always allow calling in the “natural” way. Is this a known issue? (Kotlin 1.6.0.)class Runner(private val run: (() -> Unit)?) {
fun works() {
if (run == null) return
run.invoke()
}
fun fails() {
if (run == null) return
run()
}
}
fun runner(run: (() -> Unit)?) {
if (run == null) return
run()
}
Dominaezzz
01/13/2022, 4:40 PMFleshgrinder
01/13/2022, 4:45 PMrun?.invoke() ?: return
Dominaezzz
01/13/2022, 4:57 PM?
in your workaround is not needed, which is part of the issue.Fleshgrinder
01/13/2022, 5:01 PMfun f() {
if (run == null) return
run() // requires smart cast, but doesn't work in any Kotlin version because of operator sugar
}
The alternative I gave for the particular example would be:
fun f() {
run?.invoke() ?: return
}
This would work in the example case, but not in the general case (obviously). A general solution to fix this:
fun f() {
// snip
run?.let { run ->
// snip
run()
// snip
}
// snip
}
works
function and the green background color of run
.Dominaezzz
01/13/2022, 5:02 PMworks
compile?Fleshgrinder
01/13/2022, 5:03 PMrun.invoke()
in works
gets transpiled to (run as () -> Unit).invoke()
. (Well, smart casted.)sindrenm
01/13/2022, 5:07 PMfun runner(run: (() -> Unit)?) {
if (run == null) return
run()
}
This is smart-cast + sugar, the only difference is we're dealing with a function parameter and not a class property:bashor
01/13/2022, 5:25 PMFleshgrinder
01/13/2022, 5:25 PML2
LINENUMBER 6 L2
ALOAD 0
GETFIELD Test.run : Lkotlin/jvm/functions/Function0;
INVOKEINTERFACE kotlin/jvm/functions/Function0.invoke ()Ljava/lang/Object; (itf)
POP
L3
LINENUMBER 7 L3
ALOAD 0
GETFIELD Test.run : Lkotlin/jvm/functions/Function0;
INVOKEINTERFACE kotlin/jvm/functions/Function0.invoke ()Ljava/lang/Object; (itf)
POP
L4
LINENUMBER 8 L4
ALOAD 1
INVOKEINTERFACE kotlin/jvm/functions/Function0.invoke ()Ljava/lang/Object; (itf)
POP
L5
LINENUMBER 9 L5
ALOAD 1
INVOKEINTERFACE kotlin/jvm/functions/Function0.invoke ()Ljava/lang/Object; (itf)
POP
sindrenm
01/13/2022, 5:41 PM