Carter Hudson
02/19/2024, 12:49 AMKtDotQualifiedExpression
, but I’m not sure where to go from there. My hierarchy looks something like this:
DOT_QUALIFIED_EXPRESSION(891,920)
REFERENCE_EXPRESSION(891,897)
PsiElement(IDENTIFIER)('sender')(891,897)
PsiElement(DOT)('.')(897,898)
CALL_EXPRESSION(898,920)
REFERENCE_EXPRESSION(898,907)
PsiElement(IDENTIFIER)('sendEvent')(898,907)
VALUE_ARGUMENT_LIST(907,920)
PsiElement(LPAR)('(')(907,908)
VALUE_ARGUMENT(908,919)
CALL_EXPRESSION(908,919)
REFERENCE_EXPRESSION(908,917)
PsiElement(IDENTIFIER)('SomeEvent')(908,917)
VALUE_ARGUMENT_LIST(917,919)
PsiElement(LPAR)('(')(917,918)
PsiElement(RPAR)(')')(918,919)
PsiElement(RPAR)(')')(919,920)
I essentially want to determine if the EventSender#sendEvent
method is being called, and if the parameter being passed is annotated properly. So far I haven’t been able to figure out how to obtain the type of sender
to determine if it’s the sendEvent
I even care about. Any help is appreciated.Ahmed Mourad
02/19/2024, 3:35 PMreactormonk
02/20/2024, 3:11 PMResult<T>
& smart casting - the first way would be nice, but Result
doesn't seem to be implemented that way. Is the second answer how to do it? https://chat.openai.com/share/ce159d0a-ec14-405e-972c-5f1936461e7bManuel Wrage
02/20/2024, 7:42 PMFirFunctionSymbol
to IrFunctionSymbol
, FirClassSymbol
to IrClassSymbol
and so on?Manuel Wrage
02/21/2024, 11:30 AMFirDeclarationGenerationExtension
in K2
kotlin version: 2.0.0-Beta4
error message: Daemon compilation failed: null
java.lang.Exception
at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:69)
at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:65)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemon(GradleKotlinCompilerWork.kt:240)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemonOrFallbackImpl(GradleKotlinCompilerWork.kt:159)
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:111)
at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction.execute(GradleCompilerRunnerWithWorkers.kt:76)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$0(DefaultWorkerExecutor.java:170)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:187)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:120)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:162)
at org.gradle.internal.Factories$1.create(Factories.java:31)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:249)
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:109)
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:114)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:157)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:126)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.AssertionError: java.lang.Exception: Could not close incremental caches in /home/manu/AndroidStudioProjects/injekt/core/build/kotlin/compileKotlinJvm/cacheable/caches-jvm/jvm/kotlin: source-to-classes.tab
at org.jetbrains.kotlin.com.google.common.io.Closer.close(Closer.java:230)
at org.jetbrains.kotlin.incremental.IncrementalCachesManager.close(IncrementalCachesManager.kt:55)
at kotlin.io.CloseableKt.closeFinally(Closeable.kt:56)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.kt:293)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:129)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:687)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:103)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1674)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
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(AccessController.java:712)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
... 3 more
Caused by: java.lang.Exception: Could not close incremental caches in /home/manu/AndroidStudioProjects/injekt/core/build/kotlin/compileKotlinJvm/cacheable/caches-jvm/jvm/kotlin: source-to-classes.tab
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner.forEachMapSafe(BasicMapsOwner.kt:93)
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner.close(BasicMapsOwner.kt:45)
at org.jetbrains.kotlin.com.google.common.io.Closer.close(Closer.java:218)
... 24 more
Suppressed: java.lang.IllegalStateException: Expected absolute path but found relative path: __GENERATED DECLARATIONS__.kt
at org.jetbrains.kotlin.incremental.storage.RelocatableFileToPathConverter.toPath(RelocatableFileToPathConverter.kt:20)
at org.jetbrains.kotlin.incremental.storage.FileDescriptor.getHashCode(FileToPathConverter.kt:50)
at org.jetbrains.kotlin.incremental.storage.FileDescriptor.getHashCode(FileToPathConverter.kt:30)
at org.jetbrains.kotlin.com.intellij.util.containers.hash.HashUtil.hash(HashUtil.java:24)
at org.jetbrains.kotlin.com.intellij.util.containers.hash.LinkedHashMap.remove(LinkedHashMap.java:149)
at org.jetbrains.kotlin.com.intellij.util.containers.SLRUMap.remove(SLRUMap.java:116)
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.flushAppendCache(PersistentMapImpl.java:924)
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.doPut(PersistentMapImpl.java:386)
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.put(PersistentMapImpl.java:360)
at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMap.put(PersistentHashMap.java:102)
at org.jetbrains.kotlin.incremental.storage.LazyStorage.set(LazyStorage.kt:78)
at org.jetbrains.kotlin.incremental.storage.InMemoryStorage.applyChanges(InMemoryStorage.kt:108)
at org.jetbrains.kotlin.incremental.storage.AppendableInMemoryStorage.applyChanges(InMemoryStorage.kt:175)
at org.jetbrains.kotlin.incremental.storage.InMemoryStorage.close(InMemoryStorage.kt:136)
at org.jetbrains.kotlin.incremental.storage.AppendableSetBasicMap.close(BasicMap.kt:157)
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner$close$1.invoke(BasicMapsOwner.kt:45)
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner$close$1.invoke(BasicMapsOwner.kt:45)
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner.forEachMapSafe(BasicMapsOwner.kt:85)
... 26 more
Suppressed: java.lang.Exception: Could not close incremental caches in /home/manu/AndroidStudioProjects/injekt/core/build/kotlin/compileKotlinJvm/cacheable/caches-jvm/inputs: source-to-output.tab
... 27 more
Suppressed: java.lang.IllegalStateException: Expected absolute path but found relative path: __GENERATED DECLARATIONS__.kt
at org.jetbrains.kotlin.incremental.storage.RelocatableFileToPathConverter.toPath(RelocatableFileToPathConverter.kt:20)
at org.jetbrains.kotlin.incremental.storage.FileDescriptor.getHashCode(FileToPathConverter.kt:50)
at org.jetbrains.kotlin.incremental.storage.FileDescriptor.getHashCode(FileToPathConverter.kt:30)
at org.jetbrains.kotlin.com.intellij.util.containers.hash.HashUtil.hash(HashUtil.java:24)
at org.jetbrains.kotlin.com.intellij.util.containers.hash.LinkedHashMap.remove(LinkedHashMap.java:149)
at org.jetbrains.kotlin.com.intellij.util.containers.SLRUMap.remove(SLRUMap.java:116)
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.flushAppendCache(PersistentMapImpl.java:924)
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.doPut(PersistentMapImpl.java:386)
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.put(PersistentMapImpl.java:360)
at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMap.put(PersistentHashMap.java:102)
at org.jetbrains.kotlin.incremental.storage.LazyStorage.set(LazyStorage.kt:78)
at org.jetbrains.kotlin.incremental.storage.InMemoryStorage.applyChanges(InMemoryStorage.kt:108)
at org.jetbrains.kotlin.incremental.storage.AppendableInMemoryStorage.applyChanges(InMemoryStorage.kt:175)
at org.jetbrains.kotlin.incremental.storage.InMemoryStorage.close(InMemoryStorage.kt:136)
at org.jetbrains.kotlin.incremental.storage.AppendableSetBasicMap.close(BasicMap.kt:157)
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner$close$1.invoke(BasicMapsOwner.kt:45)
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner$close$1.invoke(BasicMapsOwner.kt:45)
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner.forEachMapSafe(BasicMapsOwner.kt:85)
... 26 more
eygraber
02/22/2024, 4:38 AMk as C
, especially since I got an error when I tried lookup[C::class] = factory
despite C
being guaranteed to be a K
. Anyone know why I didn't get a warning?
public class FooFactory<K : FooKey> {
@PublishedApi internal val lookup: MutableMap<KClass<out K>, (K) -> Foo<out K>> = mutableMapOf()
public inline fun <reified C : K> addFactory(
noinline factory: (C) -> Foo<out C>
) {
lookup[C::class] = { k ->
factory(k as C)
}
}
}
Damian Baczyński
02/23/2024, 1:11 PMIrClass
) across multiple files (IrFile
). In result I have multiple classes with different parents. Some of those classes are duplicates and could be reused. However, if I use class declared in file A in file B it breaks with incremental compilation after file A is deleted. How to share those classes properly to avoid IC errors?Ahmed Mourad
02/23/2024, 1:42 PMparentAnnotated
and ancestorAnnotated
don't seem to return any results for me, I'm using them inside getTopLevelClassIds
of a FirDeclarationGenerationExtension
so supertypes should already be resolved correct? do I need to register the annotation somewhere first?
2. I need to access the resolved body of properties and functions in order to determine the classes i'm generating and their supertypes, none of the functions in the extension runs after BODY_RESOLVE
tho?
Thank you!Zac Sweers
02/24/2024, 8:17 PMTóth István Zoltán
02/25/2024, 6:57 AMinterface Test : Service
And the class I would like to generate:
class Test$Impl : Test { }
I tried to figure out how to use FirDeclarationGenerationExtension
for this but I couldn't. getTopLevelClassIds
is called very early, and I don't know how to figure out which interfaces should I process.
Any pointers? Thanks in advance.eygraber
02/27/2024, 4:18 AMactual
? Happens in 1.9.22 and 2.0 Beta 4.
// common source set
public expect interface FooProvider
public interface FooApp : FooProvider
// Shared source set (jvm, js, wasmJs)
public actual interface FooProvider {
public val foo: Foo
}
class Foo
// separate module targeting wasmJs only (same happens with jvm and js)
public fun <FA : FooApp> fooApp(fooAppFactory: () -> FA) {
fooAppFactory().foo // Unresolved reference: foo only in IDE (runs fine)
(fooAppFactory() as FooApp).foo // no error
}
eygraber
02/27/2024, 10:08 PMprotected property exposes its internal type BarImpl
even though FooImpl
isn't open. Since bar
is protected, only subclasses of FooImpl
could access it, but that isn't possible because FooImpl
is final. So why is there an issue with making FooImpl
public?
abstract class Foo<B : Bar> {
protected abstract val bar: B
}
class FooImpl : Foo<BarImpl> {
override val bar: BarImpl
}
internal class BarImpl : Bar
Norbi
02/28/2024, 9:42 PMhfhbd
02/29/2024, 6:26 AMFirDeclarationGenerationExtension
? This extension contains generateConstructors
.afezeria
02/29/2024, 7:18 AMTóth István Zoltán
03/01/2024, 7:14 AMFirDeclarationGenerationExtension.getCallableNamesForClass
how are these names mixed with the ones from the original source code and the ones generated by other plugins? For example, if the original code have the function already, should I return with the name still?voohbar
03/02/2024, 3:43 AM[WARNING] Lombok Kotlin compiler plugin is an experimental feature. See: <https://kotlinlang.org/docs/components-stability.html>.
I am okay with Lombok being experimental. I need to use it.
However I also want to use
-Werror
Unfortunately, that warning above always trips it up and fails the build. Is there a way to somehow tell the Kotlin compiler that it can ignore this warning? That I am opting int?anlex N
03/02/2024, 1:41 PManlex N
03/03/2024, 3:12 PMhfhbd
03/04/2024, 7:55 AMjessewilson
03/04/2024, 4:26 PMkotlinx.datetime.Instant
in a unit test and my code compiled just fine. What’s happening?
Here’s the file that incorrectly compiles, and a screenshot showing that IntelliJ doesn’t mind that I forgot the import.Tóth István Zoltán
03/05/2024, 11:28 AMLazar Prijović
03/05/2024, 12:41 PMkotlin { wasmWasi { ... }}
configuration), and I don't want to run kotlin-js
directly from the bash.
Sorry if it was asked here before, I couldn't find it in READMEs or by Slack search.Manuel Wrage
03/07/2024, 9:53 AMjava.lang.NoClassDefFoundError: kotlinx/serialization/json/JsonKt
Compilation works fine for jvm and js targets.
Any idea how I can fix this?
Basically it seems that none of my compiler plugin dependencies are on the classpath for native compilation.anlex N
03/09/2024, 8:55 AMJRE
is bigger and bigger, I don't like. what do you think so?Zac Sweers
03/11/2024, 1:30 AMIrClass.superTypes
list all supertypes or just the directly declared supertypes list? I assume it’s the former but wanted to confirmOla Adolfsson
03/12/2024, 1:39 PM@file:JsExport
import kotlin.js.JsExport
import kotlin.js.JsName
@JsExport
interface ActionCandidate {
@jsName "blargh"
fun blargh()
}
reactormonk
03/13/2024, 3:53 PMString
stuff.ansman
03/14/2024, 8:06 PMclass Super<T1, T2>
data class Child<T : Super<String, Child<T>>>(val foo: String)
fun foo(child: Child<*>) {
child.foo
}
This fails to compile with an error on child.foo
saying:
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public final val foo: String defined in com.example
natario1
03/14/2024, 8:39 PMIrPluginContext.referenceClass(ClassId)
returns null. The class is a public class provided by a dependency. Any hint on how to fix this?