Rename isHeader to isExpect in descriptors
This commit is contained in:
committed by
Mikhail Glukhikh
parent
fd6eab38e5
commit
c8ee424f67
+1
-1
@@ -296,7 +296,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
source: SourceElement
|
||||
) : SyntheticJavaPropertyDescriptor, PropertyDescriptorImpl(
|
||||
containingDeclaration, original, annotations, modality, visibility, isVar, name, kind, source,
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isHeader = */ false, /* isImpl = */ false, /* isExternal = */ false,
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isExpect = */ false, /* isImpl = */ false, /* isExternal = */ false,
|
||||
/* isDelegated = */ false
|
||||
) {
|
||||
|
||||
|
||||
@@ -645,7 +645,7 @@ class ControlFlowInformationProvider private constructor(
|
||||
is KtPrimaryConstructor -> if (!element.hasValOrVar()) {
|
||||
val containingClass = owner.getContainingClassOrObject()
|
||||
val containingClassDescriptor = trace.get(DECLARATION_TO_DESCRIPTOR, containingClass) as? ClassDescriptor
|
||||
if (!DescriptorUtils.isAnnotationClass(containingClassDescriptor) && containingClassDescriptor?.isHeader == false &&
|
||||
if (!DescriptorUtils.isAnnotationClass(containingClassDescriptor) && containingClassDescriptor?.isExpect == false &&
|
||||
!containingClassDescriptor.isEffectivelyExternal()
|
||||
) {
|
||||
report(UNUSED_PARAMETER.on(element, variableDescriptor), ctxt)
|
||||
@@ -665,7 +665,7 @@ class ControlFlowInformationProvider private constructor(
|
||||
if (isMain
|
||||
|| functionDescriptor.isOverridableOrOverrides
|
||||
|| owner.hasModifier(KtTokens.OVERRIDE_KEYWORD)
|
||||
|| functionDescriptor.isHeader || functionDescriptor.isImpl
|
||||
|| functionDescriptor.isExpect || functionDescriptor.isImpl
|
||||
|| functionDescriptor.isEffectivelyExternal()
|
||||
|| OperatorNameConventions.GET_VALUE == functionName
|
||||
|| OperatorNameConventions.SET_VALUE == functionName
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ class SyntheticClassOrObjectDescriptor(
|
||||
override fun isCompanionObject() = isCompanionObject
|
||||
override fun isInner() = false
|
||||
override fun isData() = false
|
||||
override fun isHeader() = false
|
||||
override fun isExpect() = false
|
||||
override fun isImpl() = false
|
||||
|
||||
override fun getCompanionObjectDescriptor() = null
|
||||
|
||||
@@ -166,7 +166,7 @@ public class BodyResolver {
|
||||
@NotNull KtSecondaryConstructor constructor,
|
||||
@NotNull ClassConstructorDescriptor descriptor
|
||||
) {
|
||||
if (descriptor.isHeader() || isEffectivelyExternal(descriptor)) {
|
||||
if (descriptor.isExpect() || isEffectivelyExternal(descriptor)) {
|
||||
// For header and external classes, we do not resolve constructor delegation calls because they are prohibited
|
||||
return DataFlowInfo.Companion.getEMPTY();
|
||||
}
|
||||
@@ -367,7 +367,7 @@ public class BodyResolver {
|
||||
descriptor.getUnsubstitutedPrimaryConstructor() != null &&
|
||||
superClass.getKind() != ClassKind.INTERFACE &&
|
||||
!superClass.getConstructors().isEmpty() &&
|
||||
!descriptor.isHeader() && !isEffectivelyExternal(descriptor) &&
|
||||
!descriptor.isExpect() && !isEffectivelyExternal(descriptor) &&
|
||||
!ErrorUtils.isError(superClass)
|
||||
) {
|
||||
trace.report(SUPERTYPE_NOT_INITIALIZED.on(specifier));
|
||||
@@ -428,7 +428,7 @@ public class BodyResolver {
|
||||
assert enumEntryDescriptor.getKind() == ClassKind.ENUM_ENTRY : "Enum entry expected: " + enumEntryDescriptor;
|
||||
ClassDescriptor enumClassDescriptor = (ClassDescriptor) enumEntryDescriptor.getContainingDeclaration();
|
||||
if (enumClassDescriptor.getKind() != ClassKind.ENUM_CLASS) return;
|
||||
if (enumClassDescriptor.isHeader()) return;
|
||||
if (enumClassDescriptor.isExpect()) return;
|
||||
|
||||
List<ClassConstructorDescriptor> applicableConstructors = DescriptorUtilsKt.getConstructorForEmptyArgumentsList(enumClassDescriptor);
|
||||
if (applicableConstructors.size() != 1) {
|
||||
@@ -617,7 +617,7 @@ public class BodyResolver {
|
||||
if (classDescriptor.getConstructors().isEmpty()) {
|
||||
trace.report(ANONYMOUS_INITIALIZER_IN_INTERFACE.on(anonymousInitializer));
|
||||
}
|
||||
if (classDescriptor.isHeader()) {
|
||||
if (classDescriptor.isExpect()) {
|
||||
trace.report(HEADER_DECLARATION_WITH_BODY.on(anonymousInitializer));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class DeclarationResolver(
|
||||
// TODO: report error on header class and impl val, or vice versa
|
||||
val (header, impl) =
|
||||
getTopLevelDescriptorsByFqName(topLevelDescriptorProvider, fqName, NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS)
|
||||
.partition { it is MemberDescriptor && it.isHeader }
|
||||
.partition { it is MemberDescriptor && it.isExpect }
|
||||
|
||||
for (descriptors in listOf(header, impl)) {
|
||||
if (descriptors.size > 1) {
|
||||
|
||||
@@ -250,7 +250,7 @@ class DeclarationsChecker(
|
||||
}
|
||||
|
||||
private fun checkHeaderClassConstructor(constructorDescriptor: ClassConstructorDescriptor, declaration: KtConstructor<*>) {
|
||||
if (!constructorDescriptor.isHeader) return
|
||||
if (!constructorDescriptor.isExpect) return
|
||||
|
||||
if (declaration.hasBody()) {
|
||||
trace.report(HEADER_DECLARATION_WITH_BODY.on(declaration))
|
||||
@@ -633,11 +633,11 @@ class DeclarationsChecker(
|
||||
|
||||
val initializer = property.initializer
|
||||
val delegate = property.delegate
|
||||
val isHeader = propertyDescriptor.isHeader
|
||||
val isExpect = propertyDescriptor.isExpect
|
||||
if (initializer != null) {
|
||||
when {
|
||||
inInterface -> trace.report(PROPERTY_INITIALIZER_IN_INTERFACE.on(initializer))
|
||||
isHeader -> trace.report(HEADER_PROPERTY_INITIALIZER.on(initializer))
|
||||
isExpect -> trace.report(HEADER_PROPERTY_INITIALIZER.on(initializer))
|
||||
!backingFieldRequired -> trace.report(PROPERTY_INITIALIZER_NO_BACKING_FIELD.on(initializer))
|
||||
property.receiverTypeReference != null -> trace.report(EXTENSION_PROPERTY_WITH_BACKING_FIELD.on(initializer))
|
||||
}
|
||||
@@ -650,7 +650,7 @@ class DeclarationsChecker(
|
||||
else {
|
||||
val isUninitialized = trace.bindingContext.get(BindingContext.IS_UNINITIALIZED, propertyDescriptor) ?: false
|
||||
val isExternal = propertyDescriptor.isEffectivelyExternal()
|
||||
if (backingFieldRequired && !inInterface && !propertyDescriptor.isLateInit && !isHeader && isUninitialized && !isExternal) {
|
||||
if (backingFieldRequired && !inInterface && !propertyDescriptor.isLateInit && !isExpect && isUninitialized && !isExternal) {
|
||||
if (propertyDescriptor.extensionReceiverParameter != null && !hasAccessorImplementation) {
|
||||
trace.report(EXTENSION_PROPERTY_MUST_HAVE_ACCESSORS_OR_BE_ABSTRACT.on(property))
|
||||
}
|
||||
@@ -696,7 +696,7 @@ class DeclarationsChecker(
|
||||
|
||||
if (containingDescriptor is ClassDescriptor) {
|
||||
val inInterface = containingDescriptor.kind == ClassKind.INTERFACE
|
||||
val isHeaderClass = containingDescriptor.isHeader
|
||||
val isExpectClass = containingDescriptor.isExpect
|
||||
if (hasAbstractModifier && !classCanHaveAbstractMembers(containingDescriptor)) {
|
||||
trace.report(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on(function, functionDescriptor.name.asString(), containingDescriptor))
|
||||
}
|
||||
@@ -712,17 +712,17 @@ class DeclarationsChecker(
|
||||
trace.report(REDUNDANT_OPEN_IN_INTERFACE.on(function))
|
||||
}
|
||||
}
|
||||
if (!hasBody && !hasAbstractModifier && !hasExternalModifier && !inInterface && !isHeaderClass) {
|
||||
if (!hasBody && !hasAbstractModifier && !hasExternalModifier && !inInterface && !isExpectClass) {
|
||||
trace.report(NON_ABSTRACT_FUNCTION_WITH_NO_BODY.on(function, functionDescriptor))
|
||||
}
|
||||
}
|
||||
else /* top-level only */ {
|
||||
if (!function.hasBody() && !hasAbstractModifier && !hasExternalModifier && !functionDescriptor.isHeader) {
|
||||
if (!function.hasBody() && !hasAbstractModifier && !hasExternalModifier && !functionDescriptor.isExpect) {
|
||||
trace.report(NON_MEMBER_FUNCTION_NO_BODY.on(function, functionDescriptor))
|
||||
}
|
||||
}
|
||||
|
||||
if (functionDescriptor.isHeader) {
|
||||
if (functionDescriptor.isExpect) {
|
||||
checkHeaderFunction(function)
|
||||
}
|
||||
|
||||
@@ -789,7 +789,7 @@ class DeclarationsChecker(
|
||||
accessorDescriptor: PropertyAccessorDescriptor?
|
||||
) {
|
||||
if (accessor == null || accessorDescriptor == null) return
|
||||
if (propertyDescriptor.isHeader && accessor.hasBody()) {
|
||||
if (propertyDescriptor.isExpect && accessor.hasBody()) {
|
||||
trace.report(HEADER_DECLARATION_WITH_BODY.on(accessor))
|
||||
}
|
||||
|
||||
@@ -829,7 +829,7 @@ class DeclarationsChecker(
|
||||
private fun checkEnumEntry(enumEntry: KtEnumEntry, enumEntryClass: ClassDescriptor) {
|
||||
val enumClass = enumEntryClass.containingDeclaration as ClassDescriptor
|
||||
if (DescriptorUtils.isEnumClass(enumClass)) {
|
||||
if (enumClass.isHeader) {
|
||||
if (enumClass.isExpect) {
|
||||
if (enumEntry.getBody() != null) {
|
||||
trace.report(HEADER_ENUM_ENTRY_WITH_BODY.on(enumEntry))
|
||||
}
|
||||
|
||||
@@ -875,7 +875,7 @@ public class DescriptorResolver {
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.LATEINIT_KEYWORD),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.CONST_KEYWORD),
|
||||
modifierList != null && PsiUtilsKt.hasExpectModifier(modifierList) && container instanceof PackageFragmentDescriptor ||
|
||||
container instanceof ClassDescriptor && ((ClassDescriptor) container).isHeader(),
|
||||
container instanceof ClassDescriptor && ((ClassDescriptor) container).isExpect(),
|
||||
modifierList != null && PsiUtilsKt.hasActualModifier(modifierList),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.EXTERNAL_KEYWORD),
|
||||
propertyInfo.getHasDelegate()
|
||||
@@ -1201,7 +1201,7 @@ public class DescriptorResolver {
|
||||
KotlinSourceElementKt.toSourceElement(parameter),
|
||||
false,
|
||||
false,
|
||||
classDescriptor.isHeader(),
|
||||
classDescriptor.isExpect(),
|
||||
modifierList != null && PsiUtilsKt.hasActualModifier(modifierList),
|
||||
false,
|
||||
false
|
||||
|
||||
@@ -184,8 +184,8 @@ class FunctionDescriptorResolver(
|
||||
functionDescriptor.isInline = function.hasModifier(KtTokens.INLINE_KEYWORD)
|
||||
functionDescriptor.isTailrec = function.hasModifier(KtTokens.TAILREC_KEYWORD)
|
||||
functionDescriptor.isSuspend = function.hasModifier(KtTokens.SUSPEND_KEYWORD)
|
||||
functionDescriptor.isHeader = container is PackageFragmentDescriptor && function.hasExpectModifier() ||
|
||||
container is ClassDescriptor && container.isHeader
|
||||
functionDescriptor.isExpect = container is PackageFragmentDescriptor && function.hasExpectModifier() ||
|
||||
container is ClassDescriptor && container.isExpect
|
||||
functionDescriptor.isImpl = function.hasActualModifier()
|
||||
|
||||
receiverType?.let { ForceResolveUtil.forceResolveAllContents(it.annotations) }
|
||||
@@ -296,8 +296,8 @@ class FunctionDescriptorResolver(
|
||||
isPrimary,
|
||||
declarationToTrace.toSourceElement()
|
||||
)
|
||||
if (classDescriptor.isHeader) {
|
||||
constructorDescriptor.isHeader = true
|
||||
if (classDescriptor.isExpect) {
|
||||
constructorDescriptor.isExpect = true
|
||||
}
|
||||
if (classDescriptor.isImpl) {
|
||||
constructorDescriptor.isImpl = true
|
||||
|
||||
@@ -153,7 +153,7 @@ class LocalVariableResolver(
|
||||
variable.toSourceElement(),
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isHeader = */ false,
|
||||
/* isExpect = */ false,
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false,
|
||||
variable is KtProperty && variable.hasDelegate()
|
||||
|
||||
@@ -252,7 +252,7 @@ class OverloadResolver(
|
||||
if (isConstructorsOfDifferentRedeclaredClasses(member1, member2)) continue
|
||||
if (isTopLevelMainInDifferentFiles(member1, member2)) continue
|
||||
if (isDefinitionsForDifferentPlatforms(member1, member2)) continue
|
||||
if (isHeaderDeclarationAndDefinition(member1, member2) || isHeaderDeclarationAndDefinition(member2, member1)) continue
|
||||
if (isExpectDeclarationAndDefinition(member1, member2) || isExpectDeclarationAndDefinition(member2, member1)) continue
|
||||
|
||||
if (!overloadChecker.isOverloadable(member1, member2)) {
|
||||
redeclarations.add(member1)
|
||||
@@ -282,9 +282,9 @@ class OverloadResolver(
|
||||
return file1 == null || file2 == null || file1 !== file2
|
||||
}
|
||||
|
||||
private fun isHeaderDeclarationAndDefinition(declaration: DeclarationDescriptor, definition: DeclarationDescriptor): Boolean {
|
||||
return declaration is MemberDescriptor && declaration.isHeader &&
|
||||
definition is MemberDescriptor && !definition.isHeader
|
||||
private fun isExpectDeclarationAndDefinition(declaration: DeclarationDescriptor, definition: DeclarationDescriptor): Boolean {
|
||||
return declaration is MemberDescriptor && declaration.isExpect &&
|
||||
definition is MemberDescriptor && !definition.isExpect
|
||||
}
|
||||
|
||||
private fun isDefinitionsForDifferentPlatforms(member1: DeclarationDescriptorNonRoot, member2: DeclarationDescriptorNonRoot): Boolean {
|
||||
|
||||
+1
-1
@@ -183,7 +183,7 @@ public class ValueArgumentsToParametersMapper {
|
||||
|
||||
KtPsiUtilKt.checkReservedYield(nameReference, candidateCall.getTrace());
|
||||
if (nameReference != null) {
|
||||
if (candidate instanceof MemberDescriptor && ((MemberDescriptor) candidate).isHeader() &&
|
||||
if (candidate instanceof MemberDescriptor && ((MemberDescriptor) candidate).isExpect() &&
|
||||
candidate.getContainingDeclaration() instanceof ClassDescriptor) {
|
||||
// We do not allow named arguments for members of header classes until we're able to use both
|
||||
// headers and platform definitions when compiling platform code
|
||||
|
||||
@@ -98,7 +98,7 @@ class DynamicCallableDescriptors(storageManager: StorageManager, builtIns: Kotli
|
||||
SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isHeader = */ false,
|
||||
/* isExpect = */ false,
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false,
|
||||
/* isDelegated = */ false
|
||||
|
||||
+9
-9
@@ -61,7 +61,7 @@ object HeaderImplDeclarationChecker : DeclarationChecker {
|
||||
|
||||
if (descriptor !is MemberDescriptor || DescriptorUtils.isEnumEntry(descriptor)) return
|
||||
|
||||
if (descriptor.isHeader) {
|
||||
if (descriptor.isExpect) {
|
||||
checkHeaderDeclarationHasImplementation(declaration, descriptor, diagnosticHolder, descriptor.module)
|
||||
}
|
||||
else {
|
||||
@@ -100,7 +100,7 @@ object HeaderImplDeclarationChecker : DeclarationChecker {
|
||||
return when (header) {
|
||||
is CallableMemberDescriptor -> {
|
||||
header.findNamesakesFromModule(platformModule).filter { impl ->
|
||||
header != impl && !impl.isHeader &&
|
||||
header != impl && !impl.isExpect &&
|
||||
// TODO: support non-source definitions (e.g. from Java)
|
||||
DescriptorToSourceUtils.getSourceFromDescriptor(impl) is KtElement
|
||||
}.groupBy { impl ->
|
||||
@@ -109,7 +109,7 @@ object HeaderImplDeclarationChecker : DeclarationChecker {
|
||||
}
|
||||
is ClassDescriptor -> {
|
||||
header.findClassifiersFromModule(platformModule).filter { impl ->
|
||||
header != impl && !impl.isHeader &&
|
||||
header != impl && !impl.isExpect &&
|
||||
DescriptorToSourceUtils.getSourceFromDescriptor(impl) is KtElement
|
||||
}.groupBy { impl ->
|
||||
areCompatibleClassifiers(header, impl)
|
||||
@@ -201,7 +201,7 @@ object HeaderImplDeclarationChecker : DeclarationChecker {
|
||||
}
|
||||
|
||||
candidates.filter { declaration ->
|
||||
impl != declaration && declaration.isHeader
|
||||
impl != declaration && declaration.isExpect
|
||||
}.groupBy { declaration ->
|
||||
// TODO: optimize by caching this per impl-header class pair, do not create a new substitutor for each impl member
|
||||
val substitutor =
|
||||
@@ -217,7 +217,7 @@ object HeaderImplDeclarationChecker : DeclarationChecker {
|
||||
is ClassifierDescriptorWithTypeParameters -> {
|
||||
impl.findClassifiersFromModule(commonModule).filter { declaration ->
|
||||
impl != declaration &&
|
||||
declaration is ClassDescriptor && declaration.isHeader
|
||||
declaration is ClassDescriptor && declaration.isExpect
|
||||
}.groupBy { header ->
|
||||
areCompatibleClassifiers(header as ClassDescriptor, impl)
|
||||
}
|
||||
@@ -408,8 +408,8 @@ object HeaderImplDeclarationChecker : DeclarationChecker {
|
||||
with(NewKotlinTypeChecker) {
|
||||
val context = object : TypeCheckerContext(false) {
|
||||
override fun areEqualTypeConstructors(a: TypeConstructor, b: TypeConstructor): Boolean {
|
||||
return isHeaderClassAndImplTypeAlias(a, b, platformModule) ||
|
||||
isHeaderClassAndImplTypeAlias(b, a, platformModule) ||
|
||||
return isExpectClassAndImplTypeAlias(a, b, platformModule) ||
|
||||
isExpectClassAndImplTypeAlias(b, a, platformModule) ||
|
||||
super.areEqualTypeConstructors(a, b)
|
||||
}
|
||||
}
|
||||
@@ -421,7 +421,7 @@ object HeaderImplDeclarationChecker : DeclarationChecker {
|
||||
// is java.lang.StringBuilder. For the purposes of type compatibility checking, we must consider these types equal here.
|
||||
// Note that the case of an "impl class" works as expected though, because the impl class by definition has the same FQ name
|
||||
// as the corresponding header class, so their type constructors are equal as per AbstractClassTypeConstructor#equals
|
||||
private fun isHeaderClassAndImplTypeAlias(
|
||||
private fun isExpectClassAndImplTypeAlias(
|
||||
headerTypeConstructor: TypeConstructor,
|
||||
implTypeConstructor: TypeConstructor,
|
||||
platformModule: ModuleDescriptor
|
||||
@@ -429,7 +429,7 @@ object HeaderImplDeclarationChecker : DeclarationChecker {
|
||||
val header = headerTypeConstructor.declarationDescriptor
|
||||
val impl = implTypeConstructor.declarationDescriptor
|
||||
return header is ClassifierDescriptorWithTypeParameters &&
|
||||
header.isHeader &&
|
||||
header.isExpect &&
|
||||
impl is ClassifierDescriptorWithTypeParameters &&
|
||||
header.findClassifiersFromModule(platformModule).any { classifier ->
|
||||
// Note that it's fine to only check that this "impl typealias" expands to the expected class, without checking
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ class InlineAnalyzerExtension(
|
||||
}
|
||||
if (hasInlineArgs) return
|
||||
|
||||
if (functionDescriptor.isInlineOnlyOrReifiable() || functionDescriptor.isHeader) return
|
||||
if (functionDescriptor.isInlineOnlyOrReifiable() || functionDescriptor.isExpect) return
|
||||
|
||||
if (reasonableInlineRules.any { it.isInlineReasonable(functionDescriptor, function, trace.bindingContext) }) return
|
||||
|
||||
|
||||
+2
-2
@@ -72,11 +72,11 @@ protected constructor(
|
||||
// See getFirstClassifierDiscriminateHeaders()
|
||||
var result: ClassifierDescriptor? = null
|
||||
for (klass in classes) {
|
||||
if (!klass.isHeader) return klass
|
||||
if (!klass.isExpect) return klass
|
||||
if (result == null) result = klass
|
||||
}
|
||||
for (typeAlias in typeAliases) {
|
||||
if (!typeAlias.isHeader) return typeAlias
|
||||
if (!typeAlias.isExpect) return typeAlias
|
||||
if (result == null) result = typeAlias
|
||||
}
|
||||
return result
|
||||
|
||||
+6
-6
@@ -91,7 +91,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
private final ClassKind kind;
|
||||
private final boolean isInner;
|
||||
private final boolean isData;
|
||||
private final boolean isHeader;
|
||||
private final boolean isExpect;
|
||||
private final boolean isImpl;
|
||||
|
||||
private final Annotations annotations;
|
||||
@@ -168,8 +168,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
this.isData = modifierList != null && modifierList.hasModifier(KtTokens.DATA_KEYWORD);
|
||||
this.isImpl = modifierList != null && PsiUtilsKt.hasActualModifier(modifierList);
|
||||
|
||||
this.isHeader = modifierList != null && PsiUtilsKt.hasExpectModifier(modifierList) ||
|
||||
containingDeclaration instanceof ClassDescriptor && ((ClassDescriptor) containingDeclaration).isHeader();
|
||||
this.isExpect = modifierList != null && PsiUtilsKt.hasExpectModifier(modifierList) ||
|
||||
containingDeclaration instanceof ClassDescriptor && ((ClassDescriptor) containingDeclaration).isExpect();
|
||||
|
||||
// Annotation entries are taken from both own annotations (if any) and object literal annotations (if any)
|
||||
List<KtAnnotationEntry> annotationEntries = new ArrayList<>();
|
||||
@@ -498,8 +498,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeader() {
|
||||
return isHeader;
|
||||
public boolean isExpect() {
|
||||
return isExpect;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -527,7 +527,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
@Override
|
||||
public String toString() {
|
||||
// not using DescriptorRenderer to preserve laziness
|
||||
return (isHeader ? "header " : isImpl ? "impl " : "") + "class " + getName().toString();
|
||||
return (isExpect ? "header " : isImpl ? "impl " : "") + "class " + getName().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -340,7 +340,7 @@ open class LazyClassMemberScope(
|
||||
if (!hasPrimaryConstructor) {
|
||||
when (thisDescriptor.kind) {
|
||||
ClassKind.INTERFACE -> return null
|
||||
ClassKind.OBJECT, ClassKind.ENUM_CLASS -> if (thisDescriptor.isHeader) return null
|
||||
ClassKind.OBJECT, ClassKind.ENUM_CLASS -> if (thisDescriptor.isExpect) return null
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -277,7 +277,7 @@ class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescriptor,
|
||||
/* source = */ oldDescriptor.source,
|
||||
/* lateInit = */ oldDescriptor.isLateInit,
|
||||
/* isConst = */ oldDescriptor.isConst,
|
||||
/* isHeader = */ oldDescriptor.isHeader,
|
||||
/* isExpect = */ oldDescriptor.isExpect,
|
||||
/* isImpl = */ oldDescriptor.isImpl,
|
||||
/* isExternal = */ oldDescriptor.isExternal,
|
||||
/* isDelegated = */ oldDescriptor.isDelegated
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ fun BackendContext.createPropertyWithBackingFieldBuilder(startOffset: Int, endOf
|
||||
/* source = */ SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isHeader = */ false,
|
||||
/* isExpect = */ false,
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false,
|
||||
/* isDelegated = */ false
|
||||
|
||||
+1
-1
@@ -597,7 +597,7 @@ class LocalDeclarationsLowering(val context: BackendContext) : DeclarationContai
|
||||
SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isHeader = */ false,
|
||||
/* isExpect = */ false,
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false,
|
||||
/* isDelegated = */ false)
|
||||
|
||||
+3
-3
@@ -40,11 +40,11 @@ class JvmPropertyDescriptorImpl private constructor(
|
||||
source: SourceElement,
|
||||
isLateInit: Boolean,
|
||||
isConst: Boolean,
|
||||
isHeader: Boolean,
|
||||
isExpect: Boolean,
|
||||
isImpl: Boolean
|
||||
) : JvmDescriptorWithExtraFlags, PropertyDescriptorImpl(
|
||||
containingDeclaration, original, annotations, modality, visibility, isVar,
|
||||
name, kind, source, isLateInit, isConst, isHeader, isImpl, /* isExternal = */ false, false
|
||||
name, kind, source, isLateInit, isConst, isExpect, isImpl, /* isExternal = */ false, false
|
||||
) {
|
||||
override fun createSubstitutedCopy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
@@ -56,7 +56,7 @@ class JvmPropertyDescriptorImpl private constructor(
|
||||
): PropertyDescriptorImpl =
|
||||
JvmPropertyDescriptorImpl(
|
||||
newOwner, original, annotations, newModality, newVisibility, extraFlags, isVar, newName, kind,
|
||||
SourceElement.NO_SOURCE, isLateInit, isConst, isHeader, isImpl
|
||||
SourceElement.NO_SOURCE, isLateInit, isConst, isExpect, isImpl
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ open class KnownClassDescriptor(
|
||||
override fun isCompanionObject(): Boolean = false
|
||||
override fun isData(): Boolean = false
|
||||
override fun isInner(): Boolean = false
|
||||
override fun isHeader(): Boolean = false
|
||||
override fun isExpect(): Boolean = false
|
||||
override fun isImpl(): Boolean = false
|
||||
override fun isExternal(): Boolean = false
|
||||
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ class JvmSharedVariablesManager(val builtIns: KotlinBuiltIns) : SharedVariablesM
|
||||
PropertyDescriptorImpl.create(
|
||||
refClass, Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, true,
|
||||
Name.identifier("element"), CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isHeader = */ false, /* isImpl = */ false,
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isExpect = */ false, /* isImpl = */ false,
|
||||
/* isExternal = */ false, /* isDelegated = */ false
|
||||
).initialize(type, dispatchReceiverParameter = refClass.thisAsReceiverParameter)
|
||||
}
|
||||
@@ -94,7 +94,7 @@ class JvmSharedVariablesManager(val builtIns: KotlinBuiltIns) : SharedVariablesM
|
||||
PropertyDescriptorImpl.create(
|
||||
genericRefClass, Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, true,
|
||||
Name.identifier("element"), CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isHeader = */ false, /* isImpl = */ false,
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isExpect = */ false, /* isImpl = */ false,
|
||||
/* isExternal = */ false, /* isDelegated = */ false
|
||||
).initialize(
|
||||
type = builtIns.anyType,
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ class SpecialDescriptorsFactory(
|
||||
Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, false,
|
||||
Name.identifier("INSTANCE"),
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, SourceElement.NO_SOURCE, /* lateInit = */ false, /* isConst = */ false,
|
||||
/* isHeader = */ false, /* isImpl = */ false, /* isExternal = */ false, /* isDelegated = */ false
|
||||
/* isExpect = */ false, /* isImpl = */ false, /* isExternal = */ false, /* isDelegated = */ false
|
||||
).initialize(objectDescriptor.defaultType)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ abstract class IrBuiltinOperatorDescriptorBase(containingDeclaration: Declaratio
|
||||
override fun isOperator(): Boolean = false
|
||||
override fun isSuspend(): Boolean = false
|
||||
override fun isTailrec(): Boolean = false
|
||||
override fun isHeader(): Boolean = false
|
||||
override fun isExpect(): Boolean = false
|
||||
override fun isImpl(): Boolean = false
|
||||
override fun hasStableParameterNames(): Boolean = true
|
||||
override fun hasSynthesizedParameterNames(): Boolean = false
|
||||
|
||||
@@ -60,7 +60,7 @@ abstract class IrDelegateDescriptorBase(
|
||||
SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isHeader = */ false,
|
||||
/* isExpect = */ false,
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false,
|
||||
/* isDelegated = */ true
|
||||
|
||||
@@ -45,7 +45,7 @@ class FlatSignature<out T> private constructor(
|
||||
val hasExtensionReceiver: Boolean,
|
||||
val hasVarargs: Boolean,
|
||||
val numDefaults: Int,
|
||||
val isHeader: Boolean,
|
||||
val isExpect: Boolean,
|
||||
val isSyntheticMember: Boolean
|
||||
) {
|
||||
val isGeneric = typeParameters.isNotEmpty()
|
||||
@@ -63,7 +63,7 @@ class FlatSignature<out T> private constructor(
|
||||
hasExtensionReceiver = false,
|
||||
hasVarargs = descriptor.valueParameters.any { it.varargElementType != null },
|
||||
numDefaults = numDefaults,
|
||||
isHeader = descriptor is MemberDescriptor && descriptor.isHeader,
|
||||
isExpect = descriptor is MemberDescriptor && descriptor.isExpect,
|
||||
isSyntheticMember = descriptor is SyntheticMemberDescriptor<*>
|
||||
)
|
||||
}
|
||||
@@ -83,7 +83,7 @@ class FlatSignature<out T> private constructor(
|
||||
hasExtensionReceiver = extensionReceiverType != null,
|
||||
hasVarargs = descriptor.valueParameters.any { it.varargElementType != null },
|
||||
numDefaults = numDefaults,
|
||||
isHeader = descriptor is MemberDescriptor && descriptor.isHeader,
|
||||
isExpect = descriptor is MemberDescriptor && descriptor.isExpect,
|
||||
isSyntheticMember = descriptor is SyntheticMemberDescriptor<*>
|
||||
)
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class FlatSignature<out T> private constructor(
|
||||
hasExtensionReceiver = false,
|
||||
hasVarargs = descriptor.valueParameters.any { it.varargElementType != null },
|
||||
numDefaults = descriptor.valueParameters.count { it.hasDefaultValue() },
|
||||
isHeader = descriptor is MemberDescriptor && descriptor.isHeader,
|
||||
isExpect = descriptor is MemberDescriptor && descriptor.isExpect,
|
||||
isSyntheticMember = descriptor is SyntheticMemberDescriptor<*>
|
||||
)
|
||||
|
||||
|
||||
+2
-2
@@ -263,8 +263,8 @@ open class OverloadingConflictResolver<C : Any>(
|
||||
if (isGeneric1 && isGeneric2) return false
|
||||
}
|
||||
|
||||
if (!call1.isHeader && call2.isHeader) return true
|
||||
if (call1.isHeader && !call2.isHeader) return false
|
||||
if (!call1.isExpect && call2.isExpect) return true
|
||||
if (call1.isExpect && !call2.isExpect) return false
|
||||
|
||||
return createEmptyConstraintSystem().isSignatureNotLessSpecific(call1, call2, SpecificityComparisonWithNumerics, specificityComparator)
|
||||
}
|
||||
|
||||
+3
-3
@@ -66,7 +66,7 @@ class DescriptorSerializer private constructor(
|
||||
val flags = Flags.getClassFlags(
|
||||
hasAnnotations(classDescriptor), classDescriptor.visibility, classDescriptor.modality, classDescriptor.kind,
|
||||
classDescriptor.isInner, classDescriptor.isCompanionObject, classDescriptor.isData, classDescriptor.isExternal,
|
||||
classDescriptor.isHeader
|
||||
classDescriptor.isExpect
|
||||
)
|
||||
if (flags != builder.flags) {
|
||||
builder.flags = flags
|
||||
@@ -187,7 +187,7 @@ class DescriptorSerializer private constructor(
|
||||
val flags = Flags.getPropertyFlags(
|
||||
hasAnnotations, descriptor.visibility, descriptor.modality, descriptor.kind, descriptor.isVar,
|
||||
hasGetter, hasSetter, hasConstant, descriptor.isConst, descriptor.isLateInit, descriptor.isExternal,
|
||||
@Suppress("DEPRECATION") descriptor.isDelegated, descriptor.isHeader
|
||||
@Suppress("DEPRECATION") descriptor.isDelegated, descriptor.isExpect
|
||||
)
|
||||
if (flags != builder.flags) {
|
||||
builder.flags = flags
|
||||
@@ -233,7 +233,7 @@ class DescriptorSerializer private constructor(
|
||||
val flags = Flags.getFunctionFlags(
|
||||
hasAnnotations(descriptor), descriptor.visibility, descriptor.modality, descriptor.kind, descriptor.isOperator,
|
||||
descriptor.isInfix, descriptor.isInline, descriptor.isTailrec, descriptor.isExternal, descriptor.isSuspend,
|
||||
descriptor.isHeader
|
||||
descriptor.isExpect
|
||||
)
|
||||
if (flags != builder.flags) {
|
||||
builder.flags = flags
|
||||
|
||||
+1
-1
@@ -195,7 +195,7 @@ public class RecursiveDescriptorComparator {
|
||||
}
|
||||
|
||||
// 'header' declarations do not belong to the platform-specific module, even though they participate in the analysis
|
||||
if (descriptor instanceof MemberDescriptor && ((MemberDescriptor) descriptor).isHeader() &&
|
||||
if (descriptor instanceof MemberDescriptor && ((MemberDescriptor) descriptor).isExpect() &&
|
||||
module.getCapability(MultiTargetPlatform.CAPABILITY) != MultiTargetPlatform.Common.INSTANCE) return false;
|
||||
|
||||
return module.equals(DescriptorUtils.getContainingModule(descriptor));
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ class LazyJavaClassDescriptor(
|
||||
override fun isInner() = isInner
|
||||
override fun isData() = false
|
||||
override fun isCompanionObject() = false
|
||||
override fun isHeader() = false
|
||||
override fun isExpect() = false
|
||||
override fun isImpl() = false
|
||||
|
||||
private val typeConstructor = LazyJavaClassTypeConstructor()
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ class FunctionClassDescriptor(
|
||||
override fun isCompanionObject() = false
|
||||
override fun isInner() = false
|
||||
override fun isData() = false
|
||||
override fun isHeader() = false
|
||||
override fun isExpect() = false
|
||||
override fun isImpl() = false
|
||||
override fun isExternal() = false
|
||||
override val annotations: Annotations get() = Annotations.EMPTY
|
||||
|
||||
@@ -26,7 +26,7 @@ public interface MemberDescriptor extends DeclarationDescriptorNonRoot, Declarat
|
||||
@NotNull
|
||||
Visibility getVisibility();
|
||||
|
||||
boolean isHeader();
|
||||
boolean isExpect();
|
||||
|
||||
boolean isImpl();
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo
|
||||
|
||||
override fun isCompanionObject() = false
|
||||
override fun isData() = false
|
||||
override fun isHeader() = false
|
||||
override fun isExpect() = false
|
||||
override fun isImpl() = false
|
||||
override fun isExternal() = false
|
||||
override val annotations: Annotations get() = Annotations.EMPTY
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ abstract class AbstractTypeAliasDescriptor(
|
||||
|
||||
override fun getVisibility() = visibilityImpl
|
||||
|
||||
override fun isHeader(): Boolean = false
|
||||
override fun isExpect(): Boolean = false
|
||||
|
||||
override fun isImpl(): Boolean = false
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeader() {
|
||||
public boolean isExpect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -155,7 +155,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeader() {
|
||||
public boolean isExpect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -43,7 +43,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
private boolean isExternal = false;
|
||||
private boolean isInline = false;
|
||||
private boolean isTailrec = false;
|
||||
private boolean isHeader = false;
|
||||
private boolean isExpect = false;
|
||||
private boolean isImpl = false;
|
||||
// Difference between these hidden kinds:
|
||||
// 1. isHiddenToOvercomeSignatureClash prohibit calling such functions even in super-call context
|
||||
@@ -136,8 +136,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
this.isTailrec = isTailrec;
|
||||
}
|
||||
|
||||
public void setHeader(boolean isHeader) {
|
||||
this.isHeader = isHeader;
|
||||
public void setExpect(boolean isExpect) {
|
||||
this.isExpect = isExpect;
|
||||
}
|
||||
|
||||
public void setImpl(boolean isImpl) {
|
||||
@@ -258,8 +258,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeader() {
|
||||
return isHeader;
|
||||
public boolean isExpect() {
|
||||
return isExpect;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -664,7 +664,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
substitutedDescriptor.setInline(isInline);
|
||||
substitutedDescriptor.setTailrec(isTailrec);
|
||||
substitutedDescriptor.setSuspend(isSuspend);
|
||||
substitutedDescriptor.setHeader(isHeader);
|
||||
substitutedDescriptor.setExpect(isExpect);
|
||||
substitutedDescriptor.setImpl(isImpl);
|
||||
substitutedDescriptor.setHasStableParameterNames(hasStableParameterNames);
|
||||
substitutedDescriptor.setHiddenToOvercomeSignatureClash(configuration.isHiddenToOvercomeSignatureClash);
|
||||
|
||||
+2
-2
@@ -227,8 +227,8 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeader() {
|
||||
return original.isHeader();
|
||||
public boolean isExpect() {
|
||||
return original.isExpect();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeader() {
|
||||
public boolean isExpect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeader() {
|
||||
public boolean isExpect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -42,7 +42,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
private final Kind kind;
|
||||
private final boolean lateInit;
|
||||
private final boolean isConst;
|
||||
private final boolean isHeader;
|
||||
private final boolean isExpect;
|
||||
private final boolean isImpl;
|
||||
private final boolean isExternal;
|
||||
private final boolean isDelegated;
|
||||
@@ -66,7 +66,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
@NotNull SourceElement source,
|
||||
boolean lateInit,
|
||||
boolean isConst,
|
||||
boolean isHeader,
|
||||
boolean isExpect,
|
||||
boolean isImpl,
|
||||
boolean isExternal,
|
||||
boolean isDelegated
|
||||
@@ -78,7 +78,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
this.kind = kind;
|
||||
this.lateInit = lateInit;
|
||||
this.isConst = isConst;
|
||||
this.isHeader = isHeader;
|
||||
this.isExpect = isExpect;
|
||||
this.isImpl = isImpl;
|
||||
this.isExternal = isExternal;
|
||||
this.isDelegated = isDelegated;
|
||||
@@ -96,14 +96,14 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
@NotNull SourceElement source,
|
||||
boolean lateInit,
|
||||
boolean isConst,
|
||||
boolean isHeader,
|
||||
boolean isExpect,
|
||||
boolean isImpl,
|
||||
boolean isExternal,
|
||||
boolean isDelegated
|
||||
) {
|
||||
return new PropertyDescriptorImpl(containingDeclaration, null, annotations,
|
||||
modality, visibility, isVar, name, kind, source, lateInit, isConst,
|
||||
isHeader, isImpl, isExternal, isDelegated);
|
||||
isExpect, isImpl, isExternal, isDelegated);
|
||||
}
|
||||
|
||||
public void setType(
|
||||
@@ -458,7 +458,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
) {
|
||||
return new PropertyDescriptorImpl(
|
||||
newOwner, original, getAnnotations(), newModality, newVisibility, isVar(), newName, kind, SourceElement.NO_SOURCE,
|
||||
isLateInit(), isConst(), isHeader(), isImpl(), isExternal(), isDelegated()
|
||||
isLateInit(), isConst(), isExpect(), isImpl(), isExternal(), isDelegated()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -480,8 +480,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeader() {
|
||||
return isHeader;
|
||||
public boolean isExpect() {
|
||||
return isExpect;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -509,7 +509,7 @@ internal class DescriptorRendererImpl(
|
||||
|
||||
private fun renderMemberModifiers(descriptor: MemberDescriptor, builder: StringBuilder) {
|
||||
renderModifier(builder, descriptor.isExternal, "external")
|
||||
renderModifier(builder, DescriptorRendererModifier.HEADER in modifiers && descriptor.isHeader, "header")
|
||||
renderModifier(builder, DescriptorRendererModifier.HEADER in modifiers && descriptor.isExpect, "header")
|
||||
renderModifier(builder, DescriptorRendererModifier.IMPL in modifiers && descriptor.isImpl, "impl")
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ inline fun <Scope, T : ClassifierDescriptor> getFirstClassifierDiscriminateHeade
|
||||
for (scope in scopes) {
|
||||
val newResult = callback(scope)
|
||||
if (newResult != null) {
|
||||
if (newResult is ClassifierDescriptorWithTypeParameters && newResult.isHeader) {
|
||||
if (newResult is ClassifierDescriptorWithTypeParameters && newResult.isExpect) {
|
||||
if (result == null) result = newResult
|
||||
}
|
||||
// this class is Impl or usual class
|
||||
|
||||
@@ -98,7 +98,7 @@ public class Flags {
|
||||
boolean isCompanionObject,
|
||||
boolean isData,
|
||||
boolean isExternal,
|
||||
boolean isHeader
|
||||
boolean isExpect
|
||||
) {
|
||||
return HAS_ANNOTATIONS.toFlags(hasAnnotations)
|
||||
| MODALITY.toFlags(modality(modality))
|
||||
@@ -107,7 +107,7 @@ public class Flags {
|
||||
| IS_INNER.toFlags(inner)
|
||||
| IS_DATA.toFlags(isData)
|
||||
| IS_EXTERNAL_CLASS.toFlags(isExternal)
|
||||
| IS_HEADER_CLASS.toFlags(isHeader)
|
||||
| IS_HEADER_CLASS.toFlags(isExpect)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class Flags {
|
||||
boolean isTailrec,
|
||||
boolean isExternal,
|
||||
boolean isSuspend,
|
||||
boolean isHeader
|
||||
boolean isExpect
|
||||
) {
|
||||
return HAS_ANNOTATIONS.toFlags(hasAnnotations)
|
||||
| VISIBILITY.toFlags(visibility(visibility))
|
||||
@@ -165,7 +165,7 @@ public class Flags {
|
||||
| IS_TAILREC.toFlags(isTailrec)
|
||||
| IS_EXTERNAL_FUNCTION.toFlags(isExternal)
|
||||
| IS_SUSPEND.toFlags(isSuspend)
|
||||
| IS_HEADER_FUNCTION.toFlags(isHeader)
|
||||
| IS_HEADER_FUNCTION.toFlags(isExpect)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public class Flags {
|
||||
boolean lateInit,
|
||||
boolean isExternal,
|
||||
boolean isDelegated,
|
||||
boolean isHeader
|
||||
boolean isExpect
|
||||
) {
|
||||
return HAS_ANNOTATIONS.toFlags(hasAnnotations)
|
||||
| VISIBILITY.toFlags(visibility(visibility))
|
||||
@@ -196,7 +196,7 @@ public class Flags {
|
||||
| HAS_CONSTANT.toFlags(hasConstant)
|
||||
| IS_EXTERNAL_PROPERTY.toFlags(isExternal)
|
||||
| IS_DELEGATED.toFlags(isDelegated)
|
||||
| IS_HEADER_PROPERTY.toFlags(isHeader)
|
||||
| IS_HEADER_PROPERTY.toFlags(isExpect)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -175,7 +175,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
function.isInline = Flags.IS_INLINE.get(flags)
|
||||
function.isTailrec = Flags.IS_TAILREC.get(flags)
|
||||
function.isSuspend = Flags.IS_SUSPEND.get(flags)
|
||||
function.isHeader = Flags.IS_HEADER_FUNCTION.get(flags)
|
||||
function.isExpect = Flags.IS_HEADER_FUNCTION.get(flags)
|
||||
return function
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ class DeserializedClassDescriptor(
|
||||
|
||||
override fun isData() = Flags.IS_DATA.get(classProto.flags)
|
||||
|
||||
override fun isHeader() = Flags.IS_HEADER_CLASS.get(classProto.flags)
|
||||
override fun isExpect() = Flags.IS_HEADER_CLASS.get(classProto.flags)
|
||||
|
||||
override fun isImpl() = false
|
||||
|
||||
|
||||
+3
-5
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization.deserialization.descriptors
|
||||
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.annotations.Nullable
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.*
|
||||
@@ -106,7 +104,7 @@ class DeserializedPropertyDescriptor(
|
||||
isConst: Boolean,
|
||||
isExternal: Boolean,
|
||||
isDelegated: Boolean,
|
||||
isHeader: Boolean,
|
||||
isExpect: Boolean,
|
||||
override val proto: ProtoBuf.Property,
|
||||
override val nameResolver: NameResolver,
|
||||
override val typeTable: TypeTable,
|
||||
@@ -114,7 +112,7 @@ class DeserializedPropertyDescriptor(
|
||||
override val containerSource: DeserializedContainerSource?
|
||||
) : DeserializedCallableMemberDescriptor, PropertyDescriptorImpl(
|
||||
containingDeclaration, original, annotations, modality, visibility, isVar, name, kind, SourceElement.NO_SOURCE,
|
||||
isLateInit, isConst, isHeader, false, isExternal, isDelegated
|
||||
isLateInit, isConst, isExpect, false, isExternal, isDelegated
|
||||
) {
|
||||
override fun createSubstitutedCopy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
@@ -126,7 +124,7 @@ class DeserializedPropertyDescriptor(
|
||||
): PropertyDescriptorImpl {
|
||||
return DeserializedPropertyDescriptor(
|
||||
newOwner, original, annotations, newModality, newVisibility, isVar, newName, kind, isLateInit, isConst, isExternal,
|
||||
@Suppress("DEPRECATION") isDelegated, isHeader, proto, nameResolver, typeTable, sinceKotlinInfoTable, containerSource
|
||||
@Suppress("DEPRECATION") isDelegated, isExpect, proto, nameResolver, typeTable, sinceKotlinInfoTable, containerSource
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -56,7 +56,7 @@ val ModuleDescriptor.allImplementingCompatibleModules
|
||||
class PlatformHeaderAnnotator : Annotator {
|
||||
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
|
||||
val declaration = element as? KtDeclaration ?: return
|
||||
if (!isHeaderDeclaration(declaration)) return
|
||||
if (!isExpectDeclaration(declaration)) return
|
||||
|
||||
if (TargetPlatformDetector.getPlatform(declaration.containingKtFile) !is TargetPlatform.Common) return
|
||||
|
||||
@@ -64,7 +64,7 @@ class PlatformHeaderAnnotator : Annotator {
|
||||
if (implementingModules.isEmpty()) return
|
||||
|
||||
val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return
|
||||
if (!descriptor.isHeader) return
|
||||
if (!descriptor.isExpect) return
|
||||
|
||||
val trace = BindingTraceContext()
|
||||
for (module in implementingModules) {
|
||||
@@ -80,7 +80,7 @@ class PlatformHeaderAnnotator : Annotator {
|
||||
KotlinPsiChecker().annotateElement(declaration, holder, SimpleDiagnostics(filteredList))
|
||||
}
|
||||
|
||||
private fun isHeaderDeclaration(declaration: KtDeclaration): Boolean {
|
||||
private fun isExpectDeclaration(declaration: KtDeclaration): Boolean {
|
||||
return declaration.hasExpectModifier() ||
|
||||
declaration is KtClassOrObject && KtPsiUtil.getOutermostClassOrObject(declaration)?.hasExpectModifier() == true
|
||||
}
|
||||
|
||||
+2
-2
@@ -148,7 +148,7 @@ private val OVERRIDE_RENDERER = DescriptorRenderer.withOptions {
|
||||
private fun PropertyDescriptor.wrap(): PropertyDescriptor {
|
||||
val delegate = copy(containingDeclaration, Modality.OPEN, visibility, kind, true) as PropertyDescriptor
|
||||
val newDescriptor = object : PropertyDescriptor by delegate {
|
||||
override fun isHeader() = false
|
||||
override fun isExpect() = false
|
||||
}
|
||||
newDescriptor.setSingleOverridden(this)
|
||||
return newDescriptor
|
||||
@@ -156,7 +156,7 @@ private fun PropertyDescriptor.wrap(): PropertyDescriptor {
|
||||
|
||||
private fun FunctionDescriptor.wrap(): FunctionDescriptor {
|
||||
return object : FunctionDescriptor by this {
|
||||
override fun isHeader() = false
|
||||
override fun isExpect() = false
|
||||
override fun getModality() = Modality.OPEN
|
||||
override fun getReturnType() = this@wrap.returnType?.approximateFlexibleTypes(preferNotNull = true, preferStarForRaw = true)
|
||||
override fun getOverriddenDescriptors() = listOf(this@wrap)
|
||||
|
||||
+3
-3
@@ -46,14 +46,14 @@ class KotlinMultiplatformJUnitRecognizer : JUnitRecognizer() {
|
||||
|
||||
val bindingContext = origin.analyze(BodyResolveMode.PARTIAL)
|
||||
val methodDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, origin] ?: return false
|
||||
return methodDescriptor.annotations.getAllAnnotations().any { it.isHeaderOfAnnotation("org.junit.Test", implModules) }
|
||||
return methodDescriptor.annotations.getAllAnnotations().any { it.isExpectOfAnnotation("org.junit.Test", implModules) }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun AnnotationWithTarget.isHeaderOfAnnotation(fqName: String, implModules: Collection<ModuleDescriptor>): Boolean {
|
||||
private fun AnnotationWithTarget.isExpectOfAnnotation(fqName: String, implModules: Collection<ModuleDescriptor>): Boolean {
|
||||
val annotationClass = annotation.type.constructor.declarationDescriptor as? ClassifierDescriptorWithTypeParameters ?: return false
|
||||
if (!annotationClass.isHeader) return false
|
||||
if (!annotationClass.isExpect) return false
|
||||
|
||||
return implModules
|
||||
.any { module ->
|
||||
|
||||
@@ -65,13 +65,13 @@ internal fun KtDeclaration.headerDeclarationIfAny(): KtDeclaration? {
|
||||
return DescriptorToSourceUtils.descriptorToDeclaration(headerDescriptor) as? KtDeclaration
|
||||
}
|
||||
|
||||
internal fun KtDeclaration.isHeaderOrHeaderClassMember() =
|
||||
internal fun KtDeclaration.isExpectOrExpectClassMember() =
|
||||
hasExpectModifier() || (containingClassOrObject?.hasExpectModifier() ?: false)
|
||||
|
||||
internal fun DeclarationDescriptor.liftToHeader(): DeclarationDescriptor? {
|
||||
if (this is MemberDescriptor) {
|
||||
return when {
|
||||
isHeader -> this
|
||||
isExpect -> this
|
||||
isImpl -> headerDescriptor()
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ fun navigateToPlatformImplementation(e: MouseEvent?, declaration: KtDeclaration)
|
||||
|
||||
private fun DeclarationDescriptor.headerImplementations(): Collection<DeclarationDescriptor> {
|
||||
if (this is MemberDescriptor) {
|
||||
if (!this.isHeader) return emptyList()
|
||||
if (!this.isExpect) return emptyList()
|
||||
|
||||
return module.allImplementingCompatibleModules.flatMap { it.implementationsOf(this) }
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ abstract class AbstractAddAccessorsIntention(
|
||||
return null
|
||||
}
|
||||
val descriptor = element.resolveToDescriptorIfAny() as? CallableMemberDescriptor ?: return null
|
||||
if (descriptor.isHeader) return null
|
||||
if (descriptor.isExpect) return null
|
||||
|
||||
if (addSetter && (!element.isVar || element.setter != null)) return null
|
||||
if (addGetter && element.getter != null) return null
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
|
||||
import org.jetbrains.kotlin.idea.core.*
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.headerImplementations
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.isHeaderOrHeaderClassMember
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.isExpectOrExpectClassMember
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.liftToHeader
|
||||
import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention
|
||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.getReturnTypeReference
|
||||
@@ -111,7 +111,7 @@ class ConvertMemberToExtensionIntention : SelfTargetingRangeIntention<KtCallable
|
||||
val descriptor = element.unsafeResolveToDescriptor()
|
||||
val containingClass = descriptor.containingDeclaration as ClassDescriptor
|
||||
|
||||
val isEffectiveHeader = allowHeader && element.isHeaderOrHeaderClassMember()
|
||||
val isEffectiveHeader = allowHeader && element.isExpectOrExpectClassMember()
|
||||
|
||||
val file = element.containingKtFile
|
||||
val project = file.project
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||
import org.jetbrains.kotlin.idea.core.getDeepestSuperDeclarations
|
||||
import org.jetbrains.kotlin.idea.core.getDirectlyOverriddenDeclarations
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.headerImplementations
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.isHeaderOrHeaderClassMember
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.isExpectOrExpectClassMember
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.liftToHeader
|
||||
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||
import org.jetbrains.kotlin.psi.KtBlockExpression
|
||||
@@ -184,7 +184,7 @@ abstract class CallableRefactoring<out T: CallableDescriptor>(
|
||||
fun getAffectedCallables(project: Project, descriptorsForChange: Collection<CallableDescriptor>): List<PsiElement> {
|
||||
val baseCallables = descriptorsForChange.mapNotNull { DescriptorToSourceUtilsIde.getAnyDeclaration(project, it) }
|
||||
return baseCallables + baseCallables.flatMapTo(HashSet<PsiElement>()) { callable ->
|
||||
if (callable is KtDeclaration && callable.isHeaderOrHeaderClassMember()) {
|
||||
if (callable is KtDeclaration && callable.isExpectOrExpectClassMember()) {
|
||||
callable.headerImplementations()
|
||||
}
|
||||
else {
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
|
||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.headerImplementations
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.isHeaderOrHeaderClassMember
|
||||
import org.jetbrains.kotlin.idea.highlighter.markers.isExpectOrExpectClassMember
|
||||
import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinCallableDefinitionUsage
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -98,7 +98,7 @@ class KotlinChangeSignatureData(
|
||||
primaryCallables + primaryCallables.flatMapTo(HashSet<UsageInfo>()) { primaryFunction ->
|
||||
val primaryDeclaration = primaryFunction.declaration as? KtDeclaration ?: return@flatMapTo emptyList()
|
||||
|
||||
if (primaryDeclaration.isHeaderOrHeaderClassMember()) {
|
||||
if (primaryDeclaration.isExpectOrExpectClassMember()) {
|
||||
return@flatMapTo primaryDeclaration.headerImplementations().mapNotNull {
|
||||
val descriptor = it.unsafeResolveToDescriptor()
|
||||
val callableDescriptor = when (descriptor) {
|
||||
|
||||
+3
-3
@@ -69,7 +69,7 @@ class JsNameClashChecker : SimpleDeclarationChecker {
|
||||
if (existing != null &&
|
||||
existing != descriptor &&
|
||||
existing.isImpl == descriptor.isImpl &&
|
||||
existing.isHeader == descriptor.isHeader &&
|
||||
existing.isExpect == descriptor.isExpect &&
|
||||
!bindingContext.isCommonDiagnosticReported(declaration)
|
||||
) {
|
||||
diagnosticHolder.report(ErrorsJs.JS_NAME_CLASH.on(declaration, name, existing))
|
||||
@@ -112,8 +112,8 @@ class JsNameClashChecker : SimpleDeclarationChecker {
|
||||
private val DeclarationDescriptor.isImpl: Boolean
|
||||
get() = this is MemberDescriptor && this.isImpl
|
||||
|
||||
private val DeclarationDescriptor.isHeader: Boolean
|
||||
get() = this is MemberDescriptor && this.isHeader
|
||||
private val DeclarationDescriptor.isExpect: Boolean
|
||||
get() = this is MemberDescriptor && this.isExpect
|
||||
|
||||
private fun isFakeOverridingNative(descriptor: CallableMemberDescriptor): Boolean {
|
||||
return descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE &&
|
||||
|
||||
@@ -163,7 +163,7 @@ public final class AnnotationsUtils {
|
||||
}
|
||||
|
||||
public static boolean isPredefinedObject(@NotNull DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof MemberDescriptor && ((MemberDescriptor) descriptor).isHeader()) return true;
|
||||
if (descriptor instanceof MemberDescriptor && ((MemberDescriptor) descriptor).isExpect()) return true;
|
||||
if (isEffectivelyExternalMember(descriptor)) return true;
|
||||
|
||||
for (PredefinedAnnotation annotation : PredefinedAnnotation.values()) {
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ object KotlinJavascriptSerializationUtil {
|
||||
val builder = ProtoBuf.PackageFragment.newBuilder()
|
||||
|
||||
// TODO: ModuleDescriptor should be able to return the package only with the contents of that module, without dependencies
|
||||
val skip: (DeclarationDescriptor) -> Boolean = { DescriptorUtils.getContainingModule(it) != module || (it is MemberDescriptor && it.isHeader) }
|
||||
val skip: (DeclarationDescriptor) -> Boolean = { DescriptorUtils.getContainingModule(it) != module || (it is MemberDescriptor && it.isExpect) }
|
||||
|
||||
val fileRegistry = KotlinFileRegistry()
|
||||
val serializerExtension = KotlinJavascriptSerializerExtension(fileRegistry)
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ private fun genProperty(
|
||||
sourceElement,
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isHeader = */ false,
|
||||
/* isExpect = */ false,
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false,
|
||||
/* isDelegated = */ false
|
||||
|
||||
Reference in New Issue
Block a user