Skip to content

Instantly share code, notes, and snippets.

@alextkachman
Last active Aug 29, 2015
Embed
What would you like to do?
Failing kotlin2js codegen for delegated extension properties
// Kotlin example
class Delegate() {
fun get(obj: String, desc: PropertyMetadataImpl) : String = obj.toString() + ".log"
}
val String.log by Delegate()
fun main(args : Array<String>) {
println("Hello, world!".log)
}
// Here is generated JS
Kotlin.System.flush();
(function () {
'use strict';
var _ = Kotlin.defineRootPackage(function () {
this.log$delegate = new _.Delegate();
}, /** @lends _ */ {
Delegate: Kotlin.createClass(null, null, /** @lends _.Delegate.prototype */ {
get: function (obj, desc) {
return obj + '.log';
}
}),
get_log: {value: function () {
// BUG: $receiver omited and ignored
return this.log$delegate.get(this, new Kotlin.PropertyMetadata('log'));
}},
main: function (args) {
Kotlin.println(_.get_log('Hello, world!'));
}
});
Kotlin.defineModule('JS_TESTS', _);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment