diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index a8d4376eda4..ed6db12e6fd 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -280,23 +280,23 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { private static final Map KOTLIN_MARKER_INTERFACES = new HashMap(); static { - KOTLIN_MARKER_INTERFACES.put("kotlin.Iterator", "kotlin/jvm/internal/markers/KMappedMarker"); - KOTLIN_MARKER_INTERFACES.put("kotlin.Iterable", "kotlin/jvm/internal/markers/KMappedMarker"); - KOTLIN_MARKER_INTERFACES.put("kotlin.Collection", "kotlin/jvm/internal/markers/KMappedMarker"); - KOTLIN_MARKER_INTERFACES.put("kotlin.List", "kotlin/jvm/internal/markers/KMappedMarker"); - KOTLIN_MARKER_INTERFACES.put("kotlin.ListIterator", "kotlin/jvm/internal/markers/KMappedMarker"); - KOTLIN_MARKER_INTERFACES.put("kotlin.Set", "kotlin/jvm/internal/markers/KMappedMarker"); - KOTLIN_MARKER_INTERFACES.put("kotlin.Map", "kotlin/jvm/internal/markers/KMappedMarker"); - KOTLIN_MARKER_INTERFACES.put("kotlin.Map.Entry", "kotlin/jvm/internal/markers/KMappedMarker"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.Iterator", "kotlin/jvm/internal/markers/KMappedMarker"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.Iterable", "kotlin/jvm/internal/markers/KMappedMarker"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.Collection", "kotlin/jvm/internal/markers/KMappedMarker"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.List", "kotlin/jvm/internal/markers/KMappedMarker"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.ListIterator", "kotlin/jvm/internal/markers/KMappedMarker"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.Set", "kotlin/jvm/internal/markers/KMappedMarker"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.Map", "kotlin/jvm/internal/markers/KMappedMarker"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.Map.Entry", "kotlin/jvm/internal/markers/KMappedMarker"); - KOTLIN_MARKER_INTERFACES.put("kotlin.MutableIterator", "kotlin/jvm/internal/markers/KMutableIterator"); - KOTLIN_MARKER_INTERFACES.put("kotlin.MutableIterable", "kotlin/jvm/internal/markers/KMutableIterable"); - KOTLIN_MARKER_INTERFACES.put("kotlin.MutableCollection", "kotlin/jvm/internal/markers/KMutableCollection"); - KOTLIN_MARKER_INTERFACES.put("kotlin.MutableList", "kotlin/jvm/internal/markers/KMutableList"); - KOTLIN_MARKER_INTERFACES.put("kotlin.MutableListIterator", "kotlin/jvm/internal/markers/KMutableListIterator"); - KOTLIN_MARKER_INTERFACES.put("kotlin.MutableSet", "kotlin/jvm/internal/markers/KMutableSet"); - KOTLIN_MARKER_INTERFACES.put("kotlin.MutableMap", "kotlin/jvm/internal/markers/KMutableMap"); - KOTLIN_MARKER_INTERFACES.put("kotlin.MutableMap.MutableEntry", "kotlin/jvm/internal/markers/KMutableMap$Entry"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.MutableIterator", "kotlin/jvm/internal/markers/KMutableIterator"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.MutableIterable", "kotlin/jvm/internal/markers/KMutableIterable"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.MutableCollection", "kotlin/jvm/internal/markers/KMutableCollection"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.MutableList", "kotlin/jvm/internal/markers/KMutableList"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.MutableListIterator", "kotlin/jvm/internal/markers/KMutableListIterator"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.MutableSet", "kotlin/jvm/internal/markers/KMutableSet"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.MutableMap", "kotlin/jvm/internal/markers/KMutableMap"); + KOTLIN_MARKER_INTERFACES.put("kotlin.collections.MutableMap.MutableEntry", "kotlin/jvm/internal/markers/KMutableMap$Entry"); } @NotNull diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java index b62455e226d..de176ab0841 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.types.KotlinType; import java.util.List; -import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME; +import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.RANGES_PACKAGE_FQ_NAME; import static org.jetbrains.kotlin.codegen.AsmUtil.isPrimitiveNumberClassDescriptor; public class RangeCodegenUtil { @@ -53,8 +53,8 @@ public class RangeCodegenUtil { ImmutableMap.Builder rangeBuilder = ImmutableMap.builder(); ImmutableMap.Builder progressionBuilder = ImmutableMap.builder(); for (PrimitiveType primitiveType : supportedRangeTypes()) { - FqName rangeClassFqName = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier(primitiveType.getTypeName() + "Range")); - FqName progressionClassFqName = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier(primitiveType.getTypeName() + "Progression")); + FqName rangeClassFqName = RANGES_PACKAGE_FQ_NAME.child(Name.identifier(primitiveType.getTypeName() + "Range")); + FqName progressionClassFqName = RANGES_PACKAGE_FQ_NAME.child(Name.identifier(primitiveType.getTypeName() + "Progression")); rangeBuilder.put(rangeClassFqName, primitiveType); progressionBuilder.put(progressionClassFqName, primitiveType); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java index 8aa7d96ddc1..0ac788fbcb3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java @@ -29,7 +29,9 @@ import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType; import org.jetbrains.kotlin.types.expressions.OperatorConventions; +import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES; import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME; +import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.COLLECTIONS_PACKAGE_FQ_NAME; import static org.jetbrains.org.objectweb.asm.Opcodes.*; public class IntrinsicMethods { @@ -76,29 +78,29 @@ public class IntrinsicMethods { ImmutableList primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList(); for (Name method : primitiveCastMethods) { String methodName = method.asString(); - declareIntrinsicFunction("Number", methodName, 0, NUMBER_CAST); + declareIntrinsicFunction(FQ_NAMES.number, methodName, 0, NUMBER_CAST); for (PrimitiveType type : PrimitiveType.NUMBER_TYPES) { - declareIntrinsicFunction(type.getTypeName().asString(), methodName, 0, NUMBER_CAST); + declareIntrinsicFunction(type.getTypeFqName(), methodName, 0, NUMBER_CAST); } } for (PrimitiveType type : PrimitiveType.NUMBER_TYPES) { - String typeName = type.getTypeName().asString(); - declareIntrinsicFunction(typeName, "plus", 0, UNARY_PLUS); - declareIntrinsicFunction(typeName, "unaryPlus", 0, UNARY_PLUS); - declareIntrinsicFunction(typeName, "minus", 0, UNARY_MINUS); - declareIntrinsicFunction(typeName, "unaryMinus", 0, UNARY_MINUS); - declareIntrinsicFunction(typeName, "inv", 0, INV); - declareIntrinsicFunction(typeName, "rangeTo", 1, RANGE_TO); - declareIntrinsicFunction(typeName, "inc", 0, INC); - declareIntrinsicFunction(typeName, "dec", 0, DEC); + FqName typeFqName = type.getTypeFqName(); + declareIntrinsicFunction(typeFqName, "plus", 0, UNARY_PLUS); + declareIntrinsicFunction(typeFqName, "unaryPlus", 0, UNARY_PLUS); + declareIntrinsicFunction(typeFqName, "minus", 0, UNARY_MINUS); + declareIntrinsicFunction(typeFqName, "unaryMinus", 0, UNARY_MINUS); + declareIntrinsicFunction(typeFqName, "inv", 0, INV); + declareIntrinsicFunction(typeFqName, "rangeTo", 1, RANGE_TO); + declareIntrinsicFunction(typeFqName, "inc", 0, INC); + declareIntrinsicFunction(typeFqName, "dec", 0, DEC); } for (PrimitiveType type : PrimitiveType.values()) { - String typeName = type.getTypeName().asString(); - declareIntrinsicFunction(typeName, "equals", 1, EQUALS); - declareIntrinsicFunction(typeName, "hashCode", 0, HASH_CODE); - declareIntrinsicFunction(typeName, "toString", 0, TO_STRING); + FqName typeFqName = type.getTypeFqName(); + declareIntrinsicFunction(typeFqName, "equals", 1, EQUALS); + declareIntrinsicFunction(typeFqName, "hashCode", 0, HASH_CODE); + declareIntrinsicFunction(typeFqName, "toString", 0, TO_STRING); intrinsicsMap.registerIntrinsic( BUILT_INS_PACKAGE_FQ_NAME, null, StringsKt.decapitalize(type.getArrayTypeName().asString()) + "Of", 1, new JavaClassArray() @@ -117,12 +119,12 @@ public class IntrinsicMethods { declareBinaryOp("or", IOR); declareBinaryOp("xor", IXOR); - declareIntrinsicFunction("Boolean", "not", 0, new Not()); + declareIntrinsicFunction(FQ_NAMES._boolean, "not", 0, new Not()); - declareIntrinsicFunction("String", "plus", 1, new Concat()); - declareIntrinsicFunction("String", "get", 1, new StringGetChar()); + declareIntrinsicFunction(FQ_NAMES.string, "plus", 1, new Concat()); + declareIntrinsicFunction(FQ_NAMES.string, "get", 1, new StringGetChar()); - declareIntrinsicFunction("Cloneable", "clone", 0, CLONE); + declareIntrinsicFunction(FQ_NAMES.cloneable, "clone", 0, CLONE); intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.any, "toString", 0, TO_STRING); intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.any, "identityEquals", 1, IDENTITY_EQUALS); @@ -130,9 +132,8 @@ public class IntrinsicMethods { intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, null, "arrayOfNulls", 1, new NewArray()); for (PrimitiveType type : PrimitiveType.values()) { - String typeName = type.getTypeName().asString(); - declareIntrinsicFunction(typeName, "compareTo", 1, new CompareTo()); - declareIntrinsicFunction(typeName + "Iterator", "next", 0, ITERATOR_NEXT); + declareIntrinsicFunction(type.getTypeFqName(), "compareTo", 1, new CompareTo()); + declareIntrinsicFunction(COLLECTIONS_PACKAGE_FQ_NAME.child(Name.identifier(type.getTypeName().asString() + "Iterator")), "next", 0, ITERATOR_NEXT); } declareArrayMethods(); @@ -140,44 +141,42 @@ public class IntrinsicMethods { private void declareArrayMethods() { for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) { - declareArrayMethodsForPrimitive(jvmPrimitiveType); + declareArrayMethods(jvmPrimitiveType.getPrimitiveType().getArrayTypeFqName()); } - - declareIntrinsicFunction("Array", "size", -1, ARRAY_SIZE); - declareIntrinsicFunction("Array", "set", 2, ARRAY_SET); - declareIntrinsicFunction("Array", "get", 1, ARRAY_GET); - declareIntrinsicFunction("Array", "clone", 0, CLONE); - declareIterator("Array"); + declareArrayMethods(FQ_NAMES.array.toSafe()); } - private void declareArrayMethodsForPrimitive(@NotNull JvmPrimitiveType jvmPrimitiveType) { - String arrayTypeName = jvmPrimitiveType.getPrimitiveType().getArrayTypeName().asString(); - declareIntrinsicFunction(arrayTypeName, "size", -1, ARRAY_SIZE); - declareIntrinsicFunction(arrayTypeName, "set", 2, ARRAY_SET); - declareIntrinsicFunction(arrayTypeName, "get", 1, ARRAY_GET); - declareIntrinsicFunction(arrayTypeName, "clone", 0, CLONE); - declareIterator(arrayTypeName); - } - - private void declareIterator(@NotNull String arrayClassName) { - declareIntrinsicFunction(arrayClassName, "iterator", 0, ARRAY_ITERATOR); + private void declareArrayMethods(@NotNull FqName arrayTypeFqName) { + declareIntrinsicFunction(arrayTypeFqName, "size", -1, ARRAY_SIZE); + declareIntrinsicFunction(arrayTypeFqName, "set", 2, ARRAY_SET); + declareIntrinsicFunction(arrayTypeFqName, "get", 1, ARRAY_GET); + declareIntrinsicFunction(arrayTypeFqName, "clone", 0, CLONE); + declareIntrinsicFunction(arrayTypeFqName, "iterator", 0, ARRAY_ITERATOR); } private void declareBinaryOp(@NotNull String methodName, int opcode) { BinaryOp op = new BinaryOp(opcode); for (PrimitiveType type : PrimitiveType.values()) { - declareIntrinsicFunction(type.getTypeName().asString(), methodName, 1, op); + declareIntrinsicFunction(type.getTypeFqName(), methodName, 1, op); } } private void declareIntrinsicFunction( - @NotNull String className, + @NotNull FqName classFqName, @NotNull String methodName, int arity, @NotNull IntrinsicMethod implementation ) { - intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier(className)), - null, methodName, arity, implementation); + intrinsicsMap.registerIntrinsic(classFqName, null, methodName, arity, implementation); + } + + private void declareIntrinsicFunction( + @NotNull FqNameUnsafe classFqName, + @NotNull String methodName, + int arity, + @NotNull IntrinsicMethod implementation + ) { + intrinsicsMap.registerIntrinsic(classFqName.toSafe(), null, methodName, arity, implementation); } @Nullable diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt index a8e20a9094b..1cbd5419b5a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IteratorNext.kt @@ -16,10 +16,11 @@ package org.jetbrains.kotlin.codegen.intrinsics -import org.jetbrains.kotlin.builtins.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME +import org.jetbrains.kotlin.builtins.KotlinBuiltIns.COLLECTIONS_PACKAGE_FQ_NAME import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.jvm.AsmTypes import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter @@ -45,7 +46,7 @@ class IteratorNext : IntrinsicMethod() { override fun invokeIntrinsic(v: InstructionAdapter) { val name = getIteratorName(returnType) v.invokevirtual( - BUILT_INS_PACKAGE_FQ_NAME.asString() + "/" + name + "Iterator", + COLLECTIONS_PACKAGE_FQ_NAME.child(Name.identifier(name + "Iterator")) .asString().replace('.', '/'), "next$name", "()" + returnType.descriptor, false diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt index 61a10646b1d..8b296f6e51e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt @@ -115,14 +115,14 @@ object TypeIntrinsics { Type.getMethodDescriptor(Type.BOOLEAN_TYPE, Type.getObjectType("java/lang/Object"), Type.INT_TYPE) private val IS_MUTABLE_COLLECTION_METHOD_NAME = hashMapOf( - "kotlin.MutableIterator" to "isMutableIterator", - "kotlin.MutableIterable" to "isMutableIterable", - "kotlin.MutableCollection" to "isMutableCollection", - "kotlin.MutableList" to "isMutableList", - "kotlin.MutableListIterator" to "isMutableListIterator", - "kotlin.MutableSet" to "isMutableSet", - "kotlin.MutableMap" to "isMutableMap", - "kotlin.MutableMap.MutableEntry" to "isMutableMapEntry" + "kotlin.collections.MutableIterator" to "isMutableIterator", + "kotlin.collections.MutableIterable" to "isMutableIterable", + "kotlin.collections.MutableCollection" to "isMutableCollection", + "kotlin.collections.MutableList" to "isMutableList", + "kotlin.collections.MutableListIterator" to "isMutableListIterator", + "kotlin.collections.MutableSet" to "isMutableSet", + "kotlin.collections.MutableMap" to "isMutableMap", + "kotlin.collections.MutableMap.MutableEntry" to "isMutableMapEntry" ) private val IS_MUTABLE_COLLECTION_METHOD_DESCRIPTOR = @@ -155,14 +155,14 @@ object TypeIntrinsics { IS_MUTABLE_COLLECTION_METHOD_NAME[getClassFqName(jetType)] private val CHECKCAST_METHOD_NAME = hashMapOf( - "kotlin.MutableIterator" to "asMutableIterator", - "kotlin.MutableIterable" to "asMutableIterable", - "kotlin.MutableCollection" to "asMutableCollection", - "kotlin.MutableList" to "asMutableList", - "kotlin.MutableListIterator" to "asMutableListIterator", - "kotlin.MutableSet" to "asMutableSet", - "kotlin.MutableMap" to "asMutableMap", - "kotlin.MutableMap.MutableEntry" to "asMutableMapEntry" + "kotlin.collections.MutableIterator" to "asMutableIterator", + "kotlin.collections.MutableIterable" to "asMutableIterable", + "kotlin.collections.MutableCollection" to "asMutableCollection", + "kotlin.collections.MutableList" to "asMutableList", + "kotlin.collections.MutableListIterator" to "asMutableListIterator", + "kotlin.collections.MutableSet" to "asMutableSet", + "kotlin.collections.MutableMap" to "asMutableMap", + "kotlin.collections.MutableMap.MutableEntry" to "asMutableMapEntry" ) private fun getAsMutableCollectionMethodName(jetType: KotlinType): String? { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMappingUtil.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMappingUtil.kt index aa9bedff79a..b26104be4e9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMappingUtil.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMappingUtil.kt @@ -18,9 +18,11 @@ package org.jetbrains.kotlin.codegen.state import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES as BUILTIN_NAMES import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.descriptorUtil.firstOverridden import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf @@ -80,10 +82,11 @@ val CallableDescriptor?.isMethodWithDeclarationSiteWildcards: Boolean } != null } +private fun FqName.child(name: String): FqName = child(Name.identifier(name)) private val METHODS_WITH_DECLARATION_SITE_WILDCARDS = setOf( - FqName("kotlin.MutableCollection.addAll"), - FqName("kotlin.MutableList.addAll"), - FqName("kotlin.MutableMap.putAll") + BUILTIN_NAMES.mutableCollection.child("addAll"), + BUILTIN_NAMES.mutableList.child("addAll"), + BUILTIN_NAMES.mutableMap.child("putAll") ) internal fun TypeMappingMode.updateArgumentModeFromAnnotations(type: KotlinType): TypeMappingMode { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt index 2520cae2a30..baa2b615492 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatform.kt @@ -62,5 +62,7 @@ private val DEFAULT_IMPORTS_FOR_JVM: List = ArrayList(). val builtIns = JvmPlatform.builtIns addAllClassifiersFromScope(builtIns.builtInsPackageScope) - addAllClassifiersFromScope(builtIns.annotationPackageScope) + addAllClassifiersFromScope(builtIns.collectionsPackageFragment.getMemberScope()) + addAllClassifiersFromScope(builtIns.rangesPackageFragment.getMemberScope()) + addAllClassifiersFromScope(builtIns.annotationPackageFragment.getMemberScope()) } diff --git a/core/builtins/native/kotlin/Collections.kt b/core/builtins/native/kotlin/Collections.kt index 639f0882b96..270cfbd5f15 100644 --- a/core/builtins/native/kotlin/Collections.kt +++ b/core/builtins/native/kotlin/Collections.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package kotlin +package kotlin.collections /** * Classes that inherit from this interface can be represented as a sequence of elements that can diff --git a/core/builtins/native/kotlin/Iterator.kt b/core/builtins/native/kotlin/Iterator.kt index 0e4ea99ed4f..d854a6a66f9 100644 --- a/core/builtins/native/kotlin/Iterator.kt +++ b/core/builtins/native/kotlin/Iterator.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package kotlin +package kotlin.collections /** * An iterator over a collection or another entity that can be represented as a sequence of elements. diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt index 5c780dfffcf..472860e7e50 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt @@ -175,7 +175,7 @@ class LazyJavaClassDescriptor( ?: FakePureImplementationsProvider.getPurelyImplementedInterface(fqName) ?: return null - if (purelyImplementedFqName.isRoot || purelyImplementedFqName.parent() != KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) return null + if (purelyImplementedFqName.isRoot || !purelyImplementedFqName.toUnsafe().startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME)) return null val classDescriptor = c.module.builtIns.getBuiltInClassByNameNullable(purelyImplementedFqName.shortName()) ?: return null diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt index f1220e301b0..e5552b26f6c 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.load.java import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES as BUILTIN_NAMES import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.getSpecialSignatureInfo import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.sameAsBuiltinMethodWithErasedValueParameters @@ -25,37 +26,41 @@ import org.jetbrains.kotlin.load.java.BuiltinSpecialProperties.getBuiltinSpecial import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.* import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure +private fun FqName.child(name: String): FqName = child(Name.identifier(name)) +private fun FqNameUnsafe.childSafe(name: String): FqName = child(Name.identifier(name)).toSafe() + object BuiltinSpecialProperties { - private val PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP = mapOf( - FqName("kotlin.Enum.name") to Name.identifier("name"), - FqName("kotlin.Enum.ordinal") to Name.identifier("ordinal"), - FqName("kotlin.Collection.size") to Name.identifier("size"), - FqName("kotlin.Map.size") to Name.identifier("size"), - FqName("kotlin.CharSequence.length") to Name.identifier("length"), - FqName("kotlin.Map.keys") to Name.identifier("keySet"), - FqName("kotlin.Map.values") to Name.identifier("values"), - FqName("kotlin.Map.entries") to Name.identifier("entrySet") + private val PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP = mapOf( + BUILTIN_NAMES._enum.childSafe("name") to Name.identifier("name"), + BUILTIN_NAMES._enum.childSafe("ordinal") to Name.identifier("ordinal"), + BUILTIN_NAMES.collection.child("size") to Name.identifier("size"), + BUILTIN_NAMES.map.child("size") to Name.identifier("size"), + BUILTIN_NAMES.charSequence.childSafe("length") to Name.identifier("length"), + BUILTIN_NAMES.map.child("keys") to Name.identifier("keySet"), + BUILTIN_NAMES.map.child("values") to Name.identifier("values"), + BUILTIN_NAMES.map.child("entries") to Name.identifier("entrySet") ) private val GETTER_JVM_NAME_TO_PROPERTIES_SHORT_NAME_MAP: Map> = PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP.getInversedShortNamesMap() - private val FQ_NAMES = PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP.keys - internal val SHORT_NAMES = FQ_NAMES.map { it.shortName() }.toSet() + private val SPECIAL_FQ_NAMES = PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP.keys + internal val SPECIAL_SHORT_NAMES = SPECIAL_FQ_NAMES.map { it.shortName() }.toSet() fun hasBuiltinSpecialPropertyFqName(callableMemberDescriptor: CallableMemberDescriptor): Boolean { - if (callableMemberDescriptor.name !in SHORT_NAMES) return false + if (callableMemberDescriptor.name !in SPECIAL_SHORT_NAMES) return false return callableMemberDescriptor.hasBuiltinSpecialPropertyFqNameImpl() } private fun CallableMemberDescriptor.hasBuiltinSpecialPropertyFqNameImpl(): Boolean { - if (fqNameOrNull() in FQ_NAMES) return true + if (fqNameOrNull() in SPECIAL_FQ_NAMES) return true if (!isFromBuiltins()) return false return overriddenDescriptors.any { hasBuiltinSpecialPropertyFqName(it) } @@ -74,9 +79,9 @@ object BuiltinSpecialProperties { object BuiltinMethodsWithSpecialGenericSignature { private val ERASED_COLLECTION_PARAMETER_FQ_NAMES = setOf( - FqName("kotlin.Collection.containsAll"), - FqName("kotlin.MutableCollection.removeAll"), - FqName("kotlin.MutableCollection.retainAll") + BUILTIN_NAMES.collection.child("containsAll"), + BUILTIN_NAMES.mutableCollection.child("removeAll"), + BUILTIN_NAMES.mutableCollection.child("retainAll") ) enum class DefaultValue(val value: Any?) { @@ -84,16 +89,16 @@ object BuiltinMethodsWithSpecialGenericSignature { } private val GENERIC_PARAMETERS_METHODS_TO_DEFAULT_VALUES_MAP = mapOf( - FqName("kotlin.Collection.contains") to DefaultValue.FALSE, - FqName("kotlin.MutableCollection.remove") to DefaultValue.FALSE, - FqName("kotlin.Map.containsKey") to DefaultValue.FALSE, - FqName("kotlin.Map.containsValue") to DefaultValue.FALSE, + BUILTIN_NAMES.collection.child("contains") to DefaultValue.FALSE, + BUILTIN_NAMES.mutableCollection.child("remove") to DefaultValue.FALSE, + BUILTIN_NAMES.map.child("containsKey") to DefaultValue.FALSE, + BUILTIN_NAMES.map.child("containsValue") to DefaultValue.FALSE, - FqName("kotlin.Map.get") to DefaultValue.NULL, - FqName("kotlin.MutableMap.remove") to DefaultValue.NULL, + BUILTIN_NAMES.map.child("get") to DefaultValue.NULL, + BUILTIN_NAMES.mutableMap.child("remove") to DefaultValue.NULL, - FqName("kotlin.List.indexOf") to DefaultValue.INDEX, - FqName("kotlin.List.lastIndexOf") to DefaultValue.INDEX + BUILTIN_NAMES.list.child("indexOf") to DefaultValue.INDEX, + BUILTIN_NAMES.list.child("lastIndexOf") to DefaultValue.INDEX ) private val ERASED_VALUE_PARAMETERS_FQ_NAMES = @@ -153,17 +158,17 @@ object BuiltinMethodsWithSpecialGenericSignature { } object BuiltinMethodsWithDifferentJvmName { - val REMOVE_AT_FQ_NAME = FqName("kotlin.MutableList.removeAt") + val REMOVE_AT_FQ_NAME = BUILTIN_NAMES.mutableList.child("removeAt") val FQ_NAMES_TO_JVM_MAP: Map = mapOf( - FqName("kotlin.Number.toByte") to Name.identifier("byteValue"), - FqName("kotlin.Number.toShort") to Name.identifier("shortValue"), - FqName("kotlin.Number.toInt") to Name.identifier("intValue"), - FqName("kotlin.Number.toLong") to Name.identifier("longValue"), - FqName("kotlin.Number.toFloat") to Name.identifier("floatValue"), - FqName("kotlin.Number.toDouble") to Name.identifier("doubleValue"), - REMOVE_AT_FQ_NAME to Name.identifier("remove"), - FqName("kotlin.CharSequence.get") to Name.identifier("charAt") + BUILTIN_NAMES.number.childSafe("toByte") to Name.identifier("byteValue"), + BUILTIN_NAMES.number.childSafe("toShort") to Name.identifier("shortValue"), + BUILTIN_NAMES.number.childSafe("toInt") to Name.identifier("intValue"), + BUILTIN_NAMES.number.childSafe("toLong") to Name.identifier("longValue"), + BUILTIN_NAMES.number.childSafe("toFloat") to Name.identifier("floatValue"), + BUILTIN_NAMES.number.childSafe("toDouble") to Name.identifier("doubleValue"), + REMOVE_AT_FQ_NAME to Name.identifier("remove"), + BUILTIN_NAMES.charSequence.childSafe("get") to Name.identifier("charAt") ) val ORIGINAL_SHORT_NAMES: List = FQ_NAMES_TO_JVM_MAP.keys.map { it.shortName() } @@ -194,7 +199,7 @@ object BuiltinMethodsWithDifferentJvmName { @Suppress("UNCHECKED_CAST") fun T.getOverriddenBuiltinWithDifferentJvmName(): T? { if (name !in BuiltinMethodsWithDifferentJvmName.ORIGINAL_SHORT_NAMES - && propertyIfAccessor.name !in BuiltinSpecialProperties.SHORT_NAMES) return null + && propertyIfAccessor.name !in BuiltinSpecialProperties.SPECIAL_SHORT_NAMES) return null return when (this) { is PropertyDescriptor, is PropertyAccessorDescriptor -> diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmNameResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmNameResolver.kt index ee23e4a586c..d945d759f17 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmNameResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmNameResolver.kt @@ -120,15 +120,15 @@ class JvmNameResolver( "kotlin/Cloneable", "kotlin/Annotation", - "kotlin/Iterable", "kotlin/MutableIterable", - "kotlin/Collection", "kotlin/MutableCollection", - "kotlin/List", "kotlin/MutableList", - "kotlin/Set", "kotlin/MutableSet", - "kotlin/Map", "kotlin/MutableMap", - "kotlin/Map.Entry", "kotlin/MutableMap.MutableEntry", + "kotlin/collections/Iterable", "kotlin/collections/MutableIterable", + "kotlin/collections/Collection", "kotlin/collections/MutableCollection", + "kotlin/collections/List", "kotlin/collections/MutableList", + "kotlin/collections/Set", "kotlin/collections/MutableSet", + "kotlin/collections/Map", "kotlin/collections/MutableMap", + "kotlin/collections/Map.Entry", "kotlin/collections/MutableMap.MutableEntry", - "kotlin/Iterator", "kotlin/MutableIterator", - "kotlin/ListIterator", "kotlin/MutableListIterator" + "kotlin/collections/Iterator", "kotlin/collections/MutableIterator", + "kotlin/collections/ListIterator", "kotlin/collections/MutableListIterator" ) private val PREDEFINED_STRINGS_MAP = PREDEFINED_STRINGS.withIndex().toMapBy({ it.value }, { it.index }) diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index 204b79656de..22460e17fbd 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -127,6 +127,7 @@ public abstract class KotlinBuiltIns { public final FqNameUnsafe cloneable = fqNameUnsafe("Cloneable"); public final FqNameUnsafe suppress = fqNameUnsafe("Suppress"); public final FqNameUnsafe unit = fqNameUnsafe("Unit"); + public final FqNameUnsafe charSequence = fqNameUnsafe("CharSequence"); public final FqNameUnsafe string = fqNameUnsafe("String"); public final FqNameUnsafe array = fqNameUnsafe("Array"); @@ -138,11 +139,11 @@ public abstract class KotlinBuiltIns { public final FqNameUnsafe _long = fqNameUnsafe("Long"); public final FqNameUnsafe _float = fqNameUnsafe("Float"); public final FqNameUnsafe _double = fqNameUnsafe("Double"); + public final FqNameUnsafe number = fqNameUnsafe("Number"); + + public final FqNameUnsafe _enum = fqNameUnsafe("Enum"); + - public final FqNameUnsafe _collection = fqNameUnsafe("Collection"); - public final FqNameUnsafe _list = fqNameUnsafe("List"); - public final FqNameUnsafe _set = fqNameUnsafe("Set"); - public final FqNameUnsafe _iterable = fqNameUnsafe("Iterable"); public final FqName throwable = fqName("Throwable"); @@ -157,9 +158,23 @@ public abstract class KotlinBuiltIns { public final FqName mustBeDocumented = annotationName("MustBeDocumented"); public final FqName unsafeVariance = fqName("UnsafeVariance"); - public final FqName mutableList = fqName("MutableList"); - public final FqName mutableSet = fqName("MutableSet"); - public final FqName mutableMap = fqName("MutableMap"); + public final FqName iterator = collectionsFqName("Iterator"); + public final FqName iterable = collectionsFqName("Iterable"); + public final FqName collection = collectionsFqName("Collection"); + public final FqName list = collectionsFqName("List"); + public final FqName set = collectionsFqName("Set"); + public final FqName map = collectionsFqName("Map"); + public final FqName mutableIterator = collectionsFqName("MutableIterator"); + public final FqName mutableIterable = collectionsFqName("MutableIterable"); + public final FqName mutableCollection = collectionsFqName("MutableCollection"); + public final FqName mutableList = collectionsFqName("MutableList"); + public final FqName mutableSet = collectionsFqName("MutableSet"); + public final FqName mutableMap = collectionsFqName("MutableMap"); + + private final FqNameUnsafe _collection = collection.toUnsafe(); + private final FqNameUnsafe _list = list.toUnsafe(); + private final FqNameUnsafe _set = set.toUnsafe(); + private final FqNameUnsafe _iterable = iterable.toUnsafe(); public final FqNameUnsafe kClass = reflect("KClass"); public final FqNameUnsafe kCallable = reflect("KCallable"); @@ -189,6 +204,11 @@ public abstract class KotlinBuiltIns { return BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier(simpleName)); } + @NotNull + private static FqName collectionsFqName(@NotNull String simpleName) { + return COLLECTIONS_PACKAGE_FQ_NAME.child(Name.identifier(simpleName)); + } + @NotNull private static FqNameUnsafe reflect(@NotNull String simpleName) { return ReflectionTypesKt.getKOTLIN_REFLECT_FQ_NAME().child(Name.identifier(simpleName)).toUnsafe(); @@ -212,6 +232,21 @@ public abstract class KotlinBuiltIns { return builtinsPackageFragment; } + @NotNull + public BuiltinsPackageFragment getCollectionsPackageFragment() { + return collectionsPackageFragment; + } + + @NotNull + public BuiltinsPackageFragment getRangesPackageFragment() { + return rangesPackageFragment; + } + + @NotNull + public BuiltinsPackageFragment getAnnotationPackageFragment() { + return annotationPackageFragment; + } + public boolean isBuiltInPackageFragment(@Nullable PackageFragmentDescriptor packageFragment) { return packageFragment != null && packageFragment.getContainingDeclaration() == getBuiltInsModule(); } @@ -221,11 +256,6 @@ public abstract class KotlinBuiltIns { return builtinsPackageFragment.getMemberScope(); } - @NotNull - public MemberScope getAnnotationPackageScope() { - return annotationPackageFragment.getMemberScope(); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // GET CLASS @@ -493,62 +523,62 @@ public abstract class KotlinBuiltIns { @NotNull public ClassDescriptor getIterator() { - return getBuiltInClassByName("Iterator"); + return getBuiltInClassByName("Iterator", collectionsPackageFragment); } @NotNull public ClassDescriptor getIterable() { - return getBuiltInClassByName("Iterable"); + return getBuiltInClassByName("Iterable", collectionsPackageFragment); } @NotNull public ClassDescriptor getMutableIterable() { - return getBuiltInClassByName("MutableIterable"); + return getBuiltInClassByName("MutableIterable", collectionsPackageFragment); } @NotNull public ClassDescriptor getMutableIterator() { - return getBuiltInClassByName("MutableIterator"); + return getBuiltInClassByName("MutableIterator", collectionsPackageFragment); } @NotNull public ClassDescriptor getCollection() { - return getBuiltInClassByName("Collection"); + return getBuiltInClassByName("Collection", collectionsPackageFragment); } @NotNull public ClassDescriptor getMutableCollection() { - return getBuiltInClassByName("MutableCollection"); + return getBuiltInClassByName("MutableCollection", collectionsPackageFragment); } @NotNull public ClassDescriptor getList() { - return getBuiltInClassByName("List"); + return getBuiltInClassByName("List", collectionsPackageFragment); } @NotNull public ClassDescriptor getMutableList() { - return getBuiltInClassByName("MutableList"); + return getBuiltInClassByName("MutableList", collectionsPackageFragment); } @NotNull public ClassDescriptor getSet() { - return getBuiltInClassByName("Set"); + return getBuiltInClassByName("Set", collectionsPackageFragment); } @NotNull public ClassDescriptor getMutableSet() { - return getBuiltInClassByName("MutableSet"); + return getBuiltInClassByName("MutableSet", collectionsPackageFragment); } @NotNull public ClassDescriptor getMap() { - return getBuiltInClassByName("Map"); + return getBuiltInClassByName("Map", collectionsPackageFragment); } @NotNull public ClassDescriptor getMutableMap() { - return getBuiltInClassByName("MutableMap"); + return getBuiltInClassByName("MutableMap", collectionsPackageFragment); } @NotNull @@ -567,12 +597,12 @@ public abstract class KotlinBuiltIns { @NotNull public ClassDescriptor getListIterator() { - return getBuiltInClassByName("ListIterator"); + return getBuiltInClassByName("ListIterator", collectionsPackageFragment); } @NotNull public ClassDescriptor getMutableListIterator() { - return getBuiltInClassByName("MutableListIterator"); + return getBuiltInClassByName("MutableListIterator", collectionsPackageFragment); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/PrimitiveType.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/PrimitiveType.java index 8ad2c4283f2..a0fe89fd23e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/PrimitiveType.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/PrimitiveType.java @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.builtins; import org.jetbrains.annotations.NotNull; +import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.Name; import java.util.Collections; @@ -39,6 +40,8 @@ public enum PrimitiveType { private final Name typeName; private final Name arrayTypeName; + private FqName typeFqName = null; + private FqName arrayTypeFqName = null; private PrimitiveType(String typeName) { this.typeName = Name.identifier(typeName); @@ -50,8 +53,26 @@ public enum PrimitiveType { return typeName; } + @NotNull + public FqName getTypeFqName() { + if (typeFqName != null) + return typeFqName; + + typeFqName = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.child(typeName); + return typeFqName; + } + @NotNull public Name getArrayTypeName() { return arrayTypeName; } + + @NotNull + public FqName getArrayTypeFqName() { + if (arrayTypeFqName != null) + return arrayTypeFqName; + + arrayTypeFqName = KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.child(arrayTypeName); + return arrayTypeFqName; + } } diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/collectionsPackage.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/collectionsPackage.kt new file mode 100644 index 00000000000..ac9a1a15fa3 --- /dev/null +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/collectionsPackage.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.collections + +// remove after bootstrapping packages +public class PackagePlaceholder \ No newline at end of file diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/ranges.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/ranges.kt new file mode 100644 index 00000000000..d2344ec2727 --- /dev/null +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/ranges.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.ranges + +// remove after bootstrapping packages +public class PackagePlaceholder \ No newline at end of file diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java index 7cfdf5a43a8..44229280200 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java @@ -147,8 +147,8 @@ public final class TopLevelFIF extends CompositeFIF { add(pattern("kotlin", "arrayOfNulls"), new KotlinFunctionIntrinsic("nullArray")); add(pattern("kotlin", "iterator").isExtensionOf("kotlin.Iterator"), RETURN_RECEIVER_INTRINSIC); - add(pattern("kotlin", "Map", "get").checkOverridden(), NATIVE_MAP_GET); - add(pattern("kotlin.js", "set").isExtensionOf("kotlin.MutableMap"), NATIVE_MAP_SET); + add(pattern("kotlin.collections", "Map", "get").checkOverridden(), NATIVE_MAP_GET); + add(pattern("kotlin.js", "set").isExtensionOf("kotlin.collections.MutableMap"), NATIVE_MAP_SET); add(pattern("java.util", "HashMap", ""), new MapSelectImplementationIntrinsic(false)); add(pattern("java.util", "HashSet", ""), new MapSelectImplementationIntrinsic(true)); diff --git a/js/js.translator/testData/kotlin_lib.js b/js/js.translator/testData/kotlin_lib.js index bd491df87c3..96c5f931455 100644 --- a/js/js.translator/testData/kotlin_lib.js +++ b/js/js.translator/testData/kotlin_lib.js @@ -254,7 +254,7 @@ */ lazyInitClasses.ArrayIterator = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.MutableIterator]; + return [Kotlin.modules['builtins'].kotlin.collections.MutableIterator]; }, /** @constructs */ function (array) { @@ -286,7 +286,7 @@ */ lazyInitClasses.ListIterator = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.ListIterator]; // TODO: MutableListIterator + return [Kotlin.modules['builtins'].kotlin.collections.ListIterator]; // TODO: MutableListIterator }, /** @constructs */ function (list, index) { @@ -358,9 +358,9 @@ lazyInitClasses.AbstractCollection = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.MutableCollection]; + return [Kotlin.modules['builtins'].kotlin.collections.MutableCollection]; }, null, { - addAll_4fm7v2$: function (collection) { + addAll_wtfk93$: function (collection) { var modified = false; var it = collection.iterator(); while (it.hasNext()) { @@ -370,7 +370,7 @@ } return modified }, - removeAll_4fm7v2$: function (c) { + removeAll_wtfk93$: function (c) { var modified = false; var it = this.iterator(); while (it.hasNext()) { @@ -381,7 +381,7 @@ } return modified }, - retainAll_4fm7v2$: function (c) { + retainAll_wtfk93$: function (c) { var modified = false; var it = this.iterator(); while (it.hasNext()) { @@ -396,7 +396,7 @@ // TODO: implement with mutable iterator throw new Kotlin.NotImplementedError("Not implemented yet, see KT-7809"); }, - containsAll_4fm7v2$: function (c) { + containsAll_wtfk93$: function (c) { var it = c.iterator(); while (it.hasNext()) { if (!this.contains_za3rmp$(it.next())) return false; @@ -452,7 +452,7 @@ */ lazyInitClasses.AbstractList = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.MutableList, Kotlin.AbstractCollection]; + return [Kotlin.modules['builtins'].kotlin.collections.MutableList, Kotlin.AbstractCollection]; }, null, { iterator: function () { return new Kotlin.ListIterator(this); @@ -470,7 +470,7 @@ this.add_vux3hl$(this.size, element); return true; }, - addAll_9cca64$: function (index, collection) { + addAll_j97iir$: function (index, collection) { // TODO: implement throw new Kotlin.NotImplementedError("Not implemented yet, see KT-7809"); }, @@ -594,7 +594,7 @@ add_vux3hl$: function (index, element) { this.array.splice(index, 0, element); }, - addAll_4fm7v2$: function (collection) { + addAll_wtfk93$: function (collection) { if (collection.size == 0) { return false; } @@ -770,7 +770,7 @@ lazyInitClasses.RangeIterator = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.Iterator]; + return [Kotlin.modules['builtins'].kotlin.collections.Iterator]; }, function (start, end, step) { this.start = start; @@ -856,7 +856,7 @@ lazyInitClasses.NumberProgression = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.Iterable]; + return [Kotlin.modules['builtins'].kotlin.collections.Iterable]; }, function (start, end, step) { this.start = start; @@ -921,7 +921,7 @@ lazyInitClasses.LongRangeIterator = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.Iterator]; + return [Kotlin.modules['builtins'].kotlin.collections.Iterator]; }, function (start, end, step) { this.start = start; @@ -944,7 +944,7 @@ lazyInitClasses.LongProgression = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.Iterable]; + return [Kotlin.modules['builtins'].kotlin.collections.Iterable]; }, function (start, end, step) { this.start = start; @@ -1023,7 +1023,7 @@ lazyInitClasses.CharProgression = Kotlin.createClassNow( function () { - return [Kotlin.modules['builtins'].kotlin.Iterable]; + return [Kotlin.modules['builtins'].kotlin.collections.Iterable]; }, function (start, end, step) { this.start = start; diff --git a/js/js.translator/testData/maps.js b/js/js.translator/testData/maps.js index c00a9339c2d..6dfea9dfbd0 100644 --- a/js/js.translator/testData/maps.js +++ b/js/js.translator/testData/maps.js @@ -63,7 +63,7 @@ function hashSetEquals(o) { if (o == null || this.size !== o.size) return false; - return this.containsAll_4fm7v2$(o); + return this.containsAll_wtfk93$(o); } function hashSetHashCode() { @@ -424,11 +424,11 @@ /** * @param {Hashtable.} hashtable */ - this.putAll_48yl7j$ = hashMapPutAll; + this.putAll_r12sna$ = hashMapPutAll; this.clone = function () { var clone = new Hashtable(hashingFunctionParam, equalityFunctionParam); - clone.putAll_48yl7j$(that); + clone.putAll_r12sna$(that); return clone; }; @@ -515,7 +515,7 @@ lazyInitClasses.HashMap = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.MutableMap]; + return [Kotlin.modules['builtins'].kotlin.collections.MutableMap]; }, function () { Kotlin.HashTable.call(this); @@ -535,7 +535,7 @@ */ lazyInitClasses.PrimitiveHashMapValuesIterator = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.Iterator]; + return [Kotlin.modules['builtins'].kotlin.collections.Iterator]; }, function (map, keys) { this.map = map; @@ -645,7 +645,7 @@ this.$size = 0; this.map = {}; }, - putAll_48yl7j$: hashMapPutAll, + putAll_r12sna$: hashMapPutAll, entries: { get: function () { var result = new Kotlin.ComplexHashSet(); @@ -840,7 +840,7 @@ lazyInitClasses.LinkedHashSet = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.MutableSet, Kotlin.HashSet]; + return [Kotlin.modules['builtins'].kotlin.collections.MutableSet, Kotlin.HashSet]; }, /** @constructs */ function () { @@ -882,7 +882,7 @@ */ lazyInitClasses.SetIterator = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.MutableIterator]; + return [Kotlin.modules['builtins'].kotlin.collections.MutableIterator]; }, function (set) { this.set = set; @@ -1027,10 +1027,10 @@ function HashSet(hashingFunction, equalityFunction) { var hashTable = new Kotlin.HashTable(hashingFunction, equalityFunction); - this.addAll_4fm7v2$ = Kotlin.AbstractCollection.prototype.addAll_4fm7v2$; - this.removeAll_4fm7v2$ = Kotlin.AbstractCollection.prototype.removeAll_4fm7v2$; - this.retainAll_4fm7v2$ = Kotlin.AbstractCollection.prototype.retainAll_4fm7v2$; - this.containsAll_4fm7v2$ = Kotlin.AbstractCollection.prototype.containsAll_4fm7v2$; + this.addAll_wtfk93$ = Kotlin.AbstractCollection.prototype.addAll_wtfk93$; + this.removeAll_wtfk93$ = Kotlin.AbstractCollection.prototype.removeAll_wtfk93$; + this.retainAll_wtfk93$ = Kotlin.AbstractCollection.prototype.retainAll_wtfk93$; + this.containsAll_wtfk93$ = Kotlin.AbstractCollection.prototype.containsAll_wtfk93$; this.add_za3rmp$ = function (o) { return !hashTable.put_wn2jw4$(o, true); @@ -1067,7 +1067,7 @@ this.clone = function () { var h = new HashSet(hashingFunction, equalityFunction); - h.addAll_4fm7v2$(hashTable.keys()); + h.addAll_wtfk93$(hashTable.keys()); return h; }; @@ -1129,7 +1129,7 @@ lazyInitClasses.HashSet = Kotlin.createClass( function () { - return [Kotlin.modules['builtins'].kotlin.MutableSet, Kotlin.AbstractCollection]; + return [Kotlin.modules['builtins'].kotlin.collections.MutableSet, Kotlin.AbstractCollection]; }, function () { HashSet.call(this);