Skip to content

Instantly share code, notes, and snippets.

View belyaev-mikhail's full-sized avatar

Mikhail Belyaev belyaev-mikhail

  • SPBSTU
  • Saint-Petersburg, Russia
View GitHub Profile
package org.jetbrains.research.kotoed.util
import org.junit.Test
import kotlin.reflect.*
import kotlin.reflect.jvm.reflect
data class TypeMirror(
val classifier: ClassifierMirror?,
val arguments: List<TypeProjectionMirror>,
val isNullable: Boolean,
@belyaev-mikhail
belyaev-mikhail / pom.xml
Last active July 10, 2018 20:28
Kotlin pom example
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>group.id</groupId>
<artifactId>artifact-id</artifactId>
<version>0.0.1</version>
/**
* We declare a package-level function main which returns Unit and takes
* an Array of strings as a parameter. Note that semicolons are optional.
*/
sealed class Expr
enum class BinaryOp{ ADD, MUL, DIV }
data class BinaryExpr(val op: BinaryOp, val lhv: Expr, val rhv: Expr): Expr
data class Constant(val value: Int): Expr
data class Variable(val name: String): Expr
.pacman > div:nth-child(3)::after, .pacman > div:nth-child(4)::after, .pacman > div:nth-child(5)::after {
content: '';
position: absolute;
border-bottom: 7.0px solid;
border-left: 4.0px solid transparent;
border-right: 4.0px solid transparent;
top: -2px;
left: 4px;
-webkit-transform: rotate(-140deg);
<distributionManagement>
<repository>
<id>bintray-vorpal-research-kotlin-maven</id>
<name>vorpal-research-kotlin-maven</name>
<url>https://api.bintray.com/maven/vorpal-research/kotlin-maven/${artifactId}/;publish=1</url>
</repository>
</distributionManagement>
package org.jetbrains.research.kotoed
open class AbstractStuff() {
inline suspend fun<reified T> hello(value: T): T = println("Hello, ${T::class}").let { value }
}
class Stuff: AbstractStuff() {
suspend fun foo() = hello(40)
}
import org.junit.Test
import java.util.ArrayList
interface Whatever
fun Whatever.crash() = 2
object obj: Whatever
fun Any?.ttt(): Any? =
when (this) {
Exception in thread "main @coroutine#1" java.lang.ClassCastException: org.jetbrains.research.kotoed.util.Playground$Whatever cannot be cast to java.lang.String
at org.jetbrains.research.kotoed.util.Playground$testStuff$1$response$1.<init>(Playground.kt:24)
at org.jetbrains.research.kotoed.util.Playground$testStuff$1.doResume(Playground.kt:23)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:50)
at kotlinx.coroutines.experimental.DispatchedContinuation.resume(CoroutineDispatcher.kt:152)
at kotlin.coroutines.experimental.CoroutinesKt.startCoroutine(CoroutinesLibrary.kt:35)
at kotlinx.coroutines.experimental.BuildersKt.launch(Builders.kt:49)
at kotlinx.coroutines.experimental.BuildersKt.launch$default(Builders.kt:43)
at org.jetbrains.research.kotoed.util.Playground.testStuff(Playground.kt:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
package org.jetbrains.research.kotoed.util
import kotlinx.coroutines.experimental.Unconfined
import kotlinx.coroutines.experimental.launch
import org.junit.Test
import kotlin.coroutines.experimental.suspendCoroutine
import kotlin.reflect.KProperty
class Playground {
data class UncookedAnnotation(val name: String, val params: Map<String, Any?>)
val KType.uncookedAnnotations
get() = this.kotlinType.annotations.map { desc ->
UncookedAnnotation(
kotlin.reflect.jvm.internal.impl.renderer.DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(desc.type),
desc.allValueArguments.asSequence().map { (k, v) -> Pair("${k.name}", v.value) }.toMap()
)
}