is<Annotation>() made static in KotlinBuiltIns
This commit is contained in:
@@ -289,11 +289,11 @@ public class AsmUtil {
|
|||||||
|
|
||||||
public static int getDeprecatedAccessFlag(@NotNull MemberDescriptor descriptor) {
|
public static int getDeprecatedAccessFlag(@NotNull MemberDescriptor descriptor) {
|
||||||
if (descriptor instanceof PropertyAccessorDescriptor) {
|
if (descriptor instanceof PropertyAccessorDescriptor) {
|
||||||
return KotlinBuiltIns.getInstance().isDeprecated(descriptor)
|
return KotlinBuiltIns.isDeprecated(descriptor)
|
||||||
? ACC_DEPRECATED
|
? ACC_DEPRECATED
|
||||||
: getDeprecatedAccessFlag(((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty());
|
: getDeprecatedAccessFlag(((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty());
|
||||||
}
|
}
|
||||||
else if (KotlinBuiltIns.getInstance().isDeprecated(descriptor)) {
|
else if (KotlinBuiltIns.isDeprecated(descriptor)) {
|
||||||
return ACC_DEPRECATED;
|
return ACC_DEPRECATED;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
if (isAnnotation) {
|
if (isAnnotation) {
|
||||||
access |= ACC_ANNOTATION;
|
access |= ACC_ANNOTATION;
|
||||||
}
|
}
|
||||||
if (KotlinBuiltIns.getInstance().isDeprecated(descriptor)) {
|
if (KotlinBuiltIns.isDeprecated(descriptor)) {
|
||||||
access |= ACC_DEPRECATED;
|
access |= ACC_DEPRECATED;
|
||||||
}
|
}
|
||||||
if (isEnum) {
|
if (isEnum) {
|
||||||
@@ -514,7 +514,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateFunctionsForDataClasses() {
|
private void generateFunctionsForDataClasses() {
|
||||||
if (!KotlinBuiltIns.getInstance().isData(descriptor)) return;
|
if (!KotlinBuiltIns.isData(descriptor)) return;
|
||||||
|
|
||||||
new DataClassMethodGeneratorImpl(myClass, bindingContext).generate();
|
new DataClassMethodGeneratorImpl(myClass, bindingContext).generate();
|
||||||
}
|
}
|
||||||
@@ -797,7 +797,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
new DefaultParameterValueLoader() {
|
new DefaultParameterValueLoader() {
|
||||||
@Override
|
@Override
|
||||||
public StackValue genValue(ValueParameterDescriptor valueParameter, ExpressionCodegen codegen) {
|
public StackValue genValue(ValueParameterDescriptor valueParameter, ExpressionCodegen codegen) {
|
||||||
assert KotlinBuiltIns.getInstance().isData((ClassDescriptor) function.getContainingDeclaration())
|
assert KotlinBuiltIns.isData((ClassDescriptor) function.getContainingDeclaration())
|
||||||
: "Function container should be annotated with [data]: " + function;
|
: "Function container should be annotated with [data]: " + function;
|
||||||
PropertyDescriptor property = bindingContext.get(BindingContext.VALUE_PARAMETER_AS_PROPERTY, valueParameter);
|
PropertyDescriptor property = bindingContext.get(BindingContext.VALUE_PARAMETER_AS_PROPERTY, valueParameter);
|
||||||
assert property != null : "Copy function doesn't correspond to any property: " + function;
|
assert property != null : "Copy function doesn't correspond to any property: " + function;
|
||||||
|
|||||||
@@ -745,7 +745,7 @@ public class JetFlowInformationProvider {
|
|||||||
public void markTailCalls() {
|
public void markTailCalls() {
|
||||||
final DeclarationDescriptor subroutineDescriptor = trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, subroutine);
|
final DeclarationDescriptor subroutineDescriptor = trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, subroutine);
|
||||||
if (!(subroutineDescriptor instanceof FunctionDescriptor)) return;
|
if (!(subroutineDescriptor instanceof FunctionDescriptor)) return;
|
||||||
if (!KotlinBuiltIns.getInstance().isTailRecursive(subroutineDescriptor)) return;
|
if (!KotlinBuiltIns.isTailRecursive(subroutineDescriptor)) return;
|
||||||
|
|
||||||
// finally blocks are copied which leads to multiple diagnostics reported on one instruction
|
// finally blocks are copied which leads to multiple diagnostics reported on one instruction
|
||||||
class KindAndCall {
|
class KindAndCall {
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ public class DeclarationResolver {
|
|||||||
JetClassOrObject klass = entry.getKey();
|
JetClassOrObject klass = entry.getKey();
|
||||||
MutableClassDescriptor classDescriptor = (MutableClassDescriptor) entry.getValue();
|
MutableClassDescriptor classDescriptor = (MutableClassDescriptor) entry.getValue();
|
||||||
|
|
||||||
if (klass instanceof JetClass && KotlinBuiltIns.getInstance().isData(classDescriptor)) {
|
if (klass instanceof JetClass && KotlinBuiltIns.isData(classDescriptor)) {
|
||||||
List<ValueParameterDescriptor> parameters =
|
List<ValueParameterDescriptor> parameters =
|
||||||
klass.hasPrimaryConstructor() ?
|
klass.hasPrimaryConstructor() ?
|
||||||
getConstructorOfDataClass(classDescriptor).getValueParameters() :
|
getConstructorOfDataClass(classDescriptor).getValueParameters() :
|
||||||
|
|||||||
+2
-2
@@ -130,7 +130,7 @@ public open class LazyClassMemberScope(resolveSession: ResolveSession,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun generateDataClassMethods(result: MutableCollection<FunctionDescriptor>, name: Name) {
|
private fun generateDataClassMethods(result: MutableCollection<FunctionDescriptor>, name: Name) {
|
||||||
if (!KotlinBuiltIns.getInstance().isData(thisDescriptor)) return
|
if (!KotlinBuiltIns.isData(thisDescriptor)) return
|
||||||
|
|
||||||
val constructor = getPrimaryConstructor()
|
val constructor = getPrimaryConstructor()
|
||||||
if (constructor == null) return
|
if (constructor == null) return
|
||||||
@@ -240,7 +240,7 @@ public open class LazyClassMemberScope(resolveSession: ResolveSession,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addDataClassMethods(result: MutableCollection<DeclarationDescriptor>) {
|
private fun addDataClassMethods(result: MutableCollection<DeclarationDescriptor>) {
|
||||||
if (!KotlinBuiltIns.getInstance().isData(thisDescriptor)) return
|
if (!KotlinBuiltIns.isData(thisDescriptor)) return
|
||||||
|
|
||||||
if (getPrimaryConstructor() == null) return
|
if (getPrimaryConstructor() == null) return
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import java.util.List;
|
|||||||
public class InlineUtil {
|
public class InlineUtil {
|
||||||
|
|
||||||
public static boolean hasNoinlineAnnotation(@NotNull CallableDescriptor valueParameterDescriptor) {
|
public static boolean hasNoinlineAnnotation(@NotNull CallableDescriptor valueParameterDescriptor) {
|
||||||
return KotlinBuiltIns.containsAnnotation(valueParameterDescriptor, KotlinBuiltIns.getInstance().getNoinlineClassAnnotation());
|
return KotlinBuiltIns.containsAnnotation(valueParameterDescriptor, KotlinBuiltIns.getNoinlineClassAnnotationFqName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -149,26 +149,34 @@ public class KotlinBuiltIns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class FqNames {
|
private static class FqNames {
|
||||||
public final FqNameUnsafe any = fqName("Any");
|
public final FqNameUnsafe any = fqNameUnsafe("Any");
|
||||||
public final FqNameUnsafe nothing = fqName("Nothing");
|
public final FqNameUnsafe nothing = fqNameUnsafe("Nothing");
|
||||||
public final FqNameUnsafe cloneable = fqName("Cloneable");
|
public final FqNameUnsafe cloneable = fqNameUnsafe("Cloneable");
|
||||||
public final FqNameUnsafe suppress = fqName("suppress");
|
public final FqNameUnsafe suppress = fqNameUnsafe("suppress");
|
||||||
public final FqNameUnsafe unit = fqName("Unit");
|
public final FqNameUnsafe unit = fqNameUnsafe("Unit");
|
||||||
public final FqNameUnsafe string = fqName("String");
|
public final FqNameUnsafe string = fqNameUnsafe("String");
|
||||||
|
public final FqName data = fqName("data");
|
||||||
|
public final FqName deprecated = fqName("deprecated");
|
||||||
|
public final FqName tailRecursive = fqName("tailRecursive");
|
||||||
|
public final FqName noinline = fqName("noinline");
|
||||||
|
|
||||||
public final Set<FqNameUnsafe> functionClasses = computeIndexedFqNames("Function", FUNCTION_TRAIT_COUNT);
|
public final Set<FqNameUnsafe> functionClasses = computeIndexedFqNames("Function", FUNCTION_TRAIT_COUNT);
|
||||||
public final Set<FqNameUnsafe> extensionFunctionClasses = computeIndexedFqNames("ExtensionFunction", FUNCTION_TRAIT_COUNT);
|
public final Set<FqNameUnsafe> extensionFunctionClasses = computeIndexedFqNames("ExtensionFunction", FUNCTION_TRAIT_COUNT);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static FqNameUnsafe fqName(@NotNull String simpleName) {
|
private static FqNameUnsafe fqNameUnsafe(@NotNull String simpleName) {
|
||||||
return BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier(simpleName)).toUnsafe();
|
return fqName(simpleName).toUnsafe();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static FqName fqName(String simpleName) {
|
||||||
|
return BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier(simpleName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Set<FqNameUnsafe> computeIndexedFqNames(@NotNull String prefix, int count) {
|
private static Set<FqNameUnsafe> computeIndexedFqNames(@NotNull String prefix, int count) {
|
||||||
Set<FqNameUnsafe> result = new HashSet<FqNameUnsafe>();
|
Set<FqNameUnsafe> result = new HashSet<FqNameUnsafe>();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
result.add(fqName(prefix + i));
|
result.add(fqNameUnsafe(prefix + i));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -326,8 +334,8 @@ public class KotlinBuiltIns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ClassDescriptor getNoinlineClassAnnotation() {
|
public static FqName getNoinlineClassAnnotationFqName() {
|
||||||
return getBuiltInClassByName("noinline");
|
return FQ_NAMES.noinline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -340,11 +348,6 @@ public class KotlinBuiltIns {
|
|||||||
return getBuiltInClassByName("inlineOptions");
|
return getBuiltInClassByName("inlineOptions");
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public ClassDescriptor getTailRecursiveAnnotationClass() {
|
|
||||||
return getBuiltInClassByName("tailRecursive");
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ClassDescriptor getDeprecatedAnnotation() {
|
public ClassDescriptor getDeprecatedAnnotation() {
|
||||||
return getBuiltInClassByName("deprecated");
|
return getBuiltInClassByName("deprecated");
|
||||||
@@ -876,25 +879,24 @@ public class KotlinBuiltIns {
|
|||||||
return FQ_NAMES.cloneable.equals(DescriptorUtils.getFqName(descriptor));
|
return FQ_NAMES.cloneable.equals(DescriptorUtils.getFqName(descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isData(@NotNull ClassDescriptor classDescriptor) {
|
public static boolean isData(@NotNull ClassDescriptor classDescriptor) {
|
||||||
return containsAnnotation(classDescriptor, getDataClassAnnotation());
|
return containsAnnotation(classDescriptor, FQ_NAMES.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeprecated(@NotNull DeclarationDescriptor declarationDescriptor) {
|
public static boolean isDeprecated(@NotNull DeclarationDescriptor declarationDescriptor) {
|
||||||
return containsAnnotation(declarationDescriptor, getDeprecatedAnnotation());
|
return containsAnnotation(declarationDescriptor, FQ_NAMES.deprecated);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTailRecursive(@NotNull DeclarationDescriptor declarationDescriptor) {
|
public static boolean isTailRecursive(@NotNull DeclarationDescriptor declarationDescriptor) {
|
||||||
return containsAnnotation(declarationDescriptor, getTailRecursiveAnnotationClass());
|
return containsAnnotation(declarationDescriptor, FQ_NAMES.tailRecursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSuppressAnnotation(@NotNull AnnotationDescriptor annotationDescriptor) {
|
public static boolean isSuppressAnnotation(@NotNull AnnotationDescriptor annotationDescriptor) {
|
||||||
return isConstructedFromGivenClass(annotationDescriptor.getType(), FQ_NAMES.suppress);
|
return isConstructedFromGivenClass(annotationDescriptor.getType(), FQ_NAMES.suppress);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean containsAnnotation(DeclarationDescriptor descriptor, ClassDescriptor annotationClass) {
|
static boolean containsAnnotation(DeclarationDescriptor descriptor, FqName annotationClassFqName) {
|
||||||
FqName fqName = DescriptorUtils.getFqName(annotationClass).toSafe();
|
return descriptor.getOriginal().getAnnotations().findAnnotation(annotationClassFqName) != null;
|
||||||
return descriptor.getOriginal().getAnnotations().findAnnotation(fqName) != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ private object KindWeigher : LookupElementWeigher("kotlin.kind") {
|
|||||||
private object DeprecatedWeigher : LookupElementWeigher("kotlin.deprecated") {
|
private object DeprecatedWeigher : LookupElementWeigher("kotlin.deprecated") {
|
||||||
override fun weigh(element: LookupElement): Int {
|
override fun weigh(element: LookupElement): Int {
|
||||||
val o = element.getObject()
|
val o = element.getObject()
|
||||||
return if (o is DeclarationDescriptorLookupObject && KotlinBuiltIns.getInstance().isDeprecated(o.descriptor)) 1 else 0
|
return if (o is DeclarationDescriptorLookupObject && KotlinBuiltIns.isDeprecated(o.descriptor)) 1 else 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public open class LookupElementFactory protected() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KotlinBuiltIns.getInstance().isDeprecated(descriptor)) {
|
if (KotlinBuiltIns.isDeprecated(descriptor)) {
|
||||||
element = element.withStrikeoutness(true)
|
element = element.withStrikeoutness(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -225,7 +225,7 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith
|
|||||||
int boldStartOffset = -1;
|
int boldStartOffset = -1;
|
||||||
int boldEndOffset = -1;
|
int boldEndOffset = -1;
|
||||||
boolean isGrey = false;
|
boolean isGrey = false;
|
||||||
boolean isDeprecated = KotlinBuiltIns.getInstance().isDeprecated(functionDescriptor);
|
boolean isDeprecated = KotlinBuiltIns.isDeprecated(functionDescriptor);
|
||||||
|
|
||||||
boolean[] usedIndexes = new boolean[valueParameters.size()];
|
boolean[] usedIndexes = new boolean[valueParameters.size()];
|
||||||
Arrays.fill(usedIndexes, false);
|
Arrays.fill(usedIndexes, false);
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public final class ClassTranslator extends AbstractTranslator {
|
|||||||
bodyVisitor.traverseContainer(classDeclaration, declarationContext);
|
bodyVisitor.traverseContainer(classDeclaration, declarationContext);
|
||||||
delegationTranslator.generateDelegated(properties);
|
delegationTranslator.generateDelegated(properties);
|
||||||
|
|
||||||
if (KotlinBuiltIns.getInstance().isData(descriptor)) {
|
if (KotlinBuiltIns.isData(descriptor)) {
|
||||||
new JsDataClassGenerator(classDeclaration, declarationContext, properties).generate();
|
new JsDataClassGenerator(classDeclaration, declarationContext, properties).generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user