Alireza Ahmadi
04/06/2020, 11:13 AMclass WarnningsExtension(
) : AnalysisHandlerExtension {
override fun analysisCompleted(project: Project, module: ModuleDescriptor, bindingTrace:
BindingTrace, files: Collection<KtFile>): AnalysisResult? {
val diagnostics = bindingTrace.bindingContext.diagnostics
return AnalysisResult.Companion.success(bindingContext, module)
}
}
But, I also want to modify this list like
val newDiagnostics = diagnostics.filter { //myFilter }
And return this result back instead. Is something like this possible? Or is there any extension that allow me to modify diagnostics?Hadi Lashkari
04/10/2020, 3:15 PM./gradlew clean check
, but when I tried it on a simple new android project created by AS, the same tests throw NoSuchMethodException: com.github.hadilq.emptycomposeandroid.TrackableClass.track()
I have to add that it seems the compiler plugin is installed because it compiles without Unresolved ...
, but at the runtime there is no generated method! Any idea would be appreciated. Thank you for your time 🙂rbares
04/12/2020, 3:44 PMplugins/android-extensions-compiler
)? I have a patch ready to fix a major bug but can't find a relevant gradle task or IDEA configuration to run the tests. If I can update these tests I hope to raise a pull request within the weekralf
04/12/2020, 11:07 PM// Original:
@MyAnnotation(values = ["a", "b"]
class MyClass
// Expected:
@MyAnnotation(values = ["a", "b", "c"]
class MyClass
I couldn’t find a hook to do this. I only found ways add a new annotation. Any pointers?rocketraman
04/16/2020, 6:25 PMpublic <T> T deserialize(..., final Type type)
like this:
inline fun <reified T: Set<Any?>> deser(...): T? = deserialize(..., object : TypeToken<T>() {}.type)
and this used to work fine with 1.4-M1 / old inference. However, now I get a runtime error when the java code attempts to return its value to the Kotlin code:
Caused by: java.lang.ClassCastException: class java.util.LinkedHashSet cannot be cast to class java.lang.Void (java.util.LinkedHashSet and java.lang.Void are in module java.base of loader 'bootstrap')
I can "solve" this by explicitly adding the T
type to the deserialize call i.e. deserialize<T>(...)
, but I'm wondering if this is a bug with the new type inference? The compiler does not report any errors if the <T>
is left off.rocketraman
04/17/2020, 7:58 PMfun <T> foo(): T? = "abc" as T
fun main() {
val s: String? = if(false) null else foo()
}
1️⃣ A runtime exception ClassCastException: class java.lang.String cannot be cast to java.lang.Void
2️⃣ A compile-time error due to the type T
of foo
being ambiguous (could be String?
or could be Nothing
)
3️⃣ A compile-time warning that the type of T
was inferred to Nothing
and that is probably not the desired result
4️⃣ An inference of T
to be String?
, so no compile-time or runtime errors
5️⃣ OtherDrew Hamilton
04/20/2020, 8:38 AMprivate companion object
, the Companion
class is compiled as package-private in the bytecode, but the static Companion
field is compiled as public + deprecated in the bytecode. Why is this?
2. Because of this, in the IDE, from a Java call-site, I can can compile and run Object object = DeferredBoolean.Attribute.Companion;
without issue. The Companion
field doesn’t even get a strikethrough, which seems like an IDE bug. Assuming this hasn’t already been fixed in a new IDE version, and depending on the answer to #1, should I file an IDE bug?mattmoore
04/21/2020, 9:55 PMscalac -Xshow-phases
to get something like this:
phase name id description
---------- -- -----------
parser 1 parse source into ASTs, perform simple desugaring
namer 2 resolve names, attach symbols to named trees
packageobjects 3 load package objects
typer 4 the meat and potatoes: type the trees
bjonnh
04/22/2020, 12:14 AMralf
04/23/2020, 11:20 PMdependencies {
kotlinCompilerPluginClasspath project(':myplugin')
}
If I change something in my compiler plugin, then I see that the Kotlin compilation tasks aren’t up to date, because my compiler plugin changed. Good! The problem now is that the incremental compilation kicks in and doesn’t recompile the code in the module, because nothing has changed for the source files individually, only the Kotlin compiler plugin dependency has changed.
Is there a way to recompile a module, if one of its compiler plugins has changed?
(I tested disabling incremental compilation and this fixes the problem. But I’m afraid of the slow compilation long term.)lhwdev
04/28/2020, 1:00 AMorg.jetbrains.kotlin.idea.highlighter.KotlinHighlightingColors
?
I could find it in the kotlin source code, but I don't know how to add the dependency.Ahmed Mourad
05/03/2020, 8:32 PMjdemeulenaere
05/04/2020, 7:22 AMkotlin-compiler
artifact ?melatonina
05/06/2020, 7:29 PMmessageCollector?.report(CompilerMessageSeverity.WARNING, message, HERE)
but using any lower severity level does not produce any output on the console, even if I pass -verbose
as compiler argument. Why? How can I use different severity levels or otherwise print messages to the console from my compiler plugin?PHondogo
05/08/2020, 7:56 PMturansky
05/09/2020, 4:25 PMIrGenerationExtension
?PHondogo
05/10/2020, 9:19 AMPHondogo
05/10/2020, 9:53 PMabstract class TestBase<T> {
suspend fun test(value: T) {
println(doTest(value))
}
protected abstract suspend fun doTest(value: T): T
}
class TestInherit : TestBase<String>() {
override suspend fun doTest(value: String): String {
return value + "/" + value
}
}
@Test
fun test() {
runBlocking {
TestInherit().test("aaa") /* throws exception here java.lang.AbstractMethodError: Receiver class TestInherit does not define or inherit an implementation of the resolved method 'abstract java.lang.Object doTest(java.lang.Object, kotlin.coroutines.Continuation)' of abstract class TestBase. */
}
}
If define TestBase without generic it works ok.
abstract class TestBase {
suspend fun test(value: String) {
println(doTest(value))
}
protected abstract suspend fun doTest(value: String): String
}
class TestInherit : TestBase() {
override suspend fun doTest(value: String): String {
return value + "/" + value
}
}
@Test
fun test() {
runBlocking {
TestInherit().test("aaa") // OK
}
}
Foso
05/12/2020, 8:04 PMPHondogo
05/13/2020, 3:20 PMPHondogo
05/14/2020, 9:08 AMKiryushin Andrey
05/15/2020, 10:54 AMit
parameter in lambdas contained in pairs, lists or other data structures. This code sample
var pair: Pair<Int, (String) -> String> = 2 to { "param $it" }
var pair2: Pair<Int, (String) -> String> = 2 to { p -> "param $p" }
var list: List<(String) -> String> = listOf { "param $it" }
var list2: List<(String) -> String> = listOf { p -> "param $p" }
looks fine to IDE, but fails to compile with the following errors for the lines using it
lambda parameter:
Type inference failed. Expected type mismatch: inferred type is Pair<Int, () -> String> but Pair<Int, (String) -> String> was expected
Unresolved reference: it
Type inference failed. Expected type mismatch: inferred type is List<() -> String> but List<(String) -> String> was expected
Unresolved reference: it
But the compiler is happy with the root-level lambda declarations like this
var func: (String) -> String = { "param $it" }
var func2: (String) -> String = { p -> "param $p" }
Is this a bug or an intended behavior? Are there any workarounds that would make the compiler happy and at the same time keep the code neat (that is, using it
but without full lambda type annotations at usage site)?
I'm using Kotlin 1.3.71 in multiplatform project and can see this both in JVM and JS targets.PHondogo
05/16/2020, 4:26 PMrnett
05/17/2020, 10:21 PMinit
blocks and class methods, references to the property's accessors seem to be replaced with the backing field. Ex:
class Test(@Watch var x: Int){
fun print(){
println("Prop: $x")
}
}
fun main() {
val t = Test(3)
println(t.x)
t.print()
}
The println(t.x)
works fine and prints 3, but the println
in print
prints the backing field. I'm using 1.4-M1. Ideas? I've dumped the IR and there doesn't seem to be any differencesPHondogo
05/17/2020, 10:46 PMrnett
05/18/2020, 3:43 AMclass KlairvoyantResolveExtension() : SyntheticResolveExtension {
override fun generateSyntheticProperties(thisDescriptor: ClassDescriptor, name: Name, bindingContext: BindingContext, fromSupertypes: ArrayList<PropertyDescriptor>, result: MutableSet<PropertyDescriptor>) {
if (!thisDescriptor.hasWatchAnnotation())
return
if(result.any { it.name == Name.identifier(Names.ClassWatcherProp) })
return
with(FrontendReferencer(thisDescriptor.module)) {
val classWatcherDescriptor = SimpleSyntheticPropertyDescriptor(thisDescriptor, Names.ClassWatcherProp, KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, CompositeWatcher, listOf()), visibility = Visibilities.PUBLIC)
result.add(classWatcherDescriptor)
}
}
}
rnett
05/19/2020, 1:47 AMrunIde
task to use the 1.4-M1 Kotlin plugin, which may be part of the reason why). Is there a way to make this work without duplicating a bunch of code in the ide plugin?rnett
05/19/2020, 3:07 AMgenerateSyntheticProperties
in my SyntheticResolveExtension
Dominaezzz
05/19/2020, 5:17 PMe: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't inline method call 'usingConnection' into
I can reproduce it in my project but I'm having trouble making a self-contained reproducer.
I would publish the project but the contents are personal/sensitive (My access tokens are hard coded).
What to do?
I fix the error when I stop taking advantage of contracts in suspend methods.
// Breaks compiler
val value: String
withContext(...) {
value = loadFromDb()
}
println(value)
// Doesn't break
val value: String = withContext(...) {
loadFromDb()
}
println(value)
ralf
05/20/2020, 2:51 AMralf
05/20/2020, 2:51 AMshikasd
05/20/2020, 9:56 AMpreciseJavaTracking
that causes that, so you can disable it in gradle or compiler configurationralf
05/20/2020, 5:12 PMshikasd
05/20/2020, 5:37 PM