pajatopmr
01/22/2021, 1:05 AMSasha Shpota
01/24/2021, 4:01 PMtschuchort
01/26/2021, 4:38 PMjavaSourceRoots
compiler option. Both KaptOptions
and K2JVMCompilerArguments
have a javaSourceRoots
member. So far I have been passing both paths to Kotlin source files and Java source files as K2JVMCompilerArguments.freeArgs
to the compiler and it has worked fine for the most part. Now we have noticed a problem that nested classes in Java sources can not be resolved by compiler plugins. This problem seems to go away when javaSourceRoots
is set to the parent directory where the Java source files are located, but not when paths to the Java source files directly are added to javaSourceRoots
.
1. Why can we give the compiler direct paths to Kotlin files but all the Java files have to be located in the same directory? We can see that the same parameter in KaptOptions
accepts paths to files and not to a parent directory: https://github.com/JetBrains/kotlin/blob/e2521718ddef33d25158032dee649b1fa6f5b73a/[…]t3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/Kapt3Plugin.kt
2. Why is this option needed at all? The K2JVMCompiler
is able to find and compile Java sources without it, but apparently not nested classes?Jan Skrasek
01/27/2021, 7:55 AMallWarningsAsErrors
or explicitApi()
. Or at least some lint anywhere? Thanks.gammax
01/29/2021, 5:40 PMcompiler-embeddable
.
I would like to get some opinions on it, understand if it’s a bug, where to report it and eventually push a fix upstream. The issue happened on one of our #detekt rule (here the patch on our end)
The snippet to reproduce is:
import com.sample.function.from.outside
fun test() {
val a = outside()
val b = a?.plus(42)
}
If the external function is not provided during the compilation, the Kotlin compiler is raising an UNNECESSARY_SAFE_CALL
on a?.plus
.
The type of a
is org.jetbrains.kotlin.types.ErrorType
.
My hunch is that the compiler should not report this error if they information on the type is missing.Karlo Lozovina
02/01/2021, 4:01 PMprivate fun getUriForCommand() = URI(
when (this) {
is FooBar -> "<http://www.google.hr>"
}
)
which seems to crash the compiler e: org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression at
Could this be a compiler bug?Michal Harakal
02/02/2021, 6:51 PMval price = """${'$'}9.99"""
?
My use case would be embedding of "kotlin source code as string" in custom DSL(similar to kotlinx.html
tag sunsafe {raw { """ Kotlin/Any Language code snippet here """}})
kevin.cianfarini
02/03/2021, 11:16 PMMarc Knaup
02/04/2021, 6:33 PMwasyl
02/05/2021, 8:49 AMfun test() {
var foo: Foo? = Foo()
println(foo)
runBlock { foo = null }
}
private fun runBlock(block: () -> Unit) {
block()
}
class Foo
So I have var foo
, which I use in println()
and then null it out in another lambda. The compiler generates the following (decompiled) code:
final ObjectRef foo = new ObjectRef();
foo.element = new Foo();
Foo var2 = (Foo)foo.element;
boolean var3 = false;
System.out.println(var2);
Note the Foo var2 = (Foo)foo.element;
which is used in println
. It is somewhat unexpected, e.g. if Foo
is heavy I may want it to be GC-ed after foo = null
is executed. It won’t be, because var2
is keeping it. Why is necessary that var2
exists, and would it make sense to clear it after it’s used?Marc Knaup
02/05/2021, 10:04 AMPRE_RELEASE_CLASS
due to a bug in Kotlin 1.4.30.
(It builds just fine with Gradle)Endre Deak
02/12/2021, 12:54 AM./gradlew build
Configuration on demand is an incubating feature.
> Task :ServerCommon:kaptGenerateStubsKotlin FAILED
e: org.jetbrains.kotlin.util.ReenteringLazyValueComputationException
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ServerCommon:kaptGenerateStubsKotlin'.
> Internal compiler error. See log for more details
how can I get into the details? It’s a JVM project, using kotlin and java as well.Marc Knaup
02/12/2021, 1:00 PMMarc Knaup
02/12/2021, 2:08 PMval umbrella = <svg xmlns="<http://www.w3.org/2000/svg>" viewBox="0 0 40 40"><path d="M21.172,2.4V0H18.828V2.4C8.063,2.933,0,10.857,0,21.172V23.06l1.694-.839a11.586,11.586,0,0,1,4.243-1.049c1.512,0,3.3,1.445,3.86,2l.829.819.826-.819c.561-.556,2.348-2,3.86-2a6.366,6.366,0,0,1,3.516,1.689V36.484a3.516,3.516,0,0,0,7.031,0V34.141H23.516v2.344a1.172,1.172,0,1,1-2.344,0V22.861a6.366,6.366,0,0,1,3.516-1.689c1.512,0,3.3,1.445,3.86,2l.829.819.826-.819c.561-.556,2.426-2,3.938-2a10.963,10.963,0,0,1,4.165,1.049l1.695.84V21.172C40,10.857,31.937,2.933,21.172,2.4Z"/></svg>
That could be converted into kotlinx-html
or React code.Fudge
02/23/2021, 8:17 AMDrew Hamilton
02/23/2021, 12:56 PMIrSimpleFunctionSymbol
being bound (or not bound)? In particular, if it is being referenced so that it can be called in a generated function, is it meant to be bound to the same IrFunction
that it represents, or to the IrFunction
that is calling it?Youssef Shoaib [MOD]
02/25/2021, 9:38 PMIrFunctionExpressionImpl
with a function build using context.irFactory.buildFun
but it's giving me issues about the parent. If I try to set the parent to the containing function (i.e. the function that the inline function is called from), it gives me an error saying "unexpected parent functionName". I'm guessing that there's probably something specific that I need to put for the parent but I'm not entirely sure what it is.Liyue
03/02/2021, 9:41 AMValueParameterDescriptor
, but when the function comes from a class file, it doesn't work.
fun parseKtCallExpr(callExpr: KtCallExpression, bindingContext:BindingContext){
val resolvedCall = callExpr.getResolvedCall(bindingContext)
val defaultParam : ValueParameterDescriptor = resolvedCall.valueArguments[0].key // Suppose it has defaultvalue
defaultParam.findPsi() as? KtParameter)?.defaultValue // it works only when function come from code.
}
Is there any way to get it? Thanks.pajatopmr
03/02/2021, 4:01 PMrnett
03/04/2021, 3:03 AMMichal Harakal
03/05/2021, 4:01 PMkotlinc hello.kt -include-runtime -Xplugin=kotlin-ir-plugin-0.1.0-SNAPSHOT.jar -Xuse-ir -d hello.jar
But I am gettng error
java.lang.IllegalStateException: The provided plugin com.bnorm.template.TemplateComponentRegistrar is not compatible with this version of compiler
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:592)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.registerExtensionsFromPlugins(KotlinCoreEnvironment.kt:132)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:172)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:426)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:226)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:152)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
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.cli.common.CLITool.exec(CLITool.kt:76)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:45)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:227)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit$default(CLITool.kt:222)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:214)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:271)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.jetbrains.kotlin.preloading.Preloader.run(Preloader.java:87)
at org.jetbrains.kotlin.preloading.Preloader.main(Preloader.java:44)
Caused by: java.lang.AbstractMethodError: Receiver class com.bnorm.template.TemplateComponentRegistrar does not define or inherit an implementation of the resolved method 'abstract void registerProjectComponents(com.intellij.mock.MockProject, org.jetbrains.kotlin.config.CompilerConfiguration)' of interface org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar.
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:584)
... 23 more
Jar file for plugin has been built with gradle from template project by @bnorm https://blog.bnorm.dev/writing-your-second-compiler-plugin-part-1 and units tests are runnign as expected.Brady Aiello
03/08/2021, 8:10 PMAllOpenVisibilityTransformer
is a DeclarationAttributeAltererExtension
. But it looks like All Open only works because DeclarationAttributeAltererExtension
is registered in KotlinCoreEnvironment. I'm wondering if there's a way for a user to register a plugin extension point, or if it's gotta go into KotlinCoreEnvironment
, meaning making changes to the compiler itself? For the latter, I'd just want to add a few more methods to DeclarationAttributeAltererExtension
so it could do more than change modality, specifically, changing visibility through a compiler plugin.PHondogo
03/09/2021, 8:31 AMAbel
03/10/2021, 4:45 PMralf
03/15/2021, 1:16 AMmbonnin
03/15/2021, 6:38 PMinternal
classes from a library I have no control over? Or is that forever forbidden?Michal Harakal
03/16/2021, 2:02 PMSyntheticResolveExtension
is executed as a part of analysis phase, in frontend. Which block in your diagram in https://kotlinlang.slack.com/archives/C7L3JB43G/p1615394755006000 is responble for its execution? Do I have the complete PSI with BindingContex?Jonathan Gerrish
03/16/2021, 6:00 PMKotlinCompileDaemonBase
... so I'm assuming so? Background - we are implementing Multiplex worker support for the Bazel Kotlin rules which means a single process will handle multiple concurrent compilation requests so I want to be sure if and how instances should be shared or isolated. Thanks in advance 🙂Youssef Shoaib [MOD]
03/21/2021, 5:39 PMlet
from the standard library), compile that as part of the normal code compilation, and then access it's body in IR? I just need a way to inspect inside the code of a function coming in from a different compilation unit in IR instead of having to look into its bytecode. Even if it is a copy of the function and not 100% what the function itself is that's still absolutely fine because I just need to read through it's IR without editing it, and so it's fine with me if I'm taking it's source files and compiling just the ones with the functions that I need to read that IR. So yeah is there any way to get a library's included sources and compile that?Peter
03/23/2021, 3:17 PMval dmat = DMatrix(features, features.size, 1, -1.0f)
dmat.label(labels) // generates compiler error
dmat.setLabel(labels) // works fine
The complier error is:
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public operator fun <T, R> DeepRecursiveFunction<TypeVariable(T), TypeVariable(R)>.invoke(value: TypeVariable(T)): TypeVariable(R) defined in kotlin
Anyone knows what is causing this behavior?Peter
03/23/2021, 3:17 PMval dmat = DMatrix(features, features.size, 1, -1.0f)
dmat.label(labels) // generates compiler error
dmat.setLabel(labels) // works fine
The complier error is:
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public operator fun <T, R> DeepRecursiveFunction<TypeVariable(T), TypeVariable(R)>.invoke(value: TypeVariable(T)): TypeVariable(R) defined in kotlin
Anyone knows what is causing this behavior?Iaroslav Postovalov
03/23/2021, 4:17 PMdmat.label = labels
is correct?Peter
03/23/2021, 8:54 PM