parth
10/13/2021, 4:34 PMspierce7
10/13/2021, 5:17 PMIDEs are currently unable to detect KSP-generated declarations on the fly,Does t his mean even after building we still can’t see the generated sources and reference them in code?
jameskleeh
10/13/2021, 6:48 PMeygraber
10/14/2021, 1:53 PMAdrien Poupard
10/22/2021, 9:18 AMevant
10/24/2021, 8:08 PMevant
10/24/2021, 8:16 PMevant
10/24/2021, 8:21 PMAlexandru Hadăr
10/26/2021, 7:25 PMw: [ksp] Unable to process:com.sample.demo.DemoAnnotationProcessor: DemoClass;Foo
IS there any command to see more details about why it’s not working ?elihart
10/27/2021, 2:26 AMCaused by: java.lang.IllegalArgumentException: EpoxyModel<*> is not a sub type of the class/interface that contains `equals` (EpoxyModel)
at com.google.devtools.ksp.processing.impl.ResolverImpl.computeAsMemberOf(ResolverImpl.kt:972)
at com.google.devtools.ksp.processing.impl.ResolverImpl.asMemberOf$compiler_plugin(ResolverImpl.kt:954)
at com.google.devtools.ksp.symbol.impl.java.KSFunctionDeclarationJavaImpl.asMemberOf(KSFunctionDeclarationJavaImpl.kt:124)
at androidx.room.compiler.processing.ksp.KSAsMemberOfKt.typeAsMemberOf(KSAsMemberOf.kt:67)
at androidx.room.compiler.processing.ksp.KspExecutableParameterElement$type$2.invoke(KspExecutableParameterElement.kt:44)
at androidx.room.compiler.processing.ksp.KspExecutableParameterElement$type$2.invoke(KspExecutableParameterElement.kt:43)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at androidx.room.compiler.processing.ksp.KspExecutableParameterElement.getType(KspExecutableParameterElement.kt:43)
at androidx.room.compiler.processing.ksp.KspExecutableParameterElement.getType(KspExecutableParameterElement.kt:26)
This happens when I access a certain`XVariableElement.type` , which is a parameter of a function inside my EpoxyModel<T> class. There seems to be a bug with how the generics are handled, but I can’t tell if it is something XProcessing is doing wrong or KSP itself.
What is strange is that when ResolverImpl.computeAsMemberOf
fails the check for containing.kotlinType.isSubtypeOf(functionDeclaredIn)
it doesn’t consider EpoxyModel<*>
as a subclass of EpoxyModel
. I have tried to reproduce this in a unit test, and can’t so far, because other cases like ArrayList<*>
vs ArrayList
work fine.
Digging deeper into it, the isSubtypeOf
function ends up comparing two LazyJavaClassDescriptor
instances representing the same class, but that type doesn’t seem to implement “equals” so because they are different instances the check fails.natario1
10/27/2021, 10:46 AMbuild/generated/ksp
is empty. Does anyone know how to debug this issue?
I tried to run the ksp task with --info, but did not get anything useful. Using room 2.3.0 and ksp 1.5.31-1.0.0, which might be a mismatch but I'd expect the build to fail then?jameskleeh
10/27/2021, 1:34 PMAlexandru Hadăr
10/27/2021, 3:20 PMoverride fun process(resolver: Resolver): List<KSAnnotated> {
val time = System.currentTimeMillis()
logger.warn("Running $time")
codeGenerator.createNewFile(
dependencies = Dependencies.ALL_FILES,
packageName = "sample.demo",
fileName = "File_$time"
).close()
return emptyList()
}
elihart
10/28/2021, 8:36 PMList<out T>
it should be covariant, and javac processors view it that way, but KSP reports the argument as invariant. I have a repro using xprocessing. I don’t think it is a problem within xProcessing because the debugger shows the originating KSTypeImpl
to have an invariant argument
@Test
fun testListVariance() {
val libSource = Source.kotlin(
"lib.kt",
"""
class KotlinClass {
fun foo(list: List<CharSequence>) {}
}
""".trimIndent()
)
runProcessorTest(listOf(libSource)) { invocation ->
val clazz = invocation.processingEnv.requireTypeElement("KotlinClass")
val param = clazz.getDeclaredMethods().single().parameters.single()
if (invocation.isKsp) {
expectThat(param.type.typeName.toString())
.isEqualTo("java.util.List<java.lang.CharSequence>")
} else {
expectThat(param.type.typeName.toString())
.isEqualTo("java.util.List<? extends java.lang.CharSequence>")
}
}
}
russhwolf
10/29/2021, 3:01 PMelihart
10/29/2021, 8:03 PMgetSymbolsWithAnnotation
.Grégory Lureau
10/30/2021, 8:51 PMVaios Tsitsonis
11/01/2021, 5:44 PMelihart
11/01/2021, 9:29 PMarnaud.giuliani
11/02/2021, 11:17 AMsalomonbrys
11/03/2021, 9:21 AMkspTestKotlinJvm
(the SP is supposed to be applied on test sources), generation happens normally and build/generated/ksp/jvmTest/kotlin
is properly populated.
However, if I run kspTestKotlinJvm
a second time (without changing anything), all generated files are removed and build/generated/ksp/jvmTest
is left empty (which of course makes the compilation fail).
I’ve tracked it down to this gradle configuration:
sourceSets {
val jvmTest by getting {
kotlin.srcDir("build/generated/ksp/jvmTest/kotlin")
}
}
So, the fact that I add the generated sources as a sourceset makes KSP remove them ?!?Zac Sweers
11/03/2021, 5:34 PMPaul Woitaschek
11/04/2021, 7:38 AMkotlinx.coroutines.flow.Flow
. When entering visitFunctionDeclaration
is there any way to get the complete return type? (not only "Flow")?
The only solution I have found so far is to call:
function.returnType?.resolve()?.declaration?.qualifiedName?.asString()
but that would force me to resolve just all functions which is documented as "expensive". Is there a way to do it without resolving all functions?Paul Woitaschek
11/04/2021, 10:15 AMprocess
, resolver.getAllFiles()
is only returning the changed files. What can cause this?elect
11/05/2021, 2:49 PMMaik
11/08/2021, 12:37 PM@ClassID
val classID: Long = 0x180
I found the expression easily using getSymbolsWithAnnotation
and was able to find out several things, such as the type of the property and its name. The only thing I could not determine was the actual value of the getter 0x180
.
Is this possible in principle with ksp and how would one solve this problem?
I would be grateful for any hints or advice on how to solve this!Paul Woitaschek
11/09/2021, 2:26 PMPaul Woitaschek
11/10/2021, 10:29 AMPaul Woitaschek
11/10/2021, 11:28 AMPaul Woitaschek
11/11/2021, 8:28 AMPaul Woitaschek
11/11/2021, 8:28 AMBig Chungus
11/11/2021, 9:16 AMPaul Woitaschek
11/11/2021, 9:16 AMBig Chungus
11/11/2021, 9:17 AMPaul Woitaschek
11/11/2021, 9:19 AMBig Chungus
11/11/2021, 9:21 AMPaul Woitaschek
11/11/2021, 9:22 AMBig Chungus
11/11/2021, 9:22 AMPaul Woitaschek
11/11/2021, 9:23 AMBig Chungus
11/11/2021, 9:24 AMPaul Woitaschek
11/11/2021, 9:29 AMBig Chungus
11/11/2021, 9:30 AM{
"path/to/source.kt": "path/to/geterated.swift"
}
elect
11/11/2021, 10:10 AMGrégory Lureau
11/11/2021, 1:23 PMPaul Woitaschek
11/11/2021, 1:25 PMGrégory Lureau
11/11/2021, 1:25 PMPaul Woitaschek
11/11/2021, 1:37 PM> Task :lifecycle:kspKotlinMetadata FAILED
e: Source file or directory not found: /home/paul/repos/yazio/shared/lifecycle/build/generated/ksp/commonMain/kotlin
This is happening when only swift files are generated but no kotlin files for the moduleelect
11/11/2021, 4:11 PMPaul Woitaschek
11/11/2021, 4:11 PMelect
11/11/2021, 4:11 PMglureau
11/11/2021, 4:54 PMPaul Woitaschek
11/11/2021, 5:20 PMGrégory Lureau
11/11/2021, 7:33 PMPaul Woitaschek
11/19/2021, 7:34 AManyway, cool experiments Paul, keep us updatedKeeping you updated 😉 https://medium.com/@woitaschek/kotlin-native-using-swift-not-objective-c-d7742c040539
Grégory Lureau
11/19/2021, 7:49 AMPaul Woitaschek
11/19/2021, 7:51 AMGrégory Lureau
11/19/2021, 8:01 AM