PHondogo
09/12/2022, 8:05 PMPhilip Graf
09/13/2022, 7:37 AMdata class Pet(val names: @get:NonNull List<@get:NonNull String>)
to compile to
public getNames()Ljava/util/List;
@Lorg/eclipse/microprofile/graphql/NonNull;() : METHOD_RETURN, null
@Lorg/eclipse/microprofile/graphql/NonNull;() : METHOD_RETURN, 0;
However, if I compile the data class above, I get two compile errors for each annotation:
- This annotation is not applicable to target 'undefined target' and use site target '@get'
- This annotation is not applicable to target 'type usage' and use site target '@get'
The NonNull annotation is from the Java library microprofile-graphql-api:
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
@Documented
public @interface NonNull {
}
If I put the annotion on the constructor argument
data class Pet(@get:NonNull val names: List<String>)
then it compiles to
public final getNames()Ljava/util/List;
@Lorg/eclipse/microprofile/graphql/NonNull;()
as I would expect.
Is it not possible to use use-site targets on types and type parameters? Is this a limitation/future feature/bug of the compiler? Or is the annotation missing a target (it has the target TYPE_USE)?smallshen
09/14/2022, 5:04 AMigor.wojda
09/15/2022, 8:58 AMorg.jetbrains.kotlin:kotlin-compiler
to parse Kotlin files.
I wonder is this lib intended also for file creation? I have a few parsed files (KtFile
) and I wonder if I can merge them - take imports, some top level members and create a new KtFile
(that will be eventually saved to a disk)
I wonder is it possible to take a KtFile
as source for KtFile
? (initial ktfiles where created by parsing real kotlin from files from disk)nikolaymetchev
09/15/2022, 2:32 PMjava.lang.AssertionError: Number of arguments should not be less than number of parameters, but: parameters=3, args=2
at org.jetbrains.kotlin.types.IndexedParametersSubstitution.<init>(TypeSubstitution.kt:115)
at org.jetbrains.kotlin.types.IndexedParametersSubstitution.<init>(TypeSubstitution.kt:109)
at org.jetbrains.kotlin.types.IndexedParametersSubstitution.<init>(TypeSubstitution.kt:123)
at org.jetbrains.kotlin.types.TypeConstructorSubstitution$Companion.create(TypeSubstitution.kt:95)
at org.jetbrains.kotlin.types.KotlinTypeFactory.computeMemberScope(KotlinTypeFactory.kt:57)
at org.jetbrains.kotlin.types.KotlinTypeFactory.simpleType(KotlinTypeFactory.kt:90)
at org.jetbrains.kotlin.types.KotlinTypeFactory.simpleType$default(KotlinTypeFactory.kt:77)
at org.jetbrains.kotlin.serialization.deserialization.TypeDeserializer.simpleType(TypeDeserializer.kt:127)
at org.jetbrains.kotlin.serialization.deserialization.TypeDeserializer.type(TypeDeserializer.kt:69)
at org.jetbrains.kotlin.serialization.deserialization.MemberDeserializer.loadFunction(MemberDeserializer.kt:218)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberScope$OptimizedImplementation.computeFunctions(DeserializedMemberScope.kt:276)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberScope$OptimizedImplementation.access$computeFunctions(DeserializedMemberScope.kt:228)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberScope$OptimizedImplementation$functions$1.invoke(DeserializedMemberScope.kt:251)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberScope$OptimizedImplementation$functions$1.invoke(DeserializedMemberScope.kt:251)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:578)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunctionToNotNull.invoke(LockBasedStorageManager.java:651)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberScope$OptimizedImplementation.getContributedFunctions(DeserializedMemberScope.kt:329)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberScope.getContributedFunctions(DeserializedMemberScope.kt:82)
at org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor$DeserializedClassMemberScope.getContributedFunctions(DeserializedClassDescriptor.kt:315)
at org.jetbrains.kotlin.resolve.scopes.SubstitutingScope.getContributedFunctions(SubstitutingScope.kt:84)
at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassMemberScope.getNonDeclaredFunctions(LazyClassMemberScope.kt:295)
at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope.doGetFunctions(AbstractLazyMemberScope.kt:103)
at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope.access$doGetFunctions(AbstractLazyMemberScope.kt:38)
at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope$functionDescriptors$1.invoke(AbstractLazyMemberScope.kt:51)
at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope$functionDescriptors$1.invoke(AbstractLazyMemberScope.kt:51)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:578)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunctionToNotNull.invoke(LockBasedStorageManager.java:651)
at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope.getContributedFunctions(AbstractLazyMemberScope.kt:97)
at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassMemberScope.getContributedFunctions(LazyClassMemberScope.kt:280)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver$resolveToDescriptor$1.visitNamedFunction(LazyDeclarationResolver.kt:125)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver$resolveToDescriptor$1.visitNamedFunction(LazyDeclarationResolver.kt:94)
at org.jetbrains.kotlin.psi.KtNamedFunction.accept(KtNamedFunction.java:51)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.resolveToDescriptor(LazyDeclarationResolver.kt:94)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.resolveToDescriptor(LazyDeclarationResolver.kt:91)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.createFunctionDescriptors(LazyTopDownAnalyzer.kt:284)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations(LazyTopDownAnalyzer.kt:206)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations$default(LazyTopDownAnalyzer.kt:58)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:130)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:99)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:264)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:55)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:255)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:101)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:60)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:157)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:94)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:477)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:127)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:366)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:311)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.rebuild(IncrementalCompilerRunner.kt:110)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:200)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:75)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:625)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:101)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1739)
at jdk.internal.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
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)
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)
Charlie Brown
09/16/2022, 2:03 AMstatic {
samTwo = (SamTwoArg)null.INSTANCE;
}
Here is my original code (from Atomic Kotlin book)
package interfaces
import atomictest.eq
fun interface SamTwoArg {
fun h(i: Int, j: Int): Int
}
val samTwo = SamTwoArg { i, j -> i + j }
fun main() {
samTwo.h(11, 47) eq 58
}
Here is decompiler result:
// SamTwoArg.java
package interfaces;
import kotlin.Metadata;
@Metadata(
mv = {1, 5, 1},
k = 1,
d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\bæ\u0080\u0001\u0018\u00002\u00020\u0001J\u0018\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u0003H&¨\u0006\u0006"},
d2 = {"Linterfaces/SamTwoArg;", "", "h", "", "i", "j", "AtomicKotlinCourse.main"}
)
public interface SamTwoArg {
int h(int var1, int var2);
}
// SAMImplementationKt.java
package interfaces;
import atomictest.AtomicTestKt;
import kotlin.Metadata;
import org.jetbrains.annotations.NotNull;
@Metadata(
mv = {1, 5, 1},
k = 2,
d1 = {"\u0000\u0010\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\u001a\u0006\u0010\u0004\u001a\u00020\u0005\"\u0011\u0010\u0000\u001a\u00020\u0001¢\u0006\b\n\u0000\u001a\u0004\b\u0002\u0010\u0003¨\u0006\u0006"},
d2 = {"samTwo", "Linterfaces/SamTwoArg;", "getSamTwo", "()Linterfaces/SamTwoArg;", "main", "", "AtomicKotlinCourse.main"}
)
public final class SAMImplementationKt {
@NotNull
private static final SamTwoArg samTwo;
@NotNull
public static final SamTwoArg getSamTwo() {
return samTwo;
}
public static final void main() {
AtomicTestKt.eq(samTwo.h(11, 47), 58);
}
// $FF: synthetic method
public static void main(String[] var0) {
main();
}
static {
samTwo = (SamTwoArg)null.INSTANCE;
}
}
PHondogo
09/21/2022, 6:14 AMnatario1
09/23/2022, 9:22 AMval list: List<Pair<String, Any>> = …
val doubles = list.filterIsInstance<Pair<String, Double>>()
filterIsInstance can’t check inner generic types, but this code is clean for both IDE and compiler.PHondogo
09/24/2022, 9:31 AMjava.lang.IllegalStateException: FULL: FIELD name:_GEN_ type:test.EnumTest visibility:internal [final,static]
Ir: test.EnumTest.Companion._GEN_
Descriptor: test.EnumTest.Companion#static{}_GEN_
Stack trace in thread.August Lilleaas
09/24/2022, 6:21 PMclass MyHandler :
RequestHandler<Map<String, String>, String>
{
companion object {
init {
dataSource
println(Intrinsics::class.java)
println(Result::class.java)
println(Session::class.java)
println(::handleUserEmailSearch.toString())
println(Continuation::class.java)
println(Function::class.java)
println(Unit::class.java)
}
}
override fun handleRequest(input: Map<String, String>, context: Context): String {
return serverlessWebResponseDb(dataSource) { dbSess ->
handleUserEmailSearch(dbSess, input["email"])
}
}
}
majindong
09/26/2022, 3:21 AMprivate fun trackableSubClass(
thisDescriptor: ClassDescriptor
): ClassDescriptorImpl = object : ClassDescriptorImpl(
thisDescriptor,
Name.identifier(SUBCLASS_NAME),
Modality.FINAL,
ClassKind.CLASS,
emptyList<KotlinType>(),
thisDescriptor.source,
false,
LockBasedStorageManager.NO_LOCKS
) {
}.apply {
val a = ClassConstructorDescriptorImpl.create(
this,
Annotations.EMPTY,
true,
this.source
)
val b = a.initialize(
emptyList(),
DescriptorVisibilities.PUBLIC,
emptyList(),
)
this.initialize(
// 内部类的成员范围 MemberScope.Empty
MemberScope.Empty,
// 构造方法集合
emptySet(),
b
)
}
mbonnin
09/27/2022, 3:25 PMAugust Lilleaas
09/29/2022, 4:46 PMsuspend
is lost to the Java type system and seems to be compiled into coroutine-friendly code with no type info about it.Javier
10/01/2022, 6:39 PMNorbi
10/04/2022, 8:55 AMKotlinType
representation of an arbitrary type by fully qualified name in AnalysisHandlerExtension.analysisCompleted()
?
Thanks.majindong
10/06/2022, 9:11 AMvineethraj49
10/06/2022, 3:37 PMSean Proctor
10/06/2022, 4:51 PMraulraja
10/07/2022, 2:44 PMIrElement.deepCopyWithSymbol
I can properly clone the entire tree I need but this tree comes with proper offsets that I need to reset to UNDEFINED_OFFSET
. I tried recursively walking the tree and mutating it but offsets are declared as a val
and passed as arguments to most methods in irFactory
.
Is there a way to change the offsets of an existing IR Tree?
Is there a way to clone a tree without the offsets?
Thanks!galex
10/08/2022, 2:15 PM1.8.20-dev-649
and I'm getting a NoClassDefFoundError: com/intellij/psi/PsiElement
error.
Thanks in advance 🙏rkeazor
10/09/2022, 4:39 PMTyler Rockwood
10/11/2022, 2:32 AMdeclarationCheckers
and expressionCheckers
? Once I've collected all of these I need to write the list of jars to a protocol buffer - the current plugin does this in analysisCompleted
- is there a corresponding callback in k2 for when the "checker" is all done? Thanks for any insights 🙂Stefan
10/11/2022, 8:53 AMjava.lang.Class.getGenericSuperclass
) in an Kotlin only setup (reified types and spaces in method names). Where should I report a bug?peekandpoke
10/12/2022, 8:45 AM> Task :shared:api:compileKotlinJs FAILED
e: Could not load module <com.thebase.shared:api> in an attempt to find deserializer for symbol com.thebase.shared.api.finance/FolioModel.BillingAddress.Company|null[0].
When the cache is cleared things start to work again ...Marc Knaup
10/16/2022, 11:16 AM@NoInfer
is no longer working for builder patterns 👀
What’s the status of that annotation? When public? 😄PHondogo
10/17/2022, 8:23 PMCaught an exception trying to connect to Kotlin Daemon:
java.lang.NoSuchFieldError: COMPILE_INCREMENTAL_WITH_CLASSPATH_SNAPSHOTS
What can be wrong?Jesper Åman
10/19/2022, 8:33 PMMichal Fudala
10/20/2022, 9:51 AMkotlinc package1; kotlinc package2; kotlinc package3; ...
in parallel and was able to get rid of the out of memory error.
Are there any better alternatives? Can Gradle help me here?PHondogo
10/20/2022, 12:54 PMfun test(a: Int = <default value calculation>)
And caller
test(if (expr) 10 else <default value calculation> )
It will be good if there was possibility to pass some keyword that is treated as default value that was declared in function. For example:
test(if (expr) 10 else default)
Eduardo López
10/21/2022, 1:35 PMvar stringField: String?
get() = unscoped { data: MyData ->
data.getString()
}
set(value) = scoped { scope: MyScope ->
scope.setString(value)
}
but I'm at a loss as to how to build the lambdas received by `scoped`/`unscoped` in IR. Any hints?