if (obj is String) { a print((obj as String).length) } a if (obj !is String) return print((obj as String).length) when (obj) { aa is Int -> print((obj as Int) + 1) is String -> print((obj as String).length + 1) is IntArray -> print((obj as IntArray).sum() + 1) } a
if (obj is String) { a print(obj.length) } a if (obj !is String) return print((obj as String).length) when (obj) { aa is Int -> print((obj as Int) + 1) is String -> print((obj as String).length + 1) is IntArray -> print((obj as IntArray).sum() + 1) } a
if (obj is String) { a print(obj.length) } a if (obj !is String) return print(obj.length) when (obj) { aa is Int -> print((obj as Int) + 1) is String -> print((obj as String).length + 1) is IntArray -> print((obj as IntArray).sum() + 1) } a
if (obj is String) { a print(obj.length) } a if (obj !is String) return print(obj.length) when (obj) { a is Int -> print(obj + 1) is String -> print(obj.length + 1) is IntArray -> print(obj.sum() + 1) } a
public inline fun Collection?.isNullOrEmpty(): Boolean { a contract { a returns(false) implies (this@isNullOrEmpty != null) } a return this == null || this.isEmpty() } a
public inline fun Collection?.isNullOrEmpty(): Boolean { a contract { a returns(false) implies (this@isNullOrEmpty != null) } a return this == null || this.isEmpty() } a
public inline fun Collection?.isNullOrEmpty(): Boolean { a contract { a returns(false) implies (this@isNullOrEmpty != null) } a return this == null || this.isEmpty() } a
public inline fun Collection?.isNullOrEmpty(): Boolean { a contract { a returns(false) implies (this@isNullOrEmpty != null) } a return this == null || this.isEmpty() } a
fun assertTrue(actual: Boolean, message: String? = null) { a contract { returns() implies actual } a return asserter.assertTrue(message ?: "Expected value to be true.", actual) } a
fun assertTrue(actual: Boolean, message: String? = null) { a contract { returns() implies actual } a return asserter.assertTrue(message ?: "Expected value to be true.", actual) } a
fun assertTrue(actual: Boolean, message: String? = null) { a contract { returns() implies actual } a return asserter.assertTrue(message ?: "Expected value to be true.", actual) } a assertTrue(obj != null) print(obj!!.length)
fun assertTrue(actual: Boolean, message: String? = null) { a contract { returns() implies actual } a return asserter.assertTrue(message ?: "Expected value to be true.", actual) } a assertTrue(obj != null) print(obj.length)
public inline fun run(block: () -> R): R { a contract { a callsInPlace(block, InvocationKind.EXACTLY_ONCE) } a return block() } a var s: String? = null a run { a s = "" a } a println(s!!) a
public inline fun run(block: () -> R): R { a contract { a callsInPlace(block, InvocationKind.EXACTLY_ONCE) } a return block() } a val s: String a run { a s = "" a } a println(s) a
fun checkObj(obj: Any?): Boolean { a contract { a returns(true) implies (obj != null) } a return obj != null } a if (checkObj(obj)) { a obj!!.javaClass } a
fun checkObj(obj: Any?): Boolean { a contract { a returns(true) implies (obj != null) } a return obj != null } a if (checkObj(obj)) { a obj!!.javaClass } a
fun checkObj(obj: Any?): Boolean { a contract { a returns(true) implies (obj != null) } a return obj != null } a if (checkObj(obj)) { a obj!!.javaClass } a
fun checkObj(obj: Any?): Boolean { a contract { a returns(true) implies (obj != null) } a return obj != null } a if (checkObj(obj)) { a obj.javaClass } a
@UseExperimental(ExperimentalContracts::class) fun checkObj(obj: Any?): Boolean { a contract { a returns(true) implies (obj != null) } a return obj != null } a if (checkObj(obj)) { a obj.javaClass } a
fun getName(): String { a return "name" } a fun fail() { a throw RuntimeException() } a val name = if (isFriend()) { a getName() } a else { a fail() } a
fun getName(): String { a return "name" } a fun fail() { a throw RuntimeException() } a val name: Any = if (isFriend()) { a getName() } a else { a fail() } a
fun getName(): String { a return "name" } a fun fail() { a throw RuntimeException() } a val name: Any = if (isFriend()) { a getName() } a else { a fail() } a
fun getName(): String { a return "name" } a fun fail() { a throw RuntimeException() } a val name: Any = if (isFriend()) { a getName() } a else { a fail() } a println((name as String).length)
fun getName(): String { a return "name" } a fun fail(): Nothing { a throw RuntimeException() } a val name: Any = if (isFriend()) { a getName() } a else { a fail() } a println((name as String).length)
fun getName(): String { a return "name" } a fun fail(): Nothing { a throw RuntimeException() } a val name: Any = if (isFriend()) { a getName() } a else { a fail() } a println((name as String).length)
fun getName(): String { a return "name" } a fun fail(): Nothing { a throw RuntimeException() } a val name: Any = if (isFriend()) { a getName() } a else { a fail() } a println((name as String).length)
fun getName(): String { a return "name" } a fun fail(): Nothing { a throw RuntimeException() } a val name: String = if (isFriend()) { a getName() } a else { a fail() } a println((name as String).length)
fun getName(): String { a return "name" } a fun fail(): Nothing { a throw RuntimeException() } a val name: String = if (isFriend()) { a getName() } a else { a fail() } a println(name.length)
fun getName(): String { a return "name" } a fun fail(): Nothing { a throw RuntimeException() } a val name = if (isFriend()) { a getName() } a else { a fail() } a println(name.length)
// kotlintest/kotlintest interface Show { a fun supports(a: Any?): Boolean fun show(a: A): String } a object NullShow : Show { a override fun supports(a: Any?): Boolean = a == null override fun show(a: Nothing?): String = "" } a
interface Mapper { a fun map(s: String): T } a class IntMapper : Mapper { a override fun map(s: String): Int = s.toInt() } a fun hoge(mapper: Mapper) { a mapper.map("10") } a
interface Mapper { a fun map(s: String): T } a class IntMapper : Mapper { a override fun map(s: String): Int = s.toInt() } a fun hoge(mapper: Mapper) { a mapper.map("10") } a val mapper = IntMapper() hoge(mapper)
interface Mapper { a fun map(s: String): T } a class IntMapper : Mapper { a override fun map(s: String): Int = s.toInt() } a fun hoge(mapper: Mapper) { a mapper.map("10") } a val mapper = IntMapper() hoge(mapper) ❌
interface Mapper { a fun map(s: String): T } a class IntMapper : Mapper { a override fun map(s: String): Int = s.toInt() } a fun hoge(mapper: Mapper) { a mapper.map("10") } a val mapper = IntMapper() hoge(mapper) ❌
interface Mapper { a fun map(s: String): T } a class IntMapper : Mapper { a override fun map(s: String): Int = s.toInt() } a fun hoge(mapper: Mapper) { a mapper.map("10") } a val mapper = IntMapper() hoge(mapper) ❌
interface Mapper { a fun map(s: String): T } a class IntMapper : Mapper { a override fun map(s: String): Int = s.toInt() } a fun hoge(mapper: Mapper) { a mapper.map("10") } a val mapper = IntMapper() hoge(mapper) ❌
interface Mapper { a fun map(s: String): T } a class IntMapper : Mapper { a override fun map(s: String): Int = s.toInt() } a fun hoge(mapper: Mapper) { a mapper.map("10") } a val mapper = IntMapper() hoge(mapper)
class OnClickActivity() : Activity(), OnClickListener fun setClick(activity: OnClickActivity) { a } a val activity = OnClickActivity() setClick(activity)
class OnClickActivity() : Activity(), OnClickListener fun setClick(activity: OnClickActivity) { a } a val activity = OnClickActivity() setClick(activity) class OnClickActivity2() : Activity(), OnClickListener
class OnClickActivity() : Activity(), OnClickListener fun setClick(activity: OnClickActivity) { a } a val activity = OnClickActivity() setClick(activity) class OnClickActivity2() : Activity(), OnClickListener val activity2 = OnClickActivity2() setClick(activity2)
class OnClickActivity() : Activity(), OnClickListener fun setClick(activity: OnClickActivity) { a } a val activity = OnClickActivity() setClick(activity) class OnClickActivity2() : Activity(), OnClickListener val activity2 = OnClickActivity2() setClick(activity2) ❌
fun setClick(activity: T) where T : Activity, T : OnClickListener { } val activity = OnClickActivity() setClick(activity) val activity2 = OnClickActivity2() setClick(activity2)
internal abstract class NIOSocketImpl( override val channel: S, val selector: SelectorManager, val pool: ObjectPool? ) : ReadWriteSocket, SelectableBase(channel), CoroutineScope where S : java.nio.channels.ByteChannel, S : java.nio.channels.SelectableChannel Ktor
internal abstract class NIOSocketImpl( override val channel: S, val selector: SelectorManager, val pool: ObjectPool? ) : ReadWriteSocket, SelectableBase(channel), CoroutineScope where S : java.nio.channels.ByteChannel, S : java.nio.channels.SelectableChannel Ktor
internal abstract class NIOSocketImpl( override val channel: S, val selector: SelectorManager, val pool: ObjectPool? ) : ReadWriteSocket, SelectableBase(channel), CoroutineScope where S : java.nio.channels.ByteChannel, S : java.nio.channels.SelectableChannel internal class DatagramSocketImpl(override val channel: DatagramChannel, selector: SelectorManager) : BoundDatagramSocket, ConnectedDatagramSocket, NIOSocketImpl(channel, selector, DefaultDatagramByteBufferPool) Ktor
internal abstract class NIOSocketImpl( override val channel: S, val selector: SelectorManager, val pool: ObjectPool? ) : ReadWriteSocket, SelectableBase(channel), CoroutineScope where S : java.nio.channels.ByteChannel, S : java.nio.channels.SelectableChannel internal class DatagramSocketImpl(override val channel: DatagramChannel, selector: SelectorManager) : BoundDatagramSocket, ConnectedDatagramSocket, NIOSocketImpl(channel, selector, DefaultDatagramByteBufferPool) internal class SocketImpl( override val channel: S, private val socket: java.net.Socket, selector: SelectorManager ) : NIOSocketImpl(channel, selector, pool = null), Socket Ktor
abstract class Either object Left : Either() object Right : Either() when (obj) { a Left -> println("is Left") Right -> println("is Right") else -> println("else") } a
sealed class Either object Left : Either() object Right : Either() when (obj) { a Left -> println("is Left") Right -> println("is Right") else -> println("else") } a
public interface Function1 : Function { public operator fun invoke(p1: P1): R } a val a: (Number) -> Number = { it } a val a1: (Int) -> Number = a val a2: (Number) -> Any = a
public interface Function1 : Function { public operator fun invoke(p1: P1): R } a val a: (Number) -> Number = { it } as val a1: (Int) -> Number = a val a2: (Number) -> Any = a
public class SamTest { a public static void foo(Runnable a, Runnable b) { a } a } a fun test() { a SamTest.foo({}) { a } a } a public interface Runnable { public abstract void run(); }