kirillrakhman
12/23/2016, 11:16 AMkirillrakhman
12/23/2016, 11:17 AMinline fun <reified T : Any> HttpException.bodyAs(gson: Gson): T? =
gson.fromJson<T>(response().errorBody().string(), object : TypeToken<T>() {}.type)
elizarov
12/23/2016, 11:17 AMkirillrakhman
12/23/2016, 11:18 AMelizarov
12/23/2016, 11:19 AMkirillrakhman
12/23/2016, 11:19 AMkirillrakhman
12/23/2016, 11:20 AMelizarov
12/23/2016, 11:54 AMdmitry.petrov
12/23/2016, 11:58 AMdmitry.petrov
12/23/2016, 11:58 AMdmitry.petrov
12/23/2016, 11:59 AMdmitry.petrov
12/23/2016, 12:00 PMdmitry.petrov
12/23/2016, 12:02 PMpublic interface Base {}
/*package-private*/ abstract class Impl implements Base {}
public class Derived1 extends Impl {}
public class Derived2 extends Impl {}
dmitry.petrov
12/23/2016, 12:05 PMDerived1
and Derived2
in expression, Impl
can be implicitly inferred, BE will emit CHECKCAST, boom.
Actually you can write similar code in Java (that would implicitly infer Impl
), it'd just take a bit more of "creativity" to do so.dmitry.petrov
12/23/2016, 12:07 PMelizarov
12/23/2016, 12:36 PMdmitry.petrov
12/23/2016, 12:38 PMfoo(bar(if (flag) Derived1() else Derived2())) // should extract variable here
damian
12/23/2016, 9:20 PMdamian
12/23/2016, 9:22 PMdamian
12/23/2016, 9:23 PMdamian
12/23/2016, 9:38 PMdamian
12/23/2016, 10:04 PMDestructure
shouldn't be a spelling error by default in IntelliJ 😉 )damian
12/24/2016, 12:01 AMdamian
12/24/2016, 2:05 AMnhaarman
12/24/2016, 12:37 PMfun test() {
val action = mock<() -> Unit>()
MyJavaClass().doSomething(action)
}
public class MyJavaClass {
void doSomething(Runnable r) {
r.run();
}
}
Now mock<() -> Unit>()
uses Mockito to create a mock object. This mock object will by default return null
when invoked: action.invoke()
will return null
.
Since M04, the following ISE is thrown:
java.lang.IllegalStateException: invoke(...) must not be null
at test.SAMTestKt$sam$Runnable$3ede1671.run(SAMTest.kt)
at test.MyJavaClass.doSomething(MyJavaClass.java:6)
at test.SAMTest.test(SAMTest.kt:12)
Is this intended?nhaarman
12/24/2016, 6:34 PMmichaelrocks
12/25/2016, 7:55 PMmichaelrocks
12/25/2016, 8:02 PMadambl4
12/26/2016, 2:50 PM1.1-M04
I'm getting a lot of org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't inline method call ...
and it always caused at MethodInliner.java:752
I'm unable to reproduce it on a small project. Somehow it related to bound callable reference inside inlined lambda.
Maybe it is a known issue? Would it be enough to file an issue just with compiler error message?