charleskorn
05/08/2021, 1:21 AMe: java.lang.IllegalStateException: not identifier: <init>
errors while compiling (example). Is this a known issue?Daniel Kuschny
05/08/2021, 1:14 PMZac Sweers
05/08/2021, 6:44 PM-Xextended-compiler-checks
?Youssef Shoaib [MOD]
05/08/2021, 7:12 PM@Suppress("REDECLARATION")
but I'm wondering if maybe there's a better way to do that (like a custom call resolved I guess) and if eventually this trick will be completely disallowedYoussef Shoaib [MOD]
05/08/2021, 7:49 PMdimitar_
05/13/2021, 4:17 PMprintln("I'm here");
I can compile the class and when I try to use kotlinc
to compile another class that calls the generated function, I get:
kotlinc -classpath . test.kt
test.kt:2:10: error: unresolved reference: generatedFunction
Main().generatedFunction()
But when I do the same with javac
, everything is ok.
I can also run the class and I get the desired output
java Test
I'm here
Any pointers would be highly appreciated 🙂
p.s. Is there any documentation about writing compiler plugins with IR out there?dimsuz
05/15/2021, 12:07 PMclass Builder {
fun <R> build(action: (R) -> R): Builder = this
}
fun main() {
val value = 3
Builder()
.build { value } // compiler error: not enough information to infer type variable R
}
That is: lambda is returning Int
therefore R
is Int
UPD: this is kotlin 1.5.0rnett
05/16/2021, 12:04 AMTristan Blakers
05/16/2021, 2:18 PMandi
05/16/2021, 3:39 PMChar
, Byte
, Short
, Int
, Long
, Float
and Double
. And for all other types, it will fallback to Int. However CompareTo
is registered for all possible combinations of primitives, hence also for Boolean::compareTo(Boolean).
I'm unsure if there is a smart trick/optimization behind using kotlin.jvm.internal.Intrinsics::compare(Int, Int)
also for Boolean::compareTo(Boolean)
?Rob Elliot
05/17/2021, 7:56 AM@JvmSynthetic
to internal
members to properly hide them from Java:
https://medium.com/scalereal/hide-internal-members-of-kotlin-module-from-jvm-c7730507fb17
which informed me of @JvmSynthetic
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-synthetic/
which in turn led me to ACC_SYNTHETIC
https://docs.oracle.com/javase/specs/jvms/se15/html/jvms-4.html
Is there a reason why the compiler with the JVM backend doesn’t just add the ACC_SYNTHETIC
access_flag to internal
methods without needing to add the noise of an extra annotation?Strum355
05/19/2021, 7:23 PMDominaezzz
05/23/2021, 9:50 AMgroostav
05/23/2021, 10:37 PMx*y^z + cos(f)
I want to translated into smt-lib2). I've read the compilers book in school and have used ANTLR professionally for some time, and I can probably hack this out with an antlr visitor and creating classes as the occur to me along with a good whack of string mangling, but I'm willing to bet somebody smarter than me has some nice compiler/code-generator tutorials/tools that would make my life a fair bit easier.
Has anybody here done something similar and have some suggested reading?rnett
05/23/2021, 11:18 PMNoClassDefFoundError
errors) trying to use a library in a native compiler plugin (i.e. using kotlin-compiler
instead of kotlin-compiler-embeddable
. Said library also uses kotlin-compiler
, and I'm depending on it using implementation
, which works fine for the non-native compiler plugin, but when I try to use something from the library in the native plugin I get NoClassDefFoundError
. Do I need to shade it in myself?evanchooly
05/25/2021, 8:55 PMJan Skrasek
05/28/2021, 7:11 AMinternal
modifier cause some optimized compilation in a way that compiler knows it isn't used from other dependent modules and skips the check "in them"?raulraja
05/31/2021, 1:55 PMorg.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar
and looking into how to integrate with plugins that depend on org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
and org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
. I see AllOpen
and others are connected to the new FIR frontend and I was hoping to run some compiler plugin tests and work on the FIR support for arrow meta. I have a couple of questions that came up while I was working on this. Here it goes in case anyone can help.
1. The FirExtensionRegistrar
unlike the ComponentRegistrar
is not an interface but an abstract class and it requires a separate lifecycle. Once instantiated for regular CLI plugins and another for the FIR style of subscription. Did I miss-understood this or is there a way to integrate this with existing compiler plugins based on the ComponentRegistrar
?
2. Even when declaring both of those extensions and enabling FIR with configuration.put(CommonConfigurationKeys.USE_FIR, true)
the override for the FIR plugin`override fun ExtensionRegistrarContext.configurePlugin(): Unit` never gets called, Is there something else needed to enable FIR beside that flag?
If anyone has had success testing the FIR extension points or could provide any guidance or example as to how to enable them I’d very much appreciate it. Thanks!dmitriy.novozhilov
05/31/2021, 4:24 PMscaventz
06/03/2021, 1:25 PMfun interface Foo : () -> Unit
fun interface Foo1 : Foo
fun interface Foo2 : Foo
fun test(foo: Foo2) {
println(foo)
}
fun main() {
val instance = object : Foo1 {
override fun invoke() {
}
}
test(instance) // is this allowed by design?
}
Maybe I'm not smart enough to understand why this is allowed, it makes me feel confused, is there any particular reason to support this behavior?Peter
06/03/2021, 6:01 PMclass Dummy {
// Define as read-only access map
private val buffers: Map<String, String>
init {
buffers = mutableMapOf()
// Unexpected, no error
buffers["test"] = "hello"
}
fun dummy2() {
// Not allowed, as expected
buffers["test"] = "hello"
}
}
CLOVIS
06/11/2021, 3:25 PMkotlin("js")
plugin, 1.5.10, Kotlin DSL, and I want to change the default timeout.
js {
browser {
testTask {
useKarma {
useChromiumHeadless()
timeout.set(??)
}
}
}
}
According to the Gradle documentation:
task myTask {
// java.time.Duration
timeout = Duration.ofMinutes(10)
}
However if I add write:
timeout.set(java.time.Duration.ofMinutes(10))
Then IntelliJ & Gradle complain with Unresolved reference: time
timeout
doesn't have any overloads that would accept kotlin.Duration
or even groovy.Duration
. Is it even possible currently to set the timeout with the Kotlin DSL?mcpiroman
06/15/2021, 7:23 AMJorge Castillo
06/19/2021, 1:52 PMMarcello Lelio Albano
06/19/2021, 4:51 PMBen Dodson
06/24/2021, 4:31 PMprivate typealias
, and then use that alias in a public method. This seems to work in Gradle, but not in our Bazel setup. My main question is, is this valid code and a bug in our Bazel setup, or should we not expose a private typealias in a public api?themarketka
06/27/2021, 7:08 PMdata class MapObjects(
val map: com.google.android.gms.maps.GoogleMap,
val markerManager: com.google.maps.android.collections.MarkerManager,
val markerCollection: com.google.maps.android.collections.MarkerManager.Collection,
)
The MarkerCollection.Collection
is a Java nested/inner class, not a static one.
After the update to Kotlin 1.5.20 (keeping runtime dependencies on 1.5.0), it compiles, but IDE complains about code like this:
val mapObjs: MapObjects = mapObjects // lateinit var access
mapObjs.markerCollection.clear()
Basically anything accessing the markerCollection
shows Internal Error occurred while analyzing this expression
. I reported it from within IDE already.
Funny detail though: when I update runtime dependency to 1.5.20, it outright crashes while compiling: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during file facade code generation
. Based on that I do not believe it’s related to Android Studio in particular.
Please send help, and if I should, include where/how do I file this in the Kotlin’s issue tracker at https://youtrack.jetbrains.com/issues/KT.dimsuz
06/28/2021, 11:11 AMinline class InlinePayload(val id: String)
fun <T> test(t: T): T {
return t
}
val (p1, p2) = listOf(test(3))
.zip(
listOf(test(InlinePayload("a"))), // (1)
::Pair)
.first()
println(p2.id) // (2) EXCEPTION!
It seems that (1)
creates a List<String>
rather than List<InlinePayload>
and then (2)
crashes with
class java.lang.String cannot be cast to class ru.example.app.InlinePayload (java.lang.String is in module java.base of loader 'bootstrap'; ru.example.app.InlinePayload is in unnamed module of loader 'app')
Strum355
06/29/2021, 1:26 PMDeserializedTypeAliasDescriptor
, it brings me to the decompiled class file. Meanwhile a symbol search gives the correct Kotlin source file DeserializedMemberDescriptor.kt
. Any ideas? I have compileOnly(kotlin("compiler-embeddable"))
in my gradle file, and relocate("com.intellij", "<http://org.jetbrains.kotlin.com|org.jetbrains.kotlin.com>.intellij")
when creating a JAR, but I dont believe that is relevant here as the package name is the same in both source and class file.Strum355
06/29/2021, 5:56 PMbuild.gradle.kts
file in order to test my compiler plugin (without the more "recommended" route of creating a gradle plugin), but Im not seeing it working for multi-project gradle projects. The plugin seems to only get invoked for a single sub-project, as per the screenshot only displaying output mentioning the sub-project with a single Kotlin file (I am printing out the list of KtFile virtualPath in the analysisCompleted
method). Project can be found here https://github.com/Strum355/lsif-kotlin (the snippet below would be in the root build.gradle.kts
)
allprojects {
tasks.withType<KotlinCompile> {
val targetroot = File(this@allprojects.buildDir, "semanticdb-targetroot")
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf(
"-Xplugin=/home/noah/Sourcegraph/lsif-kotlin/semanticdb-kotlinc-1.0-SNAPSHOT-all.jar",
"-P",
"plugin:com.sourcegraph.lsif-kotlin:sourceroot=${this@allprojects.projectDir.path}",
"-P",
"plugin:com.sourcegraph.lsif-kotlin:targetroot=${targetroot}"
)
}
}
}