JS backend: compile primitive iterators from builtins as part of stdlib.
This commit is contained in:
@@ -39,6 +39,7 @@ import org.jetbrains.k2js.translate.utils.JsAstUtils;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.k2js.config.LibrarySourcesConfig.STDLIB_JS_MODULE_NAME;
|
||||
import static org.jetbrains.k2js.translate.utils.AnnotationsUtils.*;
|
||||
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.*;
|
||||
import static org.jetbrains.k2js.translate.utils.ManglingUtils.getMangledName;
|
||||
@@ -467,6 +468,8 @@ public final class StaticContext {
|
||||
}
|
||||
|
||||
private String getExternalModuleName(DeclarationDescriptor descriptor) {
|
||||
if (isBuiltin(descriptor)) return STDLIB_JS_MODULE_NAME;
|
||||
|
||||
PsiElement element = descriptorToDeclaration(descriptor);
|
||||
if (element == null && descriptor instanceof PropertyAccessorDescriptor) {
|
||||
element = descriptorToDeclaration(((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty());
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package foo
|
||||
|
||||
class MyCharIterator : CharIterator() {
|
||||
val data = array('O', 'K')
|
||||
var i = 0
|
||||
|
||||
override fun hasNext(): Boolean = i < data.size
|
||||
override fun nextChar(): Char = data[i++]
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var r = ""
|
||||
|
||||
for (v in MyCharIterator()) {
|
||||
r += v
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user