Ahmed Mourad
09/09/2020, 11:32 PMScott Christopher
09/10/2020, 1:43 AMType mismatch. Required: P, Found: <P>
error for the returned value.
interface A
interface B
interface C
fun <P> resolve(): P where P : A, P : B, P : C {
return object : A, B, C {}
}
Is there some variation of this that is possible?Fabio
09/10/2020, 5:56 AMabstract class TodayDynamicModel<V : View> : BardeenListUiModel() {
fun asTodayDynamicModel() = this as TodayDynamicModel<View> // --> Unchecked cast: TodayDynamicModel<V> to TodayDynamicModel<View>
}
Isn't V
guaranteed to be of type View
?Erik
09/10/2020, 7:28 AMlouiscad
09/10/2020, 12:19 PMCFrei
09/10/2020, 1:00 PMfun s() = sequence<Unit> {
suspend fun f() {
let { f() }
}
}
Anyone an idea how I need to replace/annotate let
to get that up and running? (bug is in 1.4.0 and 1.4.10) - Thanks in advance!!!msink
09/10/2020, 1:43 PMElka
09/10/2020, 5:14 PMfun <T: Any> x(block: () -> T?) {
val res = block()
if (res != null) {
println(res)
} else {
println("returned null")
}
}
fun test() {
x<Unit> {
null
}
}
Kotlin (<1.4)
It prints "retuned null
Kotlin (>= 1.4)
It prints kotlin.Unit
The weird part is that x { null }
works fine. The compiler is able to infer the type to Unit?
. But I can't write x<Unit?> { null }
as the type is bound to Any
which is something we need on Kotlin-Native (unless this has changed too)Brian Dilley
09/10/2020, 6:43 PMvoid
LastExceed
09/10/2020, 7:08 PMfun <T> T.foo(param: T) {
}
suspend fun main() {
val x = "text"
val y = 42
x.foo(y)
}
why does this code compile and run successfully even though x and y are of different types ?Don Phillips
09/10/2020, 7:08 PMSrSouza
09/10/2020, 11:39 PMSlackbot
09/11/2020, 5:32 AMscottyab
09/11/2020, 9:14 AM@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class
) for an entire package and sub packages? I’m getting a bunch of warnings in my tests as I’m using experimental runBlockingTest{}
and I’d love to squash all the warnings in a single place rather than per class annotation.Stephan Schroeder
09/11/2020, 10:47 AM> Task :module-ui:compileTestKotlin
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/home/stephan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.4.10/998caa30623f73223194a8b657abd2baec4880ea/kotlin-stdlib-jdk8-1.4.10.jar (version 1.4)
/home/stephan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.4.10/30e46450b0bb3dbf43898d2f461be4a942784780/kotlin-stdlib-jdk7-1.4.10.jar (version 1.4)
/home/stephan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.3.0/6fd129fd9ba8581f2cb9c58bfd431dda4ee0457e/kotlin-reflect-1.3.0.jar (version 1.3)
/home/stephan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.4.10/ea29e063d2bbe695be13e9d044dcfb0c7add398e/kotlin-stdlib-1.4.10.jar (version 1.4)
/home/stephan/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.4.10/6229be3465805c99db1142ad75e6c6ddeac0b04c/kotlin-stdlib-common-1.4.10.jar (version 1.4)
w: Consider providing an explicit dependency on kotlin-reflect 1.4 to prevent strange errors
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
Mike Patterson
09/11/2020, 2:06 PMprivate class MyAdListener(private val listeners: List<AdListener>) : AdListener {
override fun onAdStarted(adInfo: AdInfo) = listeners.forEach { it.onAdStarted(adInfo) }
override fun onAdCompleted(adInfo: AdInfo) = listeners.forEach { it.onAdCompleted(adInfo) }
override fun onAdBreakStarted(adInfo: AdInfo) = listeners.forEach { it.onAdBreakStarted(adInfo) }
override fun onAdBreakCompleted(adInfo: AdInfo) = listeners.forEach { it.onAdBreakCompleted(adInfo) }
// etc
is there a method for delegation that works? something like...
private class MyAdListener(private val listeners: List<AdListener>) : AdListener by listeners.each()
ribesg
09/11/2020, 2:28 PMLogan Knight
09/11/2020, 8:11 PM--compatibility
flag to a Docker Compose run configuration in Ultimate?Slackbot
09/12/2020, 8:25 AMMehul Kabaria
09/13/2020, 6:32 AMHarry
09/13/2020, 11:37 AMShashank
09/13/2020, 1:55 PMStateFlow
at all? 🤔harry.singh
09/15/2020, 1:06 AMKayCee
09/15/2020, 10:05 AMrrva
09/15/2020, 2:30 PMfun computeNewValue(msg: String, oldValue: String): String {
return try {
println(msg)
computeNewValue()
} catch(e: RuntimeException) {
oldValue
}
}
fun main() {
val foo = Foo()
foo.someProperty = computeNewValue("Computing foo", foo.someProperty)
}
v79
09/15/2020, 7:19 PMVladyslav Sitalo
09/15/2020, 9:13 PMatara
09/16/2020, 6:06 AMalso
(https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/also.html) and run
(https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/run.html). I understand what they are doing but never had the need to use them. Do you use them at all? can you tell a valid case where you used them and it made your code better?andylamax
09/16/2020, 8:04 AMAshish Lama
09/16/2020, 11:42 AM