Packages: move Ranges, Progression, ProgressionIterators to kotlin.ranges and PrimitiveIterators to kotlin.collections.

This commit is contained in:
Ilya Gorbunov
2015-11-23 21:37:29 +03:00
parent a3efa1ea6c
commit 9fbbc9db98
18 changed files with 84 additions and 49 deletions
+1 -1
View File
@@ -16,7 +16,7 @@
// Auto-generated file. DO NOT EDIT!
package kotlin
package kotlin.collections
/** An iterator over a sequence of values of type `Byte`. */
public abstract class ByteIterator : Iterator<Byte> {
@@ -16,7 +16,7 @@
// Auto-generated file. DO NOT EDIT!
package kotlin
package kotlin.ranges
/**
* An iterator over a progression of values of type `Byte`.
+1 -1
View File
@@ -16,7 +16,7 @@
// Auto-generated file. DO NOT EDIT!
package kotlin
package kotlin.ranges
import kotlin.internal.getProgressionLastElement
+1 -1
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package kotlin
package kotlin.ranges
/**
* Represents a range of values (for example, numbers or characters).
+1 -1
View File
@@ -16,7 +16,7 @@
// Auto-generated file. DO NOT EDIT!
package kotlin
package kotlin.ranges
@Deprecated("Use IntRange instead.", ReplaceWith("IntRange"), level = DeprecationLevel.WARNING)
/**
@@ -274,7 +274,7 @@ fun ClassDescriptor.hasRealKotlinSuperClassWithOverrideOf(
if (doesOverrideBuiltinDeclaration) {
val containingPackageFragment = DescriptorUtils.getParentOfType(superClassDescriptor, PackageFragmentDescriptor::class.java)
if (containingPackageFragment === superClassDescriptor.builtIns.builtInsPackageFragment) return false
if (superClassDescriptor.builtIns.isBuiltInPackageFragment(containingPackageFragment)) return false
return true
}
}
@@ -50,15 +50,21 @@ public abstract class KotlinBuiltIns {
public static final Name BUILT_INS_PACKAGE_NAME = Name.identifier("kotlin");
public static final FqName BUILT_INS_PACKAGE_FQ_NAME = FqName.topLevel(BUILT_INS_PACKAGE_NAME);
public static final FqName ANNOTATION_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("annotation"));
public static final FqName COLLECTIONS_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("collections"));
public static final FqName RANGES_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("ranges"));
public static final Set<FqName> BUILT_INS_PACKAGE_FQ_NAMES = setOf(
BUILT_INS_PACKAGE_FQ_NAME,
COLLECTIONS_PACKAGE_FQ_NAME,
RANGES_PACKAGE_FQ_NAME,
ANNOTATION_PACKAGE_FQ_NAME,
ReflectionTypesKt.getKOTLIN_REFLECT_FQ_NAME()
);
protected final ModuleDescriptorImpl builtInsModule;
private final BuiltinsPackageFragment builtinsPackageFragment;
private final BuiltinsPackageFragment collectionsPackageFragment;
private final BuiltinsPackageFragment rangesPackageFragment;
private final BuiltinsPackageFragment annotationPackageFragment;
private final Map<PrimitiveType, KotlinType> primitiveTypeToArrayKotlinType;
@@ -89,6 +95,8 @@ public abstract class KotlinBuiltIns {
builtInsModule.setDependencies(builtInsModule);
builtinsPackageFragment = (BuiltinsPackageFragment) single(packageFragmentProvider.getPackageFragments(BUILT_INS_PACKAGE_FQ_NAME));
collectionsPackageFragment = (BuiltinsPackageFragment) single(packageFragmentProvider.getPackageFragments(COLLECTIONS_PACKAGE_FQ_NAME));
rangesPackageFragment = (BuiltinsPackageFragment) single(packageFragmentProvider.getPackageFragments(RANGES_PACKAGE_FQ_NAME));
annotationPackageFragment = (BuiltinsPackageFragment) single(packageFragmentProvider.getPackageFragments(ANNOTATION_PACKAGE_FQ_NAME));
primitiveTypeToArrayKotlinType = new EnumMap<PrimitiveType, KotlinType>(PrimitiveType.class);
@@ -204,6 +212,10 @@ public abstract class KotlinBuiltIns {
return builtinsPackageFragment;
}
public boolean isBuiltInPackageFragment(@Nullable PackageFragmentDescriptor packageFragment) {
return packageFragment != null && packageFragment.getContainingDeclaration() == getBuiltInsModule();
}
@NotNull
public MemberScope getBuiltInsPackageScope() {
return builtinsPackageFragment.getMemberScope();
@@ -222,24 +234,32 @@ public abstract class KotlinBuiltIns {
@NotNull
public ClassDescriptor getAnnotationClassByName(@NotNull Name simpleName) {
ClassifierDescriptor classifier = annotationPackageFragment.getMemberScope().getContributedClassifier(simpleName,
NoLookupLocation.FROM_BUILTINS);
assert classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " +
(classifier == null ? "null" : classifier.toString());
return (ClassDescriptor) classifier;
return getBuiltInClassByName(simpleName, annotationPackageFragment);
}
@NotNull
public ClassDescriptor getBuiltInClassByName(@NotNull Name simpleName) {
ClassDescriptor classDescriptor = getBuiltInClassByNameNullable(simpleName);
return getBuiltInClassByName(simpleName, getBuiltInsPackageFragment());
}
@NotNull
private static ClassDescriptor getBuiltInClassByName(@NotNull Name simpleName, @NotNull PackageFragmentDescriptor packageFragment) {
ClassDescriptor classDescriptor = getBuiltInClassByNameNullable(simpleName, packageFragment);
assert classDescriptor != null : "Built-in class " + simpleName + " is not found";
return classDescriptor;
}
@Nullable
public ClassDescriptor getBuiltInClassByNameNullable(@NotNull Name simpleName) {
ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getContributedClassifier(simpleName,
NoLookupLocation.FROM_BUILTINS);
return getBuiltInClassByNameNullable(simpleName, getBuiltInsPackageFragment());
}
@Nullable
private static ClassDescriptor getBuiltInClassByNameNullable(@NotNull Name simpleName, @NotNull PackageFragmentDescriptor packageFragment) {
ClassifierDescriptor classifier = packageFragment.getMemberScope().getContributedClassifier(
simpleName,
NoLookupLocation.FROM_BUILTINS);
assert classifier == null ||
classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " + classifier;
return (ClassDescriptor) classifier;
@@ -250,6 +270,13 @@ public abstract class KotlinBuiltIns {
return getBuiltInClassByName(Name.identifier(simpleName));
}
@NotNull
private static ClassDescriptor getBuiltInClassByName(@NotNull String simpleName, PackageFragmentDescriptor packageFragment) {
return getBuiltInClassByName(Name.identifier(simpleName), packageFragment);
}
// Special
@NotNull
@@ -314,10 +341,10 @@ public abstract class KotlinBuiltIns {
@NotNull
public Set<DeclarationDescriptor> getIntegralRanges() {
return SetsKt.<DeclarationDescriptor>setOf(
getBuiltInClassByName("ByteRange"),
getBuiltInClassByName("ShortRange"),
getBuiltInClassByName("CharRange"),
getBuiltInClassByName("IntRange")
getBuiltInClassByName("ByteRange", rangesPackageFragment),
getBuiltInClassByName("ShortRange", rangesPackageFragment),
getBuiltInClassByName("CharRange", rangesPackageFragment),
getBuiltInClassByName("IntRange", rangesPackageFragment)
);
}