Minor optimization in KotlinBuiltIns.isSpecialClassWithNoSupertypes
This commit is contained in:
@@ -95,7 +95,7 @@ public class BuiltInsSerializer(val out: PrintStream?) {
|
||||
|
||||
val serializer = DescriptorSerializer(object : SerializerExtension() {
|
||||
override fun hasSupertypes(descriptor: ClassDescriptor): Boolean =
|
||||
!KotlinBuiltIns.isSpecialClassWithNoSupertypes(descriptor)
|
||||
!KotlinBuiltIns.getInstance().isSpecialClassWithNoSupertypes(descriptor)
|
||||
})
|
||||
|
||||
val classNames = ArrayList<Name>()
|
||||
|
||||
+1
-1
@@ -473,7 +473,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
new Function0<Supertypes>() {
|
||||
@Override
|
||||
public Supertypes invoke() {
|
||||
if (KotlinBuiltIns.isSpecialClassWithNoSupertypes(LazyClassDescriptor.this)) {
|
||||
if (KotlinBuiltIns.getInstance().isSpecialClassWithNoSupertypes(LazyClassDescriptor.this)) {
|
||||
return new Supertypes(Collections.<JetType>emptyList());
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ public class DescriptorValidator {
|
||||
|
||||
Collection<JetType> supertypes = descriptor.getTypeConstructor().getSupertypes();
|
||||
if (supertypes.isEmpty() && descriptor.getKind() != ClassKind.TRAIT
|
||||
&& !KotlinBuiltIns.isSpecialClassWithNoSupertypes(descriptor)) {
|
||||
&& !KotlinBuiltIns.getInstance().isSpecialClassWithNoSupertypes(descriptor)) {
|
||||
report(collector, descriptor, "No supertypes for non-trait");
|
||||
}
|
||||
validateTypes(descriptor, collector, supertypes);
|
||||
|
||||
@@ -143,6 +143,8 @@ public class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
private static class FqNames {
|
||||
public final FqNameUnsafe any = fqName("Any");
|
||||
public final FqNameUnsafe nothing = fqName("Nothing");
|
||||
public final FqNameUnsafe suppress = fqName("suppress");
|
||||
|
||||
@NotNull
|
||||
@@ -792,10 +794,9 @@ public class KotlinBuiltIns {
|
||||
|
||||
// Recognized & special
|
||||
|
||||
public static boolean isSpecialClassWithNoSupertypes(@NotNull ClassDescriptor descriptor) {
|
||||
public boolean isSpecialClassWithNoSupertypes(@NotNull ClassDescriptor descriptor) {
|
||||
FqNameUnsafe fqName = DescriptorUtils.getFqName(descriptor);
|
||||
return BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("Any")).toUnsafe().equals(fqName) ||
|
||||
BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("Nothing")).toUnsafe().equals(fqName);
|
||||
return fqNames.any.equals(fqName) || fqNames.nothing.equals(fqName);
|
||||
}
|
||||
|
||||
public boolean isNothing(@NotNull JetType type) {
|
||||
|
||||
Reference in New Issue
Block a user