Skip to content

Instantly share code, notes, and snippets.


Alexander Udalov udalov

View GitHub Profile
udalov / jvm-ir-via-external-file.patch
Last active Dec 16, 2019
Enable JVM IR backend via external file
View jvm-ir-via-external-file.patch
diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt
index 3371edf18c8..5b72262ebfc 100644
--- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt
+++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt
@@ -24,6 +24,7 @@ import com.intellij.psi.PsiJavaModule
import org.jetbrains.kotlin.analyzer.AnalysisResult
udalov /
Last active Sep 12, 2019
Test compilation of the Kotlin project with JVM IR
#!/usr/bin/env python3
import atexit, os, re, shutil, subprocess, sys, time
from pathlib import Path
def to_str(buf):
return "".join(map(chr, buf))
def dump_stdout_stderr(f, result):
f.write("=== STDOUT ===\n\n")
udalov /
Created Sep 20, 2018
Nested classes in annotations KEEP draft

Support nested classes in annotations

Discussion of this proposal is held in this issue.


Support nested classes, including companion objects, in annotation classes:

annotation class MyAnnotation(val value: Kind) {
    enum class Kind { FIRST, SECOND }
udalov / loadOriginName.kt
Last active Mar 1, 2018
Load name of the original anonymous/synthetic class which was copied during inline (KT-21320)
View loadOriginName.kt
import org.jetbrains.kotlin.serialization.jvm.*
fun loadOriginName(className: String) {
val metadata = Class.forName(className).declaredAnnotations
.filter { it.annotationClass.qualifiedName == "kotlin.Metadata" }
.single() as Metadata
if (metadata.k == 3 && metadata.d1.isNotEmpty()) {
// Synthetic classes generated for lambdas/coroutines
udalov / getKType.kt
Last active Jun 19, 2020
DEPRECATED example how to obtain KType instance from reified T. Please use "typeOf" since 1.3.40!
View getKType.kt
import java.lang.reflect.*
import kotlin.reflect.KClass
import kotlin.reflect.KType
import kotlin.reflect.KTypeProjection
import kotlin.reflect.KVariance
import kotlin.reflect.full.createType
// --- Interface ---
inline fun <reified T : Any> getKType(): KType =
udalov /
Last active Apr 8, 2016
Spec: bound callable references


Support "bound callable references" and "bound class literals".

Motivation / use cases

  • It's painful to write lambdas every time
  • There's currently no way to reference an object member, which is sort of inconsistent with the fact that it's possible to reference static Java members
  • It's present in Java and its absence in Kotlin is rather inconvenient
  • 42 votes on KT-6947: Callable reference with expression on the left hand side

udalov /
Created Mar 28, 2016
Spec: sealed + data


Allow data classes as sealed class subclasses.

sealed class Base {
    data class Derived(...) : Base()

Motivation / use cases


Keybase proof

I hereby claim:

  • I am udalov on github.
  • I am udalov ( on keybase.
  • I have a public key whose fingerprint is 40BF FCAA AA01 B591 916C AAB6 8DA6 620F 79E0 B972

To claim this, I am signing this object:

udalov / api.kt
Last active Aug 29, 2015
Sketch of a more type-safe reflection API for Kotlin
View api.kt
interface KElement
// Class, package, type
interface KDeclarationContainer : KElement {
val allMembers: Collection<KElement>
View break java
class A { void foo() {} }
class a { }
public class Main {
public static void main(String[] args) {
new A().foo();
You can’t perform that action at this time.