[FIR] Start enum entries reworking
This commit is contained in:
committed by
Mikhail Glukhikh
parent
68d64f1b5c
commit
13132e69a3
@@ -13,6 +13,8 @@ import org.jetbrains.kotlin.name.Name
|
||||
data class CallableId(val packageName: FqName, val className: FqName?, val callableName: Name) {
|
||||
val classId: ClassId? get() = className?.let { ClassId(packageName, it, false) }
|
||||
|
||||
constructor(classId: ClassId, callableName: Name) : this(classId.packageFqName, classId.relativeClassName, callableName)
|
||||
|
||||
constructor(packageName: FqName, callableName: Name) : this(packageName, null, callableName)
|
||||
|
||||
@Deprecated("TODO: Better solution for local callables?")
|
||||
|
||||
+1
-9
@@ -10,7 +10,6 @@ import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirEnumEntryImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl
|
||||
import org.jetbrains.kotlin.fir.deserialization.FirDeserializationContext
|
||||
@@ -212,11 +211,6 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
).firstOrNull()
|
||||
|
||||
this.calleeReference = when {
|
||||
entryClassSymbol != null && (entryClassSymbol as? FirClassSymbol)?.fir is FirEnumEntry -> {
|
||||
FirResolvedNamedReferenceImpl(
|
||||
null, name, entryClassSymbol
|
||||
)
|
||||
}
|
||||
entryCallableSymbol != null -> {
|
||||
FirResolvedNamedReferenceImpl(
|
||||
null, name, entryCallableSymbol
|
||||
@@ -340,9 +334,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
kotlinScopeProvider,
|
||||
parentContext, this::findAndDeserializeClass
|
||||
)
|
||||
symbol.fir.declarations.filterIsInstance<FirEnumEntryImpl>().forEach {
|
||||
classesCache[it.symbol.classId] = it.symbol
|
||||
}
|
||||
|
||||
classesCache[classId] = symbol
|
||||
val annotations = mutableListOf<FirAnnotationCall>()
|
||||
kotlinJvmBinaryClass.loadClassAnnotations(object : KotlinJvmBinaryClass.AnnotationVisitor {
|
||||
|
||||
@@ -365,11 +365,11 @@ internal fun ConeKotlinType.lexicalCastFrom(session: FirSession, value: String):
|
||||
val firElement = lookupTag.toSymbol(session)?.fir
|
||||
if (firElement is FirRegularClass && firElement.classKind == ClassKind.ENUM_CLASS) {
|
||||
val name = Name.identifier(value)
|
||||
val firEnumEntry = firElement.declarations.filterIsInstance<FirEnumEntry>().find { it.name == name }
|
||||
val firEnumEntry = firElement.collectEnumEntries().find { it.callableId.callableName == name }
|
||||
|
||||
return if (firEnumEntry != null) FirQualifiedAccessExpressionImpl(null).apply {
|
||||
calleeReference = FirSimpleNamedReference(
|
||||
null, name, null // TODO: , firEnumEntry.symbol
|
||||
calleeReference = FirResolvedNamedReferenceImpl(
|
||||
null, name, firEnumEntry
|
||||
)
|
||||
} else if (firElement is FirJavaClass) {
|
||||
val firStaticProperty = firElement.declarations.filterIsInstance<FirJavaField>().find {
|
||||
|
||||
+52
-30
@@ -489,7 +489,7 @@ class DeclarationsConverter(
|
||||
val delegatedType = delegatedSuperTypeRef ?: implicitAnyType
|
||||
|
||||
return withChildClassName(ANONYMOUS_OBJECT_NAME) {
|
||||
FirAnonymousObjectImpl(null, session, scopeProvider, FirAnonymousObjectSymbol()).apply {
|
||||
FirAnonymousObjectImpl(null, session, ClassKind.OBJECT, scopeProvider, FirAnonymousObjectSymbol()).apply {
|
||||
annotations += modifiers.annotations
|
||||
this.superTypeRefs += superTypeRefs
|
||||
this.typeRef = superTypeRefs.first()
|
||||
@@ -515,12 +515,11 @@ class DeclarationsConverter(
|
||||
/**
|
||||
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parseEnumEntry
|
||||
*/
|
||||
private fun convertEnumEntry(enumEntry: LighterASTNode, classWrapper: ClassWrapper): FirEnumEntryImpl {
|
||||
private fun convertEnumEntry(enumEntry: LighterASTNode, classWrapper: ClassWrapper): FirProperty {
|
||||
var modifiers = Modifier()
|
||||
lateinit var identifier: String
|
||||
var hasInitializerList = false
|
||||
val enumSuperTypeCallEntry = mutableListOf<FirExpression>()
|
||||
val firDeclarations = mutableListOf<FirDeclaration>()
|
||||
var classBodyNode: LighterASTNode? = null
|
||||
enumEntry.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
@@ -535,32 +534,46 @@ class DeclarationsConverter(
|
||||
}
|
||||
|
||||
val enumEntryName = identifier.nameAsSafeName()
|
||||
return withChildClassName(enumEntryName) {
|
||||
val firEnumEntry = FirEnumEntryImpl(
|
||||
return FirPropertyImpl(
|
||||
null,
|
||||
session,
|
||||
classWrapper.delegatedSelfTypeRef,
|
||||
receiverTypeRef = null,
|
||||
name = enumEntryName,
|
||||
initializer = FirAnonymousObjectImpl(
|
||||
null,
|
||||
session,
|
||||
enumEntryName,
|
||||
ClassKind.ENUM_ENTRY,
|
||||
scopeProvider,
|
||||
FirRegularClassSymbol(context.currentClassId)
|
||||
)
|
||||
firEnumEntry.annotations += modifiers.annotations
|
||||
|
||||
val defaultDelegatedSuperTypeRef = implicitAnyType
|
||||
|
||||
val enumClassWrapper = ClassWrapper(
|
||||
enumEntryName, modifiers, ClassKind.ENUM_ENTRY, hasPrimaryConstructor = true,
|
||||
hasSecondaryConstructor = classBodyNode.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(),
|
||||
delegatedSelfTypeRef = null.toDelegatedSelfType(firEnumEntry),
|
||||
delegatedSuperTypeRef = if (hasInitializerList) classWrapper.getFirUserTypeFromClassName() else defaultDelegatedSuperTypeRef,
|
||||
superTypeCallEntry = enumSuperTypeCallEntry
|
||||
)
|
||||
firEnumEntry.superTypeRefs += enumClassWrapper.delegatedSuperTypeRef
|
||||
convertPrimaryConstructor(null, enumClassWrapper)?.let { firEnumEntry.addDeclaration(it.firConstructor) }
|
||||
classBodyNode?.also { firDeclarations += convertClassBody(it, enumClassWrapper) }
|
||||
firDeclarations.forEach { firEnumEntry.addDeclaration(it) }
|
||||
|
||||
return@withChildClassName firEnumEntry
|
||||
}
|
||||
FirAnonymousObjectSymbol()
|
||||
).apply {
|
||||
annotations += modifiers.annotations
|
||||
val enumClassWrapper = ClassWrapper(
|
||||
enumEntryName, modifiers, ClassKind.ENUM_ENTRY, hasPrimaryConstructor = true,
|
||||
hasSecondaryConstructor = classBodyNode.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(),
|
||||
delegatedSelfTypeRef = FirResolvedTypeRefImpl(
|
||||
null,
|
||||
ConeClassLikeTypeImpl(
|
||||
symbol.toLookupTag(),
|
||||
emptyArray(),
|
||||
isNullable = false
|
||||
)
|
||||
),
|
||||
delegatedSuperTypeRef = classWrapper.delegatedSelfTypeRef,
|
||||
superTypeCallEntry = enumSuperTypeCallEntry
|
||||
)
|
||||
superTypeRefs += enumClassWrapper.delegatedSuperTypeRef
|
||||
convertPrimaryConstructor(null, enumClassWrapper)?.let { declarations += it.firConstructor }
|
||||
classBodyNode?.also { declarations += convertClassBody(it, enumClassWrapper) }
|
||||
},
|
||||
delegate = null,
|
||||
isVar = false,
|
||||
symbol = FirPropertySymbol(CallableId(context.currentClassId, enumEntryName)),
|
||||
isLocal = false,
|
||||
status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply {
|
||||
isStatic = true
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -686,7 +699,13 @@ class DeclarationsConverter(
|
||||
}
|
||||
|
||||
val delegatedSelfTypeRef =
|
||||
if (classWrapper.isObjectLiteral()) FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Constructor in object", DiagnosticKind.ConstructorInObject))
|
||||
if (classWrapper.isObjectLiteral()) FirErrorTypeRefImpl(
|
||||
null,
|
||||
FirSimpleDiagnostic(
|
||||
"Constructor in object",
|
||||
DiagnosticKind.ConstructorInObject
|
||||
)
|
||||
)
|
||||
else classWrapper.delegatedSelfTypeRef
|
||||
|
||||
val status = FirDeclarationStatusImpl(modifiers.getVisibility(), Modality.FINAL).apply {
|
||||
@@ -827,7 +846,8 @@ class DeclarationsConverter(
|
||||
val parentNode = property.getParent()
|
||||
val isLocal = !(parentNode?.tokenType == KT_FILE || parentNode?.tokenType == CLASS_BODY)
|
||||
return if (isLocal) {
|
||||
val receiver = delegateExpression?.let { expressionConverter.getAsFirExpression<FirExpression>(it, "Incorrect delegate expression") }
|
||||
val receiver =
|
||||
delegateExpression?.let { expressionConverter.getAsFirExpression<FirExpression>(it, "Incorrect delegate expression") }
|
||||
FirPropertyImpl(
|
||||
null,
|
||||
session,
|
||||
@@ -895,7 +915,8 @@ class DeclarationsConverter(
|
||||
private fun convertDestructingDeclaration(destructingDeclaration: LighterASTNode): DestructuringDeclaration {
|
||||
var isVar = false
|
||||
val entries = mutableListOf<FirVariable<*>>()
|
||||
var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("Destructuring declaration without initializer", DiagnosticKind.Syntax))
|
||||
var firExpression: FirExpression =
|
||||
FirErrorExpressionImpl(null, FirSimpleDiagnostic("Destructuring declaration without initializer", DiagnosticKind.Syntax))
|
||||
destructingDeclaration.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
VAR_KEYWORD -> isVar = true
|
||||
@@ -1297,7 +1318,8 @@ class DeclarationsConverter(
|
||||
NULLABLE_TYPE -> firType = convertNullableType(it)
|
||||
FUNCTION_TYPE -> firType = convertFunctionType(it)
|
||||
DYNAMIC_TYPE -> firType = FirDynamicTypeRefImpl(null, false)
|
||||
TokenType.ERROR_ELEMENT -> firType = FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Unwrapped type is null", DiagnosticKind.Syntax))
|
||||
TokenType.ERROR_ELEMENT -> firType =
|
||||
FirErrorTypeRefImpl(null, FirSimpleDiagnostic("Unwrapped type is null", DiagnosticKind.Syntax))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va
|
||||
owner,
|
||||
hasPrimaryConstructor
|
||||
)
|
||||
is KtEnumEntry -> toFirEnumEntry(delegatedSelfType!!)
|
||||
else -> convert<FirDeclaration>()
|
||||
}
|
||||
}
|
||||
@@ -321,7 +322,10 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va
|
||||
}
|
||||
|
||||
private fun KtClassOrObject.extractSuperTypeListEntriesTo(
|
||||
container: FirModifiableClass<*>, delegatedSelfTypeRef: FirTypeRef?, classKind: ClassKind
|
||||
container: FirModifiableClass<*>,
|
||||
delegatedSelfTypeRef: FirTypeRef?,
|
||||
delegatedEnumSuperTypeRef: FirTypeRef?,
|
||||
classKind: ClassKind
|
||||
): FirTypeRef? {
|
||||
var superTypeCallEntry: KtSuperTypeCallEntry? = null
|
||||
var delegatedSuperTypeRef: FirTypeRef? = null
|
||||
@@ -367,7 +371,13 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va
|
||||
}
|
||||
}
|
||||
|
||||
val defaultDelegatedSuperTypeRef = implicitAnyType
|
||||
val defaultDelegatedSuperTypeRef =
|
||||
when {
|
||||
classKind == ClassKind.ENUM_ENTRY && this is KtClass -> delegatedEnumSuperTypeRef ?: implicitAnyType
|
||||
else -> implicitAnyType
|
||||
}
|
||||
|
||||
|
||||
if (container.superTypeRefs.isEmpty()) {
|
||||
container.superTypeRefs += defaultDelegatedSuperTypeRef
|
||||
}
|
||||
@@ -454,27 +464,45 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va
|
||||
return firFile
|
||||
}
|
||||
|
||||
override fun visitEnumEntry(enumEntry: KtEnumEntry, data: Unit): FirElement {
|
||||
return withChildClassName(enumEntry.nameAsSafeName) {
|
||||
val firEnumEntry = FirEnumEntryImpl(
|
||||
enumEntry.toFirSourceElement(),
|
||||
session,
|
||||
enumEntry.nameAsSafeName,
|
||||
scopeProvider,
|
||||
FirRegularClassSymbol(context.currentClassId)
|
||||
private fun KtEnumEntry.toFirEnumEntry(delegatedEnumSelfTypeRef: FirTypeRef): FirDeclaration {
|
||||
val obj = FirAnonymousObjectImpl(
|
||||
source = toFirSourceElement(),
|
||||
session,
|
||||
ClassKind.ENUM_ENTRY,
|
||||
scopeProvider,
|
||||
FirAnonymousObjectSymbol()
|
||||
)
|
||||
val delegatedEntrySelfType =
|
||||
FirResolvedTypeRefImpl(source = null, ConeClassLikeTypeImpl(obj.symbol.toLookupTag(), emptyArray(), isNullable = false))
|
||||
|
||||
extractSuperTypeListEntriesTo(obj, delegatedEntrySelfType, delegatedEnumSelfTypeRef, ClassKind.ENUM_ENTRY)
|
||||
|
||||
for (declaration in declarations) {
|
||||
obj.declarations += declaration.toFirDeclaration(
|
||||
delegatedEnumSelfTypeRef,
|
||||
delegatedSelfType = null,
|
||||
this,
|
||||
hasPrimaryConstructor = false
|
||||
)
|
||||
enumEntry.extractAnnotationsTo(firEnumEntry)
|
||||
val delegatedSelfType = enumEntry.toDelegatedSelfType(firEnumEntry)
|
||||
val delegatedSuperType = enumEntry.extractSuperTypeListEntriesTo(firEnumEntry, delegatedSelfType, ClassKind.ENUM_ENTRY)
|
||||
for (declaration in enumEntry.declarations) {
|
||||
firEnumEntry.addDeclaration(
|
||||
declaration.toFirDeclaration(
|
||||
delegatedSuperType, delegatedSelfType, enumEntry, hasPrimaryConstructor = true
|
||||
)
|
||||
)
|
||||
}
|
||||
firEnumEntry
|
||||
}
|
||||
|
||||
return FirPropertyImpl(
|
||||
source = toFirSourceElement(),
|
||||
session,
|
||||
delegatedEnumSelfTypeRef,
|
||||
receiverTypeRef = null,
|
||||
name = nameAsSafeName,
|
||||
initializer = obj,
|
||||
delegate = null,
|
||||
isVar = false,
|
||||
isLocal = false,
|
||||
status = FirDeclarationStatusImpl(
|
||||
Visibilities.PUBLIC, Modality.FINAL
|
||||
).apply {
|
||||
isStatic = true
|
||||
},
|
||||
symbol = FirPropertySymbol(callableIdForName(nameAsSafeName))
|
||||
)
|
||||
}
|
||||
|
||||
override fun visitClassOrObject(classOrObject: KtClassOrObject, data: Unit): FirElement {
|
||||
@@ -525,7 +553,7 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va
|
||||
classOrObject.extractAnnotationsTo(firClass)
|
||||
classOrObject.extractTypeParametersTo(firClass)
|
||||
val delegatedSelfType = classOrObject.toDelegatedSelfType(firClass)
|
||||
val delegatedSuperType = classOrObject.extractSuperTypeListEntriesTo(firClass, delegatedSelfType, classKind)
|
||||
val delegatedSuperType = classOrObject.extractSuperTypeListEntriesTo(firClass, delegatedSelfType, null, classKind)
|
||||
val primaryConstructor = classOrObject.primaryConstructor
|
||||
val firPrimaryConstructor = firClass.declarations.firstOrNull() as? FirConstructor
|
||||
if (primaryConstructor != null && firPrimaryConstructor != null) {
|
||||
@@ -568,9 +596,11 @@ class RawFirBuilder(session: FirSession, val scopeProvider: FirScopeProvider, va
|
||||
override fun visitObjectLiteralExpression(expression: KtObjectLiteralExpression, data: Unit): FirElement {
|
||||
val objectDeclaration = expression.objectDeclaration
|
||||
return withChildClassName(ANONYMOUS_OBJECT_NAME) {
|
||||
FirAnonymousObjectImpl(expression.toFirSourceElement(), session, scopeProvider, FirAnonymousObjectSymbol()).apply {
|
||||
FirAnonymousObjectImpl(
|
||||
expression.toFirSourceElement(), session, ClassKind.OBJECT, scopeProvider, FirAnonymousObjectSymbol()
|
||||
).apply {
|
||||
objectDeclaration.extractAnnotationsTo(this)
|
||||
objectDeclaration.extractSuperTypeListEntriesTo(this, null, ClassKind.CLASS)
|
||||
objectDeclaration.extractSuperTypeListEntriesTo(this, null, null, ClassKind.CLASS)
|
||||
this.typeRef = superTypeRefs.first() // TODO
|
||||
|
||||
for (declaration in objectDeclaration.declarations) {
|
||||
|
||||
+27
-15
@@ -4,27 +4,33 @@ FILE: enums.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public? final enum entry FIRST : R|kotlin/Any| {
|
||||
public? constructor(): R|Order.FIRST| {
|
||||
super<R|kotlin/Any|>()
|
||||
public final static val FIRST: R|Order| = object : R|Order| {
|
||||
public? constructor(): R|Order| {
|
||||
super<R|Order|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public? final enum entry SECOND : R|kotlin/Any| {
|
||||
public? constructor(): R|Order.SECOND| {
|
||||
super<R|kotlin/Any|>()
|
||||
|
||||
|
||||
public final static val SECOND: R|Order| = object : R|Order| {
|
||||
public? constructor(): R|Order| {
|
||||
super<R|Order|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public? final enum entry THIRD : R|kotlin/Any| {
|
||||
public? constructor(): R|Order.THIRD| {
|
||||
super<R|kotlin/Any|>()
|
||||
|
||||
|
||||
public final static val THIRD: R|Order| = object : R|Order| {
|
||||
public? constructor(): R|Order| {
|
||||
super<R|Order|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final static fun values(): R|kotlin/Array<Order>| {
|
||||
}
|
||||
|
||||
@@ -43,8 +49,8 @@ FILE: enums.kt
|
||||
internal final? val r: Double = R|<local>/r|
|
||||
internal get(): Double
|
||||
|
||||
public? final enum entry MERCURY : Planet {
|
||||
public? constructor(): R|Planet.MERCURY| {
|
||||
public final static val MERCURY: R|Planet| = object : Planet {
|
||||
public? constructor(): Planet {
|
||||
super<Planet>(Double(1.0), Double(2.0))
|
||||
}
|
||||
|
||||
@@ -54,8 +60,10 @@ FILE: enums.kt
|
||||
|
||||
}
|
||||
|
||||
public? final enum entry VENERA : Planet {
|
||||
public? constructor(): R|Planet.VENERA| {
|
||||
|
||||
|
||||
public final static val VENERA: R|Planet| = object : Planet {
|
||||
public? constructor(): Planet {
|
||||
super<Planet>(Double(3.0), Double(4.0))
|
||||
}
|
||||
|
||||
@@ -65,8 +73,10 @@ FILE: enums.kt
|
||||
|
||||
}
|
||||
|
||||
public? final enum entry EARTH : Planet {
|
||||
public? constructor(): R|Planet.EARTH| {
|
||||
|
||||
|
||||
public final static val EARTH: R|Planet| = object : Planet {
|
||||
public? constructor(): Planet {
|
||||
super<Planet>(Double(5.0), Double(6.0))
|
||||
}
|
||||
|
||||
@@ -76,6 +86,8 @@ FILE: enums.kt
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public? final? val g: Double = G#.times#(m#).div#(r#.times#(r#))
|
||||
public? get(): Double
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ FILE: enums2.kt
|
||||
public? final? val x: Some = R|<local>/x|
|
||||
public? get(): Some
|
||||
|
||||
public? final enum entry FIRST : SomeEnum {
|
||||
public? constructor(): R|SomeEnum.FIRST| {
|
||||
public final static val FIRST: R|SomeEnum| = object : SomeEnum {
|
||||
public? constructor(): SomeEnum {
|
||||
super<SomeEnum>(O1#)
|
||||
}
|
||||
|
||||
@@ -32,8 +32,10 @@ FILE: enums2.kt
|
||||
|
||||
}
|
||||
|
||||
public? final enum entry SECOND : SomeEnum {
|
||||
public? constructor(): R|SomeEnum.SECOND| {
|
||||
|
||||
|
||||
public final static val SECOND: R|SomeEnum| = object : SomeEnum {
|
||||
public? constructor(): SomeEnum {
|
||||
super<SomeEnum>(O2#)
|
||||
}
|
||||
|
||||
@@ -43,6 +45,8 @@ FILE: enums2.kt
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public? abstract fun check(y: Some): Boolean
|
||||
|
||||
public final static fun values(): R|kotlin/Array<SomeEnum>| {
|
||||
|
||||
+10
-5
@@ -8,6 +8,8 @@ package org.jetbrains.kotlin.fir.deserialization
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.collectEnumEntries
|
||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||
import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
@@ -19,7 +21,6 @@ import org.jetbrains.kotlin.fir.resolve.constructType
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.FirUnresolvedSymbolError
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl
|
||||
@@ -133,10 +134,14 @@ abstract class AbstractAnnotationDeserializer(
|
||||
ENUM -> FirFunctionCallImpl(null).apply {
|
||||
val classId = nameResolver.getClassId(value.classId)
|
||||
val entryName = nameResolver.getName(value.enumValueId)
|
||||
val entryClassId = classId.createNestedClassId(entryName)
|
||||
val entryLookupTag = ConeClassLikeLookupTagImpl(entryClassId)
|
||||
val entrySymbol = entryLookupTag.toSymbol(this@AbstractAnnotationDeserializer.session)
|
||||
this.calleeReference = entrySymbol?.let {
|
||||
|
||||
|
||||
val enumLookupTag = ConeClassLikeLookupTagImpl(classId)
|
||||
val enumSymbol = enumLookupTag.toSymbol(this@AbstractAnnotationDeserializer.session)
|
||||
val firClass = enumSymbol?.fir as? FirRegularClass
|
||||
val enumEntries = firClass?.collectEnumEntries() ?: emptyList()
|
||||
val enumEntrySymbol = enumEntries.find { it.callableId.callableName == entryName }
|
||||
this.calleeReference = enumEntrySymbol?.let {
|
||||
FirResolvedNamedReferenceImpl(null, entryName, it)
|
||||
} ?: FirErrorNamedReferenceImpl(
|
||||
null,
|
||||
|
||||
+30
-9
@@ -5,7 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.addDeclarations
|
||||
@@ -14,7 +16,11 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirEnumEntryImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirSealedClassImpl
|
||||
import org.jetbrains.kotlin.fir.scopes.KotlinScopeProvider
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
||||
@@ -121,19 +127,34 @@ fun deserializeClassToSymbol(
|
||||
addDeclarations(
|
||||
classProto.enumEntryList.mapNotNull { enumEntryProto ->
|
||||
val enumEntryName = nameResolver.getName(enumEntryProto.name)
|
||||
val enumEntryId = classId.createNestedClassId(enumEntryName)
|
||||
|
||||
val symbol = FirRegularClassSymbol(enumEntryId)
|
||||
FirEnumEntryImpl(null, session, enumEntryId.shortClassName, scopeProvider, symbol).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
superTypeRefs += FirResolvedTypeRefImpl(
|
||||
val enumType = ConeClassLikeTypeImpl(symbol.toLookupTag(), emptyArray(), false)
|
||||
val property = FirPropertyImpl(
|
||||
null,
|
||||
session,
|
||||
FirResolvedTypeRefImpl(null, enumType),
|
||||
null,
|
||||
enumEntryName,
|
||||
initializer = FirAnonymousObjectImpl(
|
||||
null,
|
||||
ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(classId), emptyArray(), false)
|
||||
)
|
||||
session,
|
||||
classKind = ClassKind.ENUM_ENTRY,
|
||||
symbol = FirAnonymousObjectSymbol()
|
||||
).apply {
|
||||
superTypeRefs += FirResolvedTypeRefImpl(source = null, type = enumType)
|
||||
},
|
||||
delegate = null,
|
||||
isVar = false,
|
||||
symbol = FirPropertySymbol(CallableId(classId, enumEntryName)),
|
||||
isLocal = false,
|
||||
status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply {
|
||||
isStatic = true
|
||||
}
|
||||
).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
}
|
||||
|
||||
|
||||
symbol.fir
|
||||
property
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -317,19 +317,14 @@ fun BodyResolveComponents.typeForQualifier(resolvedQualifier: FirResolvedQualifi
|
||||
val classId = resolvedQualifier.classId
|
||||
val resultType = resolvedQualifier.resultType
|
||||
if (classId != null) {
|
||||
val classSymbol = symbolProvider.getClassLikeSymbolByFqName(classId)!!
|
||||
val classSymbol = symbolProvider.getClassLikeSymbolByFqName(classId)
|
||||
?: return FirErrorTypeRefImpl(source = null, diagnostic = FirSimpleDiagnostic("No type for qualifier", DiagnosticKind.Other))
|
||||
val declaration = classSymbol.phasedFir
|
||||
typeForQualifierByDeclaration(declaration, resultType)?.let { return it }
|
||||
if (declaration is FirRegularClass && declaration.classKind == ClassKind.ENUM_ENTRY) {
|
||||
val enumClassSymbol = symbolProvider.getClassLikeSymbolByFqName(classSymbol.classId.outerClassId!!)!!
|
||||
return resultType.resolvedTypeFromPrototype(
|
||||
enumClassSymbol.constructType(emptyArray(), false)
|
||||
)
|
||||
}
|
||||
}
|
||||
// TODO: Handle no value type here
|
||||
return resultType.resolvedTypeFromPrototype(
|
||||
session.builtinTypes.unitType.type//StandardClassIds.Unit(symbolProvider).constructType(emptyArray(), isNullable = false)
|
||||
session.builtinTypes.unitType.type
|
||||
)
|
||||
}
|
||||
|
||||
@@ -408,15 +403,9 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: AbstractFirBasedSymbol<
|
||||
is FirClassifierSymbol<*> -> {
|
||||
val fir = (symbol as? AbstractFirBasedSymbol<*>)?.phasedFir
|
||||
// TODO: unhack
|
||||
if (fir is FirEnumEntry) {
|
||||
(fir.superTypeRefs.firstOrNull() as? FirResolvedTypeRef) ?: FirErrorTypeRefImpl(
|
||||
null,
|
||||
FirSimpleDiagnostic("No enum item supertype", DiagnosticKind.EnumAsSupertype)
|
||||
)
|
||||
} else
|
||||
FirResolvedTypeRefImpl(
|
||||
null, symbol.constructType(emptyArray(), isNullable = false)
|
||||
)
|
||||
FirResolvedTypeRefImpl(
|
||||
null, symbol.constructType(emptyArray(), isNullable = false)
|
||||
)
|
||||
}
|
||||
else -> error("WTF ! $symbol")
|
||||
}
|
||||
|
||||
+8
-22
@@ -85,30 +85,16 @@ class FirLibrarySymbolProviderImpl(val session: FirSession, val kotlinScopeProvi
|
||||
parentContext: FirDeserializationContext? = null
|
||||
): FirRegularClassSymbol? {
|
||||
val classIdExists = classId in classDataFinder.allClassIds
|
||||
val shouldBeEnumEntry = !classIdExists && classId.outerClassId in classDataFinder.allClassIds
|
||||
if (!classIdExists && !shouldBeEnumEntry) return null
|
||||
if (shouldBeEnumEntry) {
|
||||
val outerClassData = classDataFinder.findClassData(classId.outerClassId!!)!!
|
||||
val outerClassProto = outerClassData.classProto
|
||||
if (outerClassProto.enumEntryList.none { nameResolver.getName(it.name) == classId.shortClassName }) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
if (!classIdExists) return null
|
||||
return lookup.getOrPut(classId, { FirRegularClassSymbol(classId) }) { symbol ->
|
||||
if (shouldBeEnumEntry) {
|
||||
FirEnumEntryImpl(null, session, classId.shortClassName, kotlinScopeProvider, symbol).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
}
|
||||
} else {
|
||||
val classData = classDataFinder.findClassData(classId)!!
|
||||
val classProto = classData.classProto
|
||||
val classData = classDataFinder.findClassData(classId)!!
|
||||
val classProto = classData.classProto
|
||||
|
||||
deserializeClassToSymbol(
|
||||
classId, classProto, symbol, nameResolver, session,
|
||||
null, kotlinScopeProvider, parentContext,
|
||||
this::findAndDeserializeClass
|
||||
)
|
||||
}
|
||||
deserializeClassToSymbol(
|
||||
classId, classProto, symbol, nameResolver, session,
|
||||
null, kotlinScopeProvider, parentContext,
|
||||
this::findAndDeserializeClass
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -133,7 +133,6 @@ class FirStatusResolveTransformer : FirAbstractTreeTransformer<FirDeclarationSta
|
||||
|
||||
private fun FirDeclaration.resolveModality(containingClass: FirRegularClass?): Modality {
|
||||
return when (this) {
|
||||
is FirEnumEntry -> Modality.FINAL
|
||||
is FirRegularClass -> if (classKind == ClassKind.INTERFACE) Modality.ABSTRACT else Modality.FINAL
|
||||
is FirCallableMemberDeclaration<*> -> {
|
||||
when {
|
||||
|
||||
+14
-10
@@ -11,12 +11,14 @@ import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.firSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeLookupTagBasedType
|
||||
import org.jetbrains.kotlin.fir.types.ConeNullability
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
@@ -72,16 +74,16 @@ class FirWhenExhaustivenessTransformer(private val bodyResolveComponents: BodyRe
|
||||
|
||||
private fun checkEnumExhaustiveness(whenExpression: FirWhenExpression, enum: FirRegularClass, nullable: Boolean): Boolean {
|
||||
val data = EnumExhaustivenessData(
|
||||
enum.collectEnumEntries().associateByTo(mutableMapOf(), { it.classId }, { false }),
|
||||
enum.collectEnumEntries().toMutableSet(),
|
||||
!nullable
|
||||
)
|
||||
for (branch in whenExpression.branches) {
|
||||
branch.condition.accept(EnumExhaustivenessVisitor, data)
|
||||
}
|
||||
return data.containsNull && data.visitedEntries.values.all { it }
|
||||
return data.containsNull && data.remainingEntries.isEmpty()
|
||||
}
|
||||
|
||||
private class EnumExhaustivenessData(val visitedEntries: MutableMap<ClassId, Boolean>, var containsNull: Boolean)
|
||||
private class EnumExhaustivenessData(val remainingEntries: MutableSet<FirPropertySymbol>, var containsNull: Boolean)
|
||||
|
||||
private object EnumExhaustivenessVisitor : FirVisitor<Unit, EnumExhaustivenessData>() {
|
||||
override fun visitElement(element: FirElement, data: EnumExhaustivenessData) {}
|
||||
@@ -94,9 +96,11 @@ class FirWhenExhaustivenessTransformer(private val bodyResolveComponents: BodyRe
|
||||
data.containsNull = true
|
||||
}
|
||||
}
|
||||
is FirResolvedQualifier -> {
|
||||
val classId = argument.classId ?: return
|
||||
data.visitedEntries.replace(classId, true)
|
||||
is FirQualifiedAccessExpression -> {
|
||||
val reference = argument.calleeReference as? FirResolvedNamedReference ?: return
|
||||
val symbol = reference.resolvedSymbol
|
||||
if (symbol is FirPropertySymbol)
|
||||
data.remainingEntries.remove(symbol)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,18 +119,18 @@ class FirWhenExhaustivenessTransformer(private val bodyResolveComponents: BodyRe
|
||||
if (sealedClass.inheritors.isEmpty()) return true
|
||||
val data = SealedExhaustivenessData(
|
||||
sealedClass.session.firSymbolProvider,
|
||||
sealedClass.inheritors.associateByTo(mutableMapOf(), { it }, { false }),
|
||||
sealedClass.inheritors.toMutableSet(),
|
||||
!nullable
|
||||
)
|
||||
for (branch in whenExpression.branches) {
|
||||
branch.condition.accept(SealedExhaustivenessVisitor, data)
|
||||
}
|
||||
return data.containsNull && data.visitedInheritors.values.all { it }
|
||||
return data.containsNull && data.remainingInheritors.isEmpty()
|
||||
}
|
||||
|
||||
private class SealedExhaustivenessData(
|
||||
val symbolProvider: FirSymbolProvider,
|
||||
val visitedInheritors: MutableMap<ClassId, Boolean>,
|
||||
val remainingInheritors: MutableSet<ClassId>,
|
||||
var containsNull: Boolean
|
||||
)
|
||||
|
||||
@@ -151,7 +155,7 @@ class FirWhenExhaustivenessTransformer(private val bodyResolveComponents: BodyRe
|
||||
override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef, data: SealedExhaustivenessData) {
|
||||
val lookupTag = (resolvedTypeRef.type as? ConeLookupTagBasedType)?.lookupTag ?: return
|
||||
val symbol = data.symbolProvider.getSymbolByLookupTag(lookupTag) as? FirClassSymbol ?: return
|
||||
data.visitedInheritors.replace(symbol.classId, true)
|
||||
data.remainingInheritors.remove(symbol.classId)
|
||||
}
|
||||
|
||||
override fun visitBinaryLogicExpression(binaryLogicExpression: FirBinaryLogicExpression, data: SealedExhaustivenessData) {
|
||||
|
||||
+9
-3
@@ -365,15 +365,21 @@ public abstract interface Comparable<in T> : R|kotlin/Any| {
|
||||
public final enum class DeprecationLevel : R|kotlin/Enum<kotlin/DeprecationLevel>| {
|
||||
private constructor(): R|kotlin/DeprecationLevel|
|
||||
|
||||
public? final enum entry WARNING : R|kotlin/DeprecationLevel| {
|
||||
public final static val WARNING: R|kotlin/DeprecationLevel| = object : R|kotlin/DeprecationLevel| {
|
||||
}
|
||||
|
||||
public? final enum entry ERROR : R|kotlin/DeprecationLevel| {
|
||||
|
||||
|
||||
public final static val ERROR: R|kotlin/DeprecationLevel| = object : R|kotlin/DeprecationLevel| {
|
||||
}
|
||||
|
||||
public? final enum entry HIDDEN : R|kotlin/DeprecationLevel| {
|
||||
|
||||
|
||||
public final static val HIDDEN: R|kotlin/DeprecationLevel| = object : R|kotlin/DeprecationLevel| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public final class Double : R|kotlin/Number|, R|kotlin/Comparable<kotlin/Double>| {
|
||||
|
||||
Vendored
+4
-1
@@ -6,9 +6,11 @@
|
||||
public final enum class E : R|kotlin/Enum<test/E>| {
|
||||
private constructor(): R|test/E|
|
||||
|
||||
public? final enum entry ENTRY : R|test/E| {
|
||||
public final static val ENTRY: R|test/E| = object : R|test/E| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public final annotation class EnumOption : R|kotlin/Annotation| {
|
||||
@@ -37,3 +39,4 @@ public final annotation class StringOptions : R|kotlin/Annotation| {
|
||||
public constructor(vararg option: R|kotlin/Array<out kotlin/String>|): R|test/StringOptions|
|
||||
|
||||
}
|
||||
|
||||
|
||||
Vendored
+4
-1
@@ -1,9 +1,11 @@
|
||||
public final enum class E : R|kotlin/Enum<test/E>| {
|
||||
private constructor(): R|test/E|
|
||||
|
||||
public? final enum entry CAKE : R|test/E| {
|
||||
public final static val CAKE: R|test/E| = object : R|test/E| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public final annotation class EnumAnno : R|kotlin/Annotation| {
|
||||
@@ -28,3 +30,4 @@ public final annotation class EnumArrayAnno : R|kotlin/Annotation| {
|
||||
public constructor(vararg value: R|kotlin/Array<out test/E>|): R|test/EnumArrayAnno|
|
||||
|
||||
}
|
||||
|
||||
|
||||
+12
-4
@@ -17,17 +17,25 @@ public final annotation class Bnno : R|kotlin/Annotation| {
|
||||
public final enum class Eee : R|kotlin/Enum<test/Eee>| {
|
||||
private constructor(): R|test/Eee|
|
||||
|
||||
public? final enum entry Entry1 : R|test/Eee| {
|
||||
public final static val Entry1: R|test/Eee| = object : R|test/Eee| {
|
||||
}
|
||||
|
||||
public? final enum entry Entry2 : R|test/Eee| {
|
||||
|
||||
|
||||
public final static val Entry2: R|test/Eee| = object : R|test/Eee| {
|
||||
}
|
||||
|
||||
public? final enum entry Entry3 : R|test/Eee| {
|
||||
|
||||
|
||||
public final static val Entry3: R|test/Eee| = object : R|test/Eee| {
|
||||
}
|
||||
|
||||
public? final enum entry Entry4 : R|test/Eee| {
|
||||
|
||||
|
||||
public final static val Entry4: R|test/Eee| = object : R|test/Eee| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
internal final enum class In : R|kotlin/Enum<test/In>| {
|
||||
private constructor(): R|test/In|
|
||||
|
||||
public? final enum entry A : R|test/In| {
|
||||
public final static val A: R|test/In| = object : R|test/In| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private final enum class Pr : R|kotlin/Enum<test/Pr>| {
|
||||
private constructor(): R|test/Pr|
|
||||
|
||||
public? final enum entry A : R|test/Pr| {
|
||||
public final static val A: R|test/Pr| = object : R|test/Pr| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public final enum class Pu : R|kotlin/Enum<test/Pu>| {
|
||||
private constructor(): R|test/Pu|
|
||||
|
||||
public? final enum entry A : R|test/Pu| {
|
||||
public final static val A: R|test/Pu| = object : R|test/Pu| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -7,14 +7,20 @@ public final enum class En : R|kotlin/Enum<test/En>| {
|
||||
|
||||
private constructor(b: R|kotlin/Boolean| = STUB, i: R|kotlin/Int| = STUB): R|test/En|
|
||||
|
||||
public? final enum entry E1 : R|test/En| {
|
||||
public final static val E1: R|test/En| = object : R|test/En| {
|
||||
}
|
||||
|
||||
public? final enum entry E2 : R|test/En| {
|
||||
|
||||
|
||||
public final static val E2: R|test/En| = object : R|test/En| {
|
||||
}
|
||||
|
||||
public? final enum entry E3 : R|test/En| {
|
||||
|
||||
|
||||
public final static val E3: R|test/En| = object : R|test/En| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -19,11 +19,15 @@ public final enum class Enum : R|kotlin/Enum<test/Enum>| {
|
||||
public abstract interface Trait : R|kotlin/Any| {
|
||||
}
|
||||
|
||||
public? final enum entry ENTRY1 : R|test/Enum| {
|
||||
public final static val ENTRY1: R|test/Enum| = object : R|test/Enum| {
|
||||
}
|
||||
|
||||
public? final enum entry ENTRY2 : R|test/Enum| {
|
||||
|
||||
|
||||
public final static val ENTRY2: R|test/Enum| = object : R|test/Enum| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@ public final class A : R|kotlin/Any| {
|
||||
public final enum class E : R|kotlin/Enum<test/A.E>| {
|
||||
private constructor(): R|test/A.E|
|
||||
|
||||
public? final enum entry ENTRY : R|test/A.E| {
|
||||
public final static val ENTRY: R|test/A.E| = object : R|test/A.E| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -9,9 +9,11 @@ public final class A : R|kotlin/Any| {
|
||||
public final enum class E : R|kotlin/Enum<test/A.E>| {
|
||||
private constructor(): R|test/A.E|
|
||||
|
||||
public? final enum entry ENTRY : R|test/A.E| {
|
||||
public final static val ENTRY: R|test/A.E| = object : R|test/A.E| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
public final enum class MyEnum : R|kotlin/Enum<test/MyEnum>| {
|
||||
private constructor(): R|test/MyEnum|
|
||||
|
||||
public? final enum entry ENTRY : R|test/MyEnum| {
|
||||
public final static val ENTRY: R|test/MyEnum| = object : R|test/MyEnum| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
public final enum class Test : R|kotlin/Enum<test/Test>| {
|
||||
private constructor(a: R|kotlin/Int|): R|test/Test|
|
||||
|
||||
public? final enum entry A : R|test/Test| {
|
||||
public final static val A: R|test/Test| = object : R|test/Test| {
|
||||
}
|
||||
|
||||
public? final enum entry B : R|test/Test| {
|
||||
|
||||
|
||||
public final static val B: R|test/Test| = object : R|test/Test| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+24
-8
@@ -1,29 +1,45 @@
|
||||
public final enum class E : R|kotlin/Enum<test/E>| {
|
||||
private constructor(): R|test/E|
|
||||
|
||||
public? final enum entry ONE : R|test/E| {
|
||||
public final static val ONE: R|test/E| = object : R|test/E| {
|
||||
}
|
||||
|
||||
public? final enum entry TWO : R|test/E| {
|
||||
|
||||
|
||||
public final static val TWO: R|test/E| = object : R|test/E| {
|
||||
}
|
||||
|
||||
public? final enum entry THREE : R|test/E| {
|
||||
|
||||
|
||||
public final static val THREE: R|test/E| = object : R|test/E| {
|
||||
}
|
||||
|
||||
public? final enum entry FOUR : R|test/E| {
|
||||
|
||||
|
||||
public final static val FOUR: R|test/E| = object : R|test/E| {
|
||||
}
|
||||
|
||||
public? final enum entry FIVE : R|test/E| {
|
||||
|
||||
|
||||
public final static val FIVE: R|test/E| = object : R|test/E| {
|
||||
}
|
||||
|
||||
public? final enum entry SIX : R|test/E| {
|
||||
|
||||
|
||||
public final static val SIX: R|test/E| = object : R|test/E| {
|
||||
}
|
||||
|
||||
public? final enum entry SEVEN : R|test/E| {
|
||||
|
||||
|
||||
public final static val SEVEN: R|test/E| = object : R|test/E| {
|
||||
}
|
||||
|
||||
public? final enum entry EIGHT : R|test/E| {
|
||||
|
||||
|
||||
public final static val EIGHT: R|test/E| = object : R|test/E| {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+8
-4
@@ -21,8 +21,8 @@ FILE: enum.kt
|
||||
public final val x: R|Some| = R|<local>/x|
|
||||
public get(): R|Some|
|
||||
|
||||
public final enum entry FIRST : R|SomeEnum| {
|
||||
public constructor(): R|SomeEnum.FIRST| {
|
||||
public final static val FIRST: R|SomeEnum| = object : R|SomeEnum| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|SomeEnum|>(Q|O1|)
|
||||
}
|
||||
|
||||
@@ -32,8 +32,10 @@ FILE: enum.kt
|
||||
|
||||
}
|
||||
|
||||
public final enum entry SECOND : R|SomeEnum| {
|
||||
public constructor(): R|SomeEnum.SECOND| {
|
||||
|
||||
|
||||
public final static val SECOND: R|SomeEnum| = object : R|SomeEnum| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|SomeEnum|>(Q|O2|)
|
||||
}
|
||||
|
||||
@@ -43,6 +45,8 @@ FILE: enum.kt
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public abstract fun check(y: R|Some|): R|kotlin/Boolean|
|
||||
|
||||
public final static fun values(): R|kotlin/Array<SomeEnum>| {
|
||||
|
||||
+12
-8
@@ -4,20 +4,24 @@ FILE: enumWithCompanion.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final enum entry A : R|kotlin/Any| {
|
||||
public constructor(): R|EC.A| {
|
||||
super<R|kotlin/Any|>()
|
||||
public final static val A: R|EC| = object : R|EC| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|EC|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final enum entry B : R|kotlin/Any| {
|
||||
public constructor(): R|EC.B| {
|
||||
super<R|kotlin/Any|>()
|
||||
|
||||
|
||||
public final static val B: R|EC| = object : R|EC| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|EC|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|EC.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
@@ -25,10 +29,10 @@ FILE: enumWithCompanion.kt
|
||||
|
||||
public final fun u(ec: R|EC|): R|kotlin/Boolean| {
|
||||
^u when (R|<local>/ec|) {
|
||||
==($subj$, Q|EC.A|) -> {
|
||||
==($subj$, R|/EC.A|) -> {
|
||||
Boolean(true)
|
||||
}
|
||||
==($subj$, Q|EC.B|) -> {
|
||||
==($subj$, R|/EC.B|) -> {
|
||||
Boolean(false)
|
||||
}
|
||||
}
|
||||
|
||||
+34
-28
@@ -4,27 +4,33 @@ FILE: exhaustiveness_enum.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final enum entry A : R|kotlin/Any| {
|
||||
public constructor(): R|Enum.A| {
|
||||
super<R|kotlin/Any|>()
|
||||
public final static val A: R|Enum| = object : R|Enum| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|Enum|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final enum entry B : R|kotlin/Any| {
|
||||
public constructor(): R|Enum.B| {
|
||||
super<R|kotlin/Any|>()
|
||||
|
||||
|
||||
public final static val B: R|Enum| = object : R|Enum| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|Enum|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final enum entry C : R|kotlin/Any| {
|
||||
public constructor(): R|Enum.C| {
|
||||
super<R|kotlin/Any|>()
|
||||
|
||||
|
||||
public final static val C: R|Enum| = object : R|Enum| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|Enum|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final static fun values(): R|kotlin/Array<Enum>| {
|
||||
}
|
||||
|
||||
@@ -34,19 +40,19 @@ FILE: exhaustiveness_enum.kt
|
||||
}
|
||||
public final fun test_1(e: R|Enum|): R|kotlin/Unit| {
|
||||
lval a: R|kotlin/Unit| = when (R|<local>/e|) {
|
||||
==($subj$, Q|Enum.A|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|Enum.B|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
}
|
||||
|
||||
lval b: R|kotlin/Unit| = when (R|<local>/e|) {
|
||||
==($subj$, Q|Enum.A|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|Enum.B|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
($subj$ is R|kotlin/String|) -> {
|
||||
@@ -55,19 +61,19 @@ FILE: exhaustiveness_enum.kt
|
||||
}
|
||||
|
||||
lval c: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
==($subj$, Q|Enum.A|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|Enum.B|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
==($subj$, Q|Enum.C|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.C|) -> {
|
||||
Int(3)
|
||||
}
|
||||
}
|
||||
|
||||
lval d: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
==($subj$, Q|Enum.A|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
else -> {
|
||||
@@ -78,25 +84,25 @@ FILE: exhaustiveness_enum.kt
|
||||
}
|
||||
public final fun test_2(e: R|Enum?|): R|kotlin/Unit| {
|
||||
lval a: R|kotlin/Unit| = when (R|<local>/e|) {
|
||||
==($subj$, Q|Enum.A|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|Enum.B|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
==($subj$, Q|Enum.C|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.C|) -> {
|
||||
Int(3)
|
||||
}
|
||||
}
|
||||
|
||||
lval a: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
==($subj$, Q|Enum.A|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|Enum.B|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
==($subj$, Q|Enum.C|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.C|) -> {
|
||||
Int(3)
|
||||
}
|
||||
==($subj$, Null(null)) -> {
|
||||
@@ -105,13 +111,13 @@ FILE: exhaustiveness_enum.kt
|
||||
}
|
||||
|
||||
lval a: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
==($subj$, Q|Enum.A|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|Enum.B|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
==($subj$, Q|Enum.C|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.C|) -> {
|
||||
Int(3)
|
||||
}
|
||||
else -> {
|
||||
@@ -122,10 +128,10 @@ FILE: exhaustiveness_enum.kt
|
||||
}
|
||||
public final fun test_3(e: R|Enum|): R|kotlin/Unit| {
|
||||
lval a: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
==($subj$, Q|Enum.A|) || ==($subj$, Q|Enum.B|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.A|) || ==($subj$, Q|Enum|.R|/Enum.B|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|Enum.C|) -> {
|
||||
==($subj$, Q|Enum|.R|/Enum.C|) -> {
|
||||
Int(2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,27 +4,33 @@ FILE: enumValues.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final enum entry FIRST : R|kotlin/Any| {
|
||||
public constructor(): R|MyEnum.FIRST| {
|
||||
super<R|kotlin/Any|>()
|
||||
public final static val FIRST: R|MyEnum| = object : R|MyEnum| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|MyEnum|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final enum entry SECOND : R|kotlin/Any| {
|
||||
public constructor(): R|MyEnum.SECOND| {
|
||||
super<R|kotlin/Any|>()
|
||||
|
||||
|
||||
public final static val SECOND: R|MyEnum| = object : R|MyEnum| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|MyEnum|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final enum entry LAST : R|kotlin/Any| {
|
||||
public constructor(): R|MyEnum.LAST| {
|
||||
super<R|kotlin/Any|>()
|
||||
|
||||
|
||||
public final static val LAST: R|MyEnum| = object : R|MyEnum| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|MyEnum|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final fun bar(): R|kotlin/Int| {
|
||||
^bar Int(42)
|
||||
}
|
||||
|
||||
+7
-5
@@ -33,13 +33,15 @@ FILE: qualifiedExpressions.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final enum entry entry : R|kotlin/Any| {
|
||||
public constructor(): R|a/b/E.entry| {
|
||||
super<R|kotlin/Any|>()
|
||||
public final static val entry: R|a/b/E| = object : R|a/b/E| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|a/b/E|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final static fun values(): R|kotlin/Array<a/b/E>| {
|
||||
}
|
||||
|
||||
@@ -58,6 +60,6 @@ FILE: qualifiedExpressions.kt
|
||||
lval x: R|kotlin/Int| = Q|a/b|.R|a/b/f|
|
||||
Q|a/b/C|.R|a/b/C.Companion.foo|()
|
||||
R|a/b/C.C|().R|a/b/C.foo|()
|
||||
lval e: R|a/b/E| = Q|a/b/E.entry|
|
||||
lval e1: R|a/b/E| = Q|a/b/E.entry|
|
||||
lval e: R|a/b/E| = Q|a/b/E|.R|a/b/E.entry|
|
||||
lval e1: R|a/b/E| = Q|a/b/E|.R|a/b/E.entry|
|
||||
}
|
||||
|
||||
+27
-15
@@ -4,27 +4,33 @@ FILE: enums.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final enum entry FIRST : R|kotlin/Any| {
|
||||
public constructor(): R|Order.FIRST| {
|
||||
super<R|kotlin/Any|>()
|
||||
public final static val FIRST: R|Order| = object : R|Order| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|Order|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final enum entry SECOND : R|kotlin/Any| {
|
||||
public constructor(): R|Order.SECOND| {
|
||||
super<R|kotlin/Any|>()
|
||||
|
||||
|
||||
public final static val SECOND: R|Order| = object : R|Order| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|Order|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final enum entry THIRD : R|kotlin/Any| {
|
||||
public constructor(): R|Order.THIRD| {
|
||||
super<R|kotlin/Any|>()
|
||||
|
||||
|
||||
public final static val THIRD: R|Order| = object : R|Order| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|Order|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final static fun values(): R|kotlin/Array<Order>| {
|
||||
}
|
||||
|
||||
@@ -43,8 +49,8 @@ FILE: enums.kt
|
||||
internal final val r: R|kotlin/Double| = R|<local>/r|
|
||||
internal get(): R|kotlin/Double|
|
||||
|
||||
public final enum entry MERCURY : R|Planet| {
|
||||
public constructor(): R|Planet.MERCURY| {
|
||||
public final static val MERCURY: R|Planet| = object : R|Planet| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|Planet|>(Double(1.0), Double(2.0))
|
||||
}
|
||||
|
||||
@@ -54,8 +60,10 @@ FILE: enums.kt
|
||||
|
||||
}
|
||||
|
||||
public final enum entry VENERA : R|Planet| {
|
||||
public constructor(): R|Planet.VENERA| {
|
||||
|
||||
|
||||
public final static val VENERA: R|Planet| = object : R|Planet| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|Planet|>(Double(3.0), Double(4.0))
|
||||
}
|
||||
|
||||
@@ -65,8 +73,10 @@ FILE: enums.kt
|
||||
|
||||
}
|
||||
|
||||
public final enum entry EARTH : R|Planet| {
|
||||
public constructor(): R|Planet.EARTH| {
|
||||
|
||||
|
||||
public final static val EARTH: R|Planet| = object : R|Planet| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|Planet|>(Double(5.0), Double(6.0))
|
||||
}
|
||||
|
||||
@@ -76,6 +86,8 @@ FILE: enums.kt
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final val g: R|kotlin/Double| = R|/Planet.Companion.G|.R|kotlin/Double.times|(R|<local>/m|).R|kotlin/Double.div|(R|<local>/r|.R|kotlin/Double.times|(R|<local>/r|))
|
||||
public get(): R|kotlin/Double|
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FILE: annotations.kt
|
||||
@R|kotlin/annotation/Target|(Q|kotlin/annotation/AnnotationTarget.FILE|, Q|kotlin/annotation/AnnotationTarget.FUNCTION|, Q|kotlin/annotation/AnnotationTarget.TYPE|, Q|kotlin/annotation/AnnotationTarget.PROPERTY_GETTER|) public final annotation class Simple : R|kotlin/Annotation| {
|
||||
@R|kotlin/annotation/Target|(Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.FILE|, Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.FUNCTION|, Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.TYPE|, Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.PROPERTY_GETTER|) public final annotation class Simple : R|kotlin/Annotation| {
|
||||
public constructor(): R|annotations/Simple| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.declarations
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.fir.FirPureAbstractElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
/*
|
||||
* This file was generated automatically
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
abstract class FirEnumEntry : FirPureAbstractElement(), FirRegularClass {
|
||||
abstract override val source: FirSourceElement?
|
||||
abstract override val session: FirSession
|
||||
abstract override val resolvePhase: FirResolvePhase
|
||||
abstract override val name: Name
|
||||
abstract override val annotations: List<FirAnnotationCall>
|
||||
abstract override val typeParameters: List<FirTypeParameter>
|
||||
abstract override val status: FirDeclarationStatus
|
||||
abstract override val classKind: ClassKind
|
||||
abstract override val declarations: List<FirDeclaration>
|
||||
abstract override val scopeProvider: FirScopeProvider
|
||||
abstract override val symbol: FirRegularClassSymbol
|
||||
abstract override val companionObject: FirRegularClass?
|
||||
abstract override val superTypeRefs: List<FirTypeRef>
|
||||
abstract val arguments: List<FirExpression>
|
||||
abstract val typeRef: FirTypeRef
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitEnumEntry(this, data)
|
||||
|
||||
abstract override fun <D> transformStatus(transformer: FirTransformer<D>, data: D): FirEnumEntry
|
||||
|
||||
abstract fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirEnumEntry
|
||||
}
|
||||
+1
-1
@@ -27,11 +27,11 @@ import org.jetbrains.kotlin.fir.visitors.*
|
||||
class FirAnonymousObjectImpl(
|
||||
override val source: FirSourceElement?,
|
||||
override val session: FirSession,
|
||||
override val classKind: ClassKind,
|
||||
override val scopeProvider: FirScopeProvider,
|
||||
override val symbol: FirAnonymousObjectSymbol
|
||||
) : FirAnonymousObject(), FirModifiableClass<FirAnonymousObject>, FirAbstractAnnotatedElement {
|
||||
override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR
|
||||
override val classKind: ClassKind get() = ClassKind.OBJECT
|
||||
override val superTypeRefs: MutableList<FirTypeRef> = mutableListOf()
|
||||
override val declarations: MutableList<FirDeclaration> = mutableListOf()
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.declarations.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationStatus
|
||||
import org.jetbrains.kotlin.fir.declarations.FirEnumEntry
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
/*
|
||||
* This file was generated automatically
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
class FirEnumEntryImpl(
|
||||
override val source: FirSourceElement?,
|
||||
override val session: FirSession,
|
||||
override val name: Name,
|
||||
override val scopeProvider: FirScopeProvider,
|
||||
override val symbol: FirRegularClassSymbol
|
||||
) : FirEnumEntry(), FirModifiableClass<FirRegularClass>, FirModifiableTypeParametersOwner, FirAbstractAnnotatedElement {
|
||||
override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
override val typeParameters: MutableList<FirTypeParameter> = mutableListOf()
|
||||
override var status: FirDeclarationStatus = FirDeclarationStatusImpl(Visibilities.UNKNOWN, Modality.FINAL)
|
||||
override val classKind: ClassKind get() = ClassKind.ENUM_ENTRY
|
||||
override val declarations: MutableList<FirDeclaration> = mutableListOf()
|
||||
override val companionObject: FirRegularClass? get() = null
|
||||
override val superTypeRefs: MutableList<FirTypeRef> = mutableListOf()
|
||||
override val arguments: MutableList<FirExpression> = mutableListOf()
|
||||
override var typeRef: FirTypeRef = session.builtinTypes.enumType
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
annotations.forEach { it.accept(visitor, data) }
|
||||
typeParameters.forEach { it.accept(visitor, data) }
|
||||
status.accept(visitor, data)
|
||||
declarations.forEach { it.accept(visitor, data) }
|
||||
superTypeRefs.forEach { it.accept(visitor, data) }
|
||||
arguments.forEach { it.accept(visitor, data) }
|
||||
typeRef.accept(visitor, data)
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirEnumEntryImpl {
|
||||
annotations.transformInplace(transformer, data)
|
||||
typeParameters.transformInplace(transformer, data)
|
||||
transformStatus(transformer, data)
|
||||
declarations.transformInplace(transformer, data)
|
||||
superTypeRefs.transformInplace(transformer, data)
|
||||
transformArguments(transformer, data)
|
||||
typeRef = typeRef.transformSingle(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformStatus(transformer: FirTransformer<D>, data: D): FirEnumEntryImpl {
|
||||
status = status.transformSingle(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirEnumEntryImpl {
|
||||
arguments.transformInplace(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) {
|
||||
resolvePhase = newResolvePhase
|
||||
}
|
||||
|
||||
override fun replaceSuperTypeRefs(newSuperTypeRefs: List<FirTypeRef>) {
|
||||
superTypeRefs.clear()
|
||||
superTypeRefs.addAll(newSuperTypeRefs)
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,6 @@ import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSealedClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
||||
import org.jetbrains.kotlin.fir.declarations.FirEnumEntry
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirContractDescriptionOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.FirMemberFunction
|
||||
@@ -258,10 +257,6 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
||||
return transformElement(typeAlias, data)
|
||||
}
|
||||
|
||||
open fun transformEnumEntry(enumEntry: FirEnumEntry, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformElement(enumEntry, data)
|
||||
}
|
||||
|
||||
open fun <F : FirFunction<F>> transformFunction(function: FirFunction<F>, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformElement(function, data)
|
||||
}
|
||||
@@ -714,10 +709,6 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
||||
return transformTypeAlias(typeAlias, data)
|
||||
}
|
||||
|
||||
final override fun visitEnumEntry(enumEntry: FirEnumEntry, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformEnumEntry(enumEntry, data)
|
||||
}
|
||||
|
||||
final override fun <F : FirFunction<F>> visitFunction(function: FirFunction<F>, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformFunction(function, data)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSealedClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
||||
import org.jetbrains.kotlin.fir.declarations.FirEnumEntry
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirContractDescriptionOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.FirMemberFunction
|
||||
@@ -192,8 +191,6 @@ abstract class FirVisitor<out R, in D> {
|
||||
|
||||
open fun visitTypeAlias(typeAlias: FirTypeAlias, data: D): R = visitElement(typeAlias, data)
|
||||
|
||||
open fun visitEnumEntry(enumEntry: FirEnumEntry, data: D): R = visitElement(enumEntry, data)
|
||||
|
||||
open fun <F : FirFunction<F>> visitFunction(function: FirFunction<F>, data: D): R = visitElement(function, data)
|
||||
|
||||
open fun visitContractDescriptionOwner(contractDescriptionOwner: FirContractDescriptionOwner, data: D): R = visitElement(contractDescriptionOwner, data)
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSealedClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
||||
import org.jetbrains.kotlin.fir.declarations.FirEnumEntry
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirContractDescriptionOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.FirMemberFunction
|
||||
@@ -256,10 +255,6 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
||||
visitElement(typeAlias)
|
||||
}
|
||||
|
||||
open fun visitEnumEntry(enumEntry: FirEnumEntry) {
|
||||
visitElement(enumEntry)
|
||||
}
|
||||
|
||||
open fun <F : FirFunction<F>> visitFunction(function: FirFunction<F>) {
|
||||
visitElement(function)
|
||||
}
|
||||
@@ -712,10 +707,6 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
||||
visitTypeAlias(typeAlias)
|
||||
}
|
||||
|
||||
final override fun visitEnumEntry(enumEntry: FirEnumEntry, data: Nothing?) {
|
||||
visitEnumEntry(enumEntry)
|
||||
}
|
||||
|
||||
final override fun <F : FirFunction<F>> visitFunction(function: FirFunction<F>, data: Nothing?) {
|
||||
visitFunction(function)
|
||||
}
|
||||
|
||||
@@ -272,9 +272,6 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
||||
)
|
||||
}
|
||||
|
||||
override fun visitEnumEntry(enumEntry: FirEnumEntry) {
|
||||
visitRegularClass(enumEntry)
|
||||
}
|
||||
|
||||
|
||||
private fun List<FirDeclaration>.renderDeclarations() {
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
package org.jetbrains.kotlin.fir.declarations
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirEnumEntryImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
||||
@@ -55,9 +55,6 @@ fun FirModifiableRegularClass.addDeclarations(declarations: Collection<FirDeclar
|
||||
declarations.forEach(this::addDeclaration)
|
||||
}
|
||||
|
||||
fun FirEnumEntryImpl.addDeclaration(declaration: FirDeclaration) {
|
||||
declarations += declaration
|
||||
}
|
||||
|
||||
val FirTypeAlias.expandedConeType: ConeClassLikeType? get() = expandedTypeRef.coneTypeSafe()
|
||||
|
||||
@@ -71,7 +68,14 @@ val FirClassSymbol<*>.superConeTypes
|
||||
|
||||
val FirClass<*>.superConeTypes get() = superTypeRefs.mapNotNull { it.coneTypeSafe<ConeClassLikeType>() }
|
||||
|
||||
fun FirRegularClass.collectEnumEntries(): Collection<FirEnumEntry> {
|
||||
fun FirRegularClass.collectEnumEntries(): Collection<FirPropertySymbol> {
|
||||
assert(classKind == ClassKind.ENUM_CLASS)
|
||||
return declarations.filterIsInstance<FirEnumEntry>()
|
||||
return declarations
|
||||
.mapNotNull {
|
||||
if (it !is FirProperty) return@mapNotNull null
|
||||
val initializer = it.initializer
|
||||
if (initializer == null || initializer !is FirAnonymousObject || initializer.classKind != ClassKind.ENUM_ENTRY)
|
||||
return@mapNotNull null
|
||||
return@mapNotNull it.symbol
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.visitors
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirEnumEntry
|
||||
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSealedClass
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
@@ -73,9 +72,6 @@ abstract class FirDefaultTransformer<D> : FirTransformer<D>() {
|
||||
return transformJump(breakExpression, data)
|
||||
}
|
||||
|
||||
override fun transformEnumEntry(enumEntry: FirEnumEntry, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformRegularClass(enumEntry, data)
|
||||
}
|
||||
|
||||
override fun transformLambdaArgumentExpression(lambdaArgumentExpression: FirLambdaArgumentExpression, data: D): CompositeTransformResult<FirStatement> {
|
||||
return transformWrappedArgumentExpression(lambdaArgumentExpression, data)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.visitors
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirEnumEntry
|
||||
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSealedClass
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
@@ -69,9 +68,6 @@ abstract class FirDefaultVisitor<R, D> : FirVisitor<R, D>() {
|
||||
return visitJump(breakExpression, data)
|
||||
}
|
||||
|
||||
override fun visitEnumEntry(enumEntry: FirEnumEntry, data: D): R {
|
||||
return visitRegularClass(enumEntry, data)
|
||||
}
|
||||
|
||||
override fun visitLambdaArgumentExpression(lambdaArgumentExpression: FirLambdaArgumentExpression, data: D): R {
|
||||
return visitWrappedArgumentExpression(lambdaArgumentExpression, data)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.visitors
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirEnumEntry
|
||||
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSealedClass
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
@@ -69,9 +68,6 @@ abstract class FirDefaultVisitorVoid : FirVisitorVoid() {
|
||||
return visitJump(breakExpression)
|
||||
}
|
||||
|
||||
override fun visitEnumEntry(enumEntry: FirEnumEntry) {
|
||||
return visitRegularClass(enumEntry)
|
||||
}
|
||||
|
||||
override fun visitLambdaArgumentExpression(lambdaArgumentExpression: FirLambdaArgumentExpression) {
|
||||
return visitWrappedArgumentExpression(lambdaArgumentExpression)
|
||||
|
||||
-1
@@ -45,7 +45,6 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
|
||||
val regularClass = element("RegularClass", Declaration, memberDeclaration, typeParametersOwner, klass)
|
||||
val sealedClass = element("SealedClass", Declaration, regularClass)
|
||||
val typeAlias = element("TypeAlias", Declaration, classLikeDeclaration, memberDeclaration, typeParametersOwner)
|
||||
val enumEntry = element("EnumEntry", Declaration, regularClass)
|
||||
|
||||
val function = element("Function", Declaration, callableDeclaration, controlFlowGraphOwner, targetElement, annotationContainer, typeParametersOwner, statement)
|
||||
|
||||
|
||||
-19
@@ -67,27 +67,8 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
|
||||
impl(anonymousObject) {
|
||||
parents += modifiableClass.withArg(anonymousObject)
|
||||
default("classKind") {
|
||||
value = "ClassKind.OBJECT"
|
||||
withGetter = true
|
||||
}
|
||||
}
|
||||
|
||||
impl(enumEntry) {
|
||||
parents += modifiableClass.withArg(regularClass)
|
||||
parents += modifiableTypeParametersOwner
|
||||
default("status", "FirDeclarationStatusImpl(Visibilities.UNKNOWN, Modality.FINAL)")
|
||||
default("classKind") {
|
||||
value = "ClassKind.ENUM_ENTRY"
|
||||
withGetter = true
|
||||
}
|
||||
default("companionObject") {
|
||||
value = "null"
|
||||
withGetter = true
|
||||
}
|
||||
default("typeRef", "session.builtinTypes.enumType")
|
||||
useTypes(visibilitiesType, modalityType)
|
||||
}
|
||||
|
||||
impl(typeAlias) {
|
||||
parents += modifiableTypeParametersOwner
|
||||
|
||||
-5
@@ -243,11 +243,6 @@ object NodeConfigurator : AbstractFieldConfigurator() {
|
||||
+annotations
|
||||
}
|
||||
|
||||
enumEntry.configure {
|
||||
+arguments.withTransform()
|
||||
+field(typeRef)
|
||||
}
|
||||
|
||||
anonymousFunction.configure {
|
||||
parentArg(function, "F", anonymousFunction)
|
||||
+symbol("FirAnonymousFunctionSymbol")
|
||||
|
||||
@@ -49,7 +49,7 @@ fun <T> bar(a: Any): T = a as T
|
||||
fun <T> foo() {
|
||||
foo<Color.RED>()
|
||||
foo<RedAlias>()
|
||||
bar<Color.RED>(Color.RED)
|
||||
<!INAPPLICABLE_CANDIDATE!>bar<!><Color.RED>(Color.RED)
|
||||
}
|
||||
|
||||
fun Array<Color.RED>.foo(entries: Array<Color.RED>): Array<Color.RED> = null!!
|
||||
+4
-4
@@ -16,12 +16,12 @@ enum class C {
|
||||
|
||||
E4 {
|
||||
fun c() {
|
||||
this.<!UNRESOLVED_REFERENCE!>B<!>()
|
||||
this.B()
|
||||
|
||||
C.A()
|
||||
A()
|
||||
//TODO: should be resolved with error
|
||||
this.<!UNRESOLVED_REFERENCE!>A<!>()
|
||||
this.A()
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,6 +45,6 @@ fun f() {
|
||||
C.A()
|
||||
C.<!UNRESOLVED_REFERENCE!>B<!>()
|
||||
|
||||
C.E3.O_O
|
||||
C.E3.G()
|
||||
C.E3.<!UNRESOLVED_REFERENCE!>O_O<!>
|
||||
C.E3.<!UNRESOLVED_REFERENCE!>G<!>()
|
||||
}
|
||||
|
||||
+4
-4
@@ -16,12 +16,12 @@ enum class C {
|
||||
|
||||
E4 {
|
||||
fun c() {
|
||||
this.<!UNRESOLVED_REFERENCE!>B<!>()
|
||||
this.B()
|
||||
|
||||
C.A()
|
||||
A()
|
||||
//TODO: should be resolved with error
|
||||
this.<!UNRESOLVED_REFERENCE!>A<!>()
|
||||
this.A()
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,6 +45,6 @@ fun f() {
|
||||
C.A()
|
||||
C.<!UNRESOLVED_REFERENCE!>B<!>()
|
||||
|
||||
C.E3.O_O
|
||||
C.E3.G()
|
||||
C.E3.<!UNRESOLVED_REFERENCE!>O_O<!>
|
||||
C.E3.<!UNRESOLVED_REFERENCE!>G<!>()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package kt1193
|
||||
|
||||
enum class MyEnum(val i: Int) {
|
||||
A(12),
|
||||
B //no error
|
||||
<!INAPPLICABLE_CANDIDATE!>B<!> //no error
|
||||
}
|
||||
|
||||
open class A(x: Int = 1)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ enum class TestOk(val x: String = "OK") {
|
||||
}
|
||||
|
||||
enum class TestErrors(val x: String) {
|
||||
TEST1,
|
||||
<!INAPPLICABLE_CANDIDATE!>TEST1,<!>
|
||||
TEST2<!INAPPLICABLE_CANDIDATE!><!>(),
|
||||
TEST3("Hello")
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,4 +13,4 @@ fun f1() = E.FIRST.foo()
|
||||
fun f2() = E.FIRST.(foo)()
|
||||
fun f3() = E.SECOND.foo()
|
||||
fun f4() = E.SECOND.(foo)()
|
||||
fun f5() = E.SECOND.A()
|
||||
fun f5() = E.SECOND.<!UNRESOLVED_REFERENCE!>A<!>()
|
||||
|
||||
+1
-1
@@ -13,4 +13,4 @@ fun f1() = E.FIRST.foo()
|
||||
fun f2() = E.FIRST.(foo)()
|
||||
fun f3() = E.SECOND.foo()
|
||||
fun f4() = E.SECOND.(foo)()
|
||||
fun f5() = E.SECOND.A()
|
||||
fun f5() = E.SECOND.<!UNRESOLVED_REFERENCE!>A<!>()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
enum interface Some {
|
||||
// Enum part
|
||||
D;
|
||||
<!UNRESOLVED_REFERENCE!>D;<!>
|
||||
|
||||
// Interface like part
|
||||
fun test()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
enum class E {
|
||||
E1 {
|
||||
override fun foo() = outerFun() <!AMBIGUITY!>+<!> super.<!UNRESOLVED_REFERENCE!>outerFun<!>()
|
||||
override fun foo() = outerFun() + super.outerFun()
|
||||
},
|
||||
E2 {
|
||||
override fun foo() = E1.foo()
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// FILE: common.kt
|
||||
|
||||
expect enum class En(x: Int) {
|
||||
E1,
|
||||
<!INAPPLICABLE_CANDIDATE!>E1,<!>
|
||||
E2(42),
|
||||
;
|
||||
|
||||
|
||||
+1
-1
@@ -17,5 +17,5 @@ enum class En {
|
||||
|
||||
fun ENTRY() = 42
|
||||
|
||||
fun SUBCLASS() = <!AMBIGUITY!>ENTRY<!>()
|
||||
fun SUBCLASS() = ENTRY()
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ object A {
|
||||
|
||||
enum class B {
|
||||
X() {
|
||||
constructor()
|
||||
<!CONSTRUCTOR_IN_OBJECT!>constructor()<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@ enum class MyEnum { A }
|
||||
typealias TestAlias = MyEnum
|
||||
|
||||
val test1 = MyEnum.A
|
||||
val test2 = TestAlias.<!UNRESOLVED_REFERENCE!>A<!>
|
||||
val test2 = TestAlias.A
|
||||
@@ -25,6 +25,6 @@ import test.EnumAlias
|
||||
|
||||
|
||||
fun bar() {
|
||||
<!UNRESOLVED_REFERENCE!>Entry<!>
|
||||
EnumAlias.<!UNRESOLVED_REFERENCE!>Entry<!>
|
||||
Entry
|
||||
EnumAlias.Entry
|
||||
}
|
||||
Reference in New Issue
Block a user