Last active
August 29, 2015 13:57
-
-
Save alextkachman/9802138 to your computer and use it in GitHub Desktop.
Failing kotlin2js codegen for delegated extension properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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