JS backend: compile primitive iterators from builtins as part of stdlib.
This commit is contained in:
@@ -222,6 +222,7 @@
|
|||||||
|
|
||||||
<kotlin2js output="${output}/${compiled.stdlib.js}" main="noCall">
|
<kotlin2js output="${output}/${compiled.stdlib.js}" main="noCall">
|
||||||
<src>
|
<src>
|
||||||
|
<fileset refid="kotlin.builtin.files" />
|
||||||
<resources refid="js.lib.files" />
|
<resources refid="js.lib.files" />
|
||||||
</src>
|
</src>
|
||||||
</kotlin2js>
|
</kotlin2js>
|
||||||
|
|||||||
@@ -87,6 +87,10 @@ public final class ClassInheritanceTest extends SingleFileTranslationTest {
|
|||||||
public void testWithInitializeMethod() throws Exception {
|
public void testWithInitializeMethod() throws Exception {
|
||||||
checkFooBoxIsOk();
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testInheritFromCharIterator() throws Exception {
|
||||||
|
checkFooBoxIsOk();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import org.jetbrains.k2js.translate.utils.JsAstUtils;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
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.AnnotationsUtils.*;
|
||||||
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.*;
|
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.*;
|
||||||
import static org.jetbrains.k2js.translate.utils.ManglingUtils.getMangledName;
|
import static org.jetbrains.k2js.translate.utils.ManglingUtils.getMangledName;
|
||||||
@@ -467,6 +468,8 @@ public final class StaticContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getExternalModuleName(DeclarationDescriptor descriptor) {
|
private String getExternalModuleName(DeclarationDescriptor descriptor) {
|
||||||
|
if (isBuiltin(descriptor)) return STDLIB_JS_MODULE_NAME;
|
||||||
|
|
||||||
PsiElement element = descriptorToDeclaration(descriptor);
|
PsiElement element = descriptorToDeclaration(descriptor);
|
||||||
if (element == null && descriptor instanceof PropertyAccessorDescriptor) {
|
if (element == null && descriptor instanceof PropertyAccessorDescriptor) {
|
||||||
element = descriptorToDeclaration(((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty());
|
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
|
||||||
|
}
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
<project>
|
<project>
|
||||||
|
<fileset id="kotlin.builtin.files" dir="${basedir}/core/builtins/src">
|
||||||
|
<include name="kotlin/Iterators.kt"/>
|
||||||
|
<include name="kotlin/Range.kt"/>
|
||||||
|
</fileset>
|
||||||
|
|
||||||
<union id="js.lib.files">
|
<union id="js.lib.files">
|
||||||
<fileset dir="${basedir}/js/js.libraries/src">
|
<fileset dir="${basedir}/js/js.libraries/src">
|
||||||
<include name="**/*.kt" />
|
<include name="**/*.kt" />
|
||||||
|
|||||||
Reference in New Issue
Block a user