Introduce kotlin.Cloneable
- Cloneable is a trait with a single protected member 'clone', which is mapped to java.lang.Cloneable on JVM - 'clone' is non-abstract to be able to call 'super.clone()' in the implementations. Also if you need your class to be Cloneable, most of the time inheriting from Cloneable and calling 'super.clone()' will work - hack 'super.clone()' in JVM intrinsics and TImpl delegation generation - make arrays Cloneable, handle 'clone()' calls in the intrinsic #KT-4890 Fixed
This commit is contained in:
@@ -138,6 +138,7 @@ public class KotlinBuiltIns {
|
||||
private static class FqNames {
|
||||
public final FqNameUnsafe any = fqName("Any");
|
||||
public final FqNameUnsafe nothing = fqName("Nothing");
|
||||
public final FqNameUnsafe cloneable = fqName("Cloneable");
|
||||
public final FqNameUnsafe suppress = fqName("suppress");
|
||||
|
||||
public final ImmutableSet<FqNameUnsafe> functionClasses = computeIndexedFqNames("Function", FUNCTION_TRAIT_COUNT);
|
||||
@@ -300,6 +301,11 @@ public class KotlinBuiltIns {
|
||||
return getBuiltInClassByName("Throwable");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getCloneable() {
|
||||
return getBuiltInClassByName("Cloneable");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getDataClassAnnotation() {
|
||||
return getBuiltInClassByName("data");
|
||||
@@ -841,6 +847,10 @@ public class KotlinBuiltIns {
|
||||
return !(type instanceof PackageType) && getStringType().equals(type);
|
||||
}
|
||||
|
||||
public boolean isCloneable(@NotNull ClassDescriptor descriptor) {
|
||||
return fqNames.cloneable.equals(DescriptorUtils.getFqName(descriptor));
|
||||
}
|
||||
|
||||
public boolean isData(@NotNull ClassDescriptor classDescriptor) {
|
||||
return containsAnnotation(classDescriptor, getDataClassAnnotation());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user