FIR: introduce symbols + type parameter resolve #KT-24064 Fixed
This commit is contained in:
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.descriptors
|
package org.jetbrains.kotlin.fir.descriptors
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
|
|
||||||
|
|
||||||
interface ConeDescriptor
|
interface ConeDescriptor
|
||||||
|
|
||||||
interface ConeClassifierDescriptor : ConeDescriptor
|
interface ConeClassifierDescriptor : ConeDescriptor
|
||||||
@@ -16,10 +16,12 @@ interface ConeClassifierDescriptor : ConeDescriptor
|
|||||||
interface ConeClassifierDescriptorWithTypeParameters : ConeClassifierDescriptor {
|
interface ConeClassifierDescriptorWithTypeParameters : ConeClassifierDescriptor {
|
||||||
val typeParameters: List<ConeTypeParameterDescriptor>
|
val typeParameters: List<ConeTypeParameterDescriptor>
|
||||||
|
|
||||||
val fqName: ClassId
|
val classId: ClassId
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ConeTypeParameterDescriptor : ConeClassifierDescriptor
|
interface ConeTypeParameterDescriptor : ConeClassifierDescriptor {
|
||||||
|
val symbol: ConeTypeParameterSymbol
|
||||||
|
}
|
||||||
|
|
||||||
interface ConeTypeAliasDescriptor : ConeClassifierDescriptorWithTypeParameters {
|
interface ConeTypeAliasDescriptor : ConeClassifierDescriptorWithTypeParameters {
|
||||||
val expandedType: ConeKotlinType
|
val expandedType: ConeKotlinType
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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.symbols
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
|
|
||||||
|
interface ConeSymbol
|
||||||
|
|
||||||
|
interface ConeTypeParameterSymbol : ConeSymbol
|
||||||
|
|
||||||
|
class ConeClassLikeSymbol(val classId: ClassId) : ConeSymbol
|
||||||
|
|
||||||
|
fun ClassId.toSymbol() = ConeClassLikeSymbol(this)
|
||||||
+18
-8
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.types
|
package org.jetbrains.kotlin.fir.types
|
||||||
|
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol
|
||||||
|
|
||||||
sealed class ConeKotlinTypeProjection(val kind: ProjectionKind)
|
sealed class ConeKotlinTypeProjection(val kind: ProjectionKind)
|
||||||
|
|
||||||
@@ -24,16 +26,24 @@ abstract class ConeKotlinTypeProjectionOut : ConeKotlinTypeProjection(Projection
|
|||||||
abstract val type: ConeKotlinType
|
abstract val type: ConeKotlinType
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ConeKotlinType : ConeKotlinTypeProjection(ProjectionKind.INVARIANT) {
|
abstract class ConeKotlinType : ConeKotlinTypeProjection(ProjectionKind.INVARIANT)
|
||||||
|
|
||||||
|
abstract class ConeSymbolBasedType : ConeKotlinType() {
|
||||||
|
abstract val symbol: ConeSymbol
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class ConeClassLikeType : ConeSymbolBasedType() {
|
||||||
|
abstract override val symbol: ConeClassLikeSymbol
|
||||||
|
|
||||||
abstract val typeArguments: List<ConeKotlinTypeProjection>
|
abstract val typeArguments: List<ConeKotlinTypeProjection>
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ConeClassType : ConeKotlinType() {
|
abstract class ConeAbbreviatedType : ConeClassLikeType() {
|
||||||
abstract val fqName: ClassId
|
abstract val abbreviationSymbol: ConeClassLikeSymbol
|
||||||
|
|
||||||
|
abstract val directExpansion: ConeClassLikeType
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ConeAbbreviatedType : ConeClassType() {
|
abstract class ConeTypeParameterType : ConeSymbolBasedType() {
|
||||||
abstract val abbreviationFqName: ClassId
|
abstract override val symbol: ConeTypeParameterSymbol
|
||||||
|
|
||||||
abstract val directExpansion: ConeKotlinType
|
|
||||||
}
|
}
|
||||||
@@ -5,21 +5,20 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.types.impl
|
package org.jetbrains.kotlin.fir.types.impl
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
|
||||||
|
|
||||||
open class ConeClassTypeImpl(
|
open class ConeClassTypeImpl(
|
||||||
override val fqName: ClassId,
|
override val symbol: ConeClassLikeSymbol,
|
||||||
override val typeArguments: List<ConeKotlinTypeProjection>
|
override val typeArguments: List<ConeKotlinTypeProjection>
|
||||||
) : ConeClassType()
|
) : ConeClassLikeType()
|
||||||
|
|
||||||
class ConeKotlinTypeProjectionInImpl(override val type: ConeKotlinType) : ConeKotlinTypeProjectionIn()
|
class ConeKotlinTypeProjectionInImpl(override val type: ConeKotlinType) : ConeKotlinTypeProjectionIn()
|
||||||
|
|
||||||
class ConeKotlinTypeProjectionOutImpl(override val type: ConeKotlinType) : ConeKotlinTypeProjectionOut()
|
class ConeKotlinTypeProjectionOutImpl(override val type: ConeKotlinType) : ConeKotlinTypeProjectionOut()
|
||||||
|
|
||||||
class ConeKotlinErrorType(val reason: String) : ConeKotlinType() {
|
class ConeKotlinErrorType(val reason: String) : ConeKotlinType() {
|
||||||
override val typeArguments: List<ConeKotlinTypeProjection>
|
|
||||||
get() = emptyList()
|
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "<ERROR TYPE: $reason>"
|
return "<ERROR TYPE: $reason>"
|
||||||
@@ -27,10 +26,12 @@ class ConeKotlinErrorType(val reason: String) : ConeKotlinType() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ConeAbbreviatedTypeImpl(
|
class ConeAbbreviatedTypeImpl(
|
||||||
override val abbreviationFqName: ClassId,
|
override val abbreviationSymbol: ConeClassLikeSymbol,
|
||||||
override val typeArguments: List<ConeKotlinTypeProjection>,
|
override val typeArguments: List<ConeKotlinTypeProjection>,
|
||||||
override val directExpansion: ConeKotlinType
|
override val directExpansion: ConeClassLikeType
|
||||||
) : ConeAbbreviatedType() {
|
) : ConeAbbreviatedType() {
|
||||||
override val fqName: ClassId
|
override val symbol: ConeClassLikeSymbol
|
||||||
get() = abbreviationFqName
|
get() = abbreviationSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ConeTypeParameterTypeImpl(override val symbol: ConeTypeParameterSymbol) : ConeTypeParameterType()
|
||||||
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
|||||||
import org.jetbrains.kotlin.fir.expressions.FirBody
|
import org.jetbrains.kotlin.fir.expressions.FirBody
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.FirType
|
import org.jetbrains.kotlin.fir.types.FirType
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
||||||
import org.jetbrains.kotlin.fir.types.impl.*
|
import org.jetbrains.kotlin.fir.types.impl.*
|
||||||
@@ -274,6 +275,7 @@ class RawFirBuilder(val session: FirSession) {
|
|||||||
typeAlias.getTypeReference().toFirOrErrorType()
|
typeAlias.getTypeReference().toFirOrErrorType()
|
||||||
)
|
)
|
||||||
typeAlias.extractAnnotationsTo(firTypeAlias)
|
typeAlias.extractAnnotationsTo(firTypeAlias)
|
||||||
|
typeAlias.extractTypeParametersTo(firTypeAlias)
|
||||||
return firTypeAlias
|
return firTypeAlias
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,7 +435,9 @@ class RawFirBuilder(val session: FirSession) {
|
|||||||
session,
|
session,
|
||||||
parameter,
|
parameter,
|
||||||
parameter.nameAsSafeName,
|
parameter.nameAsSafeName,
|
||||||
parameter.variance
|
parameter.variance,
|
||||||
|
parameter.hasModifier(KtTokens.REIFIED_KEYWORD),
|
||||||
|
FirTypeParameterSymbol()
|
||||||
)
|
)
|
||||||
parameter.extractAnnotationsTo(firTypeParameter)
|
parameter.extractAnnotationsTo(firTypeParameter)
|
||||||
val extendsBound = parameter.extendsBound
|
val extendsBound = parameter.extendsBound
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.name.ClassId
|
|||||||
|
|
||||||
class ConeClassDescriptorImpl(
|
class ConeClassDescriptorImpl(
|
||||||
override val typeParameters: List<ConeTypeParameterDescriptor>,
|
override val typeParameters: List<ConeTypeParameterDescriptor>,
|
||||||
override val fqName: ClassId,
|
override val classId: ClassId,
|
||||||
override val superTypes: List<ConeKotlinType>,
|
override val superTypes: List<ConeKotlinType>,
|
||||||
override val nestedClassifiers: List<ConeClassifierDescriptor>
|
override val nestedClassifiers: List<ConeClassifierDescriptor>
|
||||||
) : ConeClassDescriptor, AbstractFirBasedDescriptor<FirResolvedClass>()
|
) : ConeClassDescriptor, AbstractFirBasedDescriptor<FirResolvedClass>()
|
||||||
+1
-1
@@ -13,6 +13,6 @@ import org.jetbrains.kotlin.name.ClassId
|
|||||||
|
|
||||||
class ConeTypeAliasDescriptorImpl(
|
class ConeTypeAliasDescriptorImpl(
|
||||||
override val typeParameters: List<ConeTypeParameterDescriptor>,
|
override val typeParameters: List<ConeTypeParameterDescriptor>,
|
||||||
override val fqName: ClassId,
|
override val classId: ClassId,
|
||||||
override val expandedType: ConeKotlinType
|
override val expandedType: ConeKotlinType
|
||||||
) : ConeTypeAliasDescriptor, AbstractFirBasedDescriptor<FirResolvedTypeAlias>()
|
) : ConeTypeAliasDescriptor, AbstractFirBasedDescriptor<FirResolvedTypeAlias>()
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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.descriptors
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirResolvedTypeParameter
|
||||||
|
import org.jetbrains.kotlin.fir.descriptors.ConeTypeParameterDescriptor
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
|
class ConeTypeParameterDescriptorImpl(
|
||||||
|
override val symbol: ConeTypeParameterSymbol
|
||||||
|
) : ConeTypeParameterDescriptor, AbstractFirBasedDescriptor<FirResolvedTypeParameter>()
|
||||||
+38
-5
@@ -10,14 +10,18 @@ import org.jetbrains.kotlin.fir.FirElement
|
|||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedClassImpl
|
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedClassImpl
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedTypeAliasImpl
|
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedTypeAliasImpl
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedTypeParameterImpl
|
||||||
import org.jetbrains.kotlin.fir.descriptors.ConeClassifierDescriptor
|
import org.jetbrains.kotlin.fir.descriptors.ConeClassifierDescriptor
|
||||||
import org.jetbrains.kotlin.fir.descriptors.ConeTypeParameterDescriptor
|
import org.jetbrains.kotlin.fir.descriptors.ConeTypeParameterDescriptor
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.toSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.FirResolvedType
|
import org.jetbrains.kotlin.fir.types.FirResolvedType
|
||||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||||
import org.jetbrains.kotlin.fir.visitors.compose
|
import org.jetbrains.kotlin.fir.visitors.compose
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class FirClassifierResolveTransformer : FirTransformer<Nothing?>() {
|
class FirClassifierResolveTransformer : FirTransformer<Nothing?>() {
|
||||||
override fun <E : FirElement> transformElement(element: E, data: Nothing?): CompositeTransformResult<E> {
|
override fun <E : FirElement> transformElement(element: E, data: Nothing?): CompositeTransformResult<E> {
|
||||||
@@ -31,11 +35,11 @@ class FirClassifierResolveTransformer : FirTransformer<Nothing?>() {
|
|||||||
return file.also { it.transformChildren(this, null) }.compose()
|
return file.also { it.transformChildren(this, null) }.compose()
|
||||||
}
|
}
|
||||||
|
|
||||||
var className: FqName = FqName.ROOT
|
private var classLikeName: FqName = FqName.ROOT
|
||||||
|
|
||||||
override fun transformClass(klass: FirClass, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
override fun transformClass(klass: FirClass, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||||
val actualClassName = className.child(klass.name)
|
val actualClassName = classLikeName.child(klass.name)
|
||||||
className = actualClassName
|
classLikeName = actualClassName
|
||||||
|
|
||||||
klass.transformChildren(this, data)
|
klass.transformChildren(this, data)
|
||||||
|
|
||||||
@@ -43,7 +47,7 @@ class FirClassifierResolveTransformer : FirTransformer<Nothing?>() {
|
|||||||
(it as FirResolvedType).type
|
(it as FirResolvedType).type
|
||||||
}
|
}
|
||||||
|
|
||||||
className = className.parent()
|
classLikeName = classLikeName.parent()
|
||||||
|
|
||||||
val typeParameters =
|
val typeParameters =
|
||||||
klass.typeParameters.filterIsInstance<FirDescriptorOwner<*>>().mapNotNull { it.descriptor as? ConeTypeParameterDescriptor }
|
klass.typeParameters.filterIsInstance<FirDescriptorOwner<*>>().mapNotNull { it.descriptor as? ConeTypeParameterDescriptor }
|
||||||
@@ -65,15 +69,30 @@ class FirClassifierResolveTransformer : FirTransformer<Nothing?>() {
|
|||||||
return resolvedClass.compose()
|
return resolvedClass.compose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var memberName: Name? = null
|
||||||
|
|
||||||
|
override fun transformNamedFunction(namedFunction: FirNamedFunction, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||||
|
memberName = namedFunction.name
|
||||||
|
return super.transformNamedFunction(namedFunction, data).also {
|
||||||
|
memberName = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun transformTypeAlias(typeAlias: FirTypeAlias, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
override fun transformTypeAlias(typeAlias: FirTypeAlias, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||||
|
val actualClassName = classLikeName.child(typeAlias.name)
|
||||||
|
classLikeName = actualClassName
|
||||||
|
|
||||||
typeAlias.transformChildren(this, data)
|
typeAlias.transformChildren(this, data)
|
||||||
|
|
||||||
|
classLikeName = classLikeName.parent()
|
||||||
|
|
||||||
val expandedType = (typeAlias.expandedType as FirResolvedType).type
|
val expandedType = (typeAlias.expandedType as FirResolvedType).type
|
||||||
val typeParameters =
|
val typeParameters =
|
||||||
typeAlias.typeParameters.filterIsInstance<FirDescriptorOwner<*>>().mapNotNull { it.descriptor as? ConeTypeParameterDescriptor }
|
typeAlias.typeParameters.filterIsInstance<FirDescriptorOwner<*>>().mapNotNull { it.descriptor as? ConeTypeParameterDescriptor }
|
||||||
|
|
||||||
val descriptor = ConeTypeAliasDescriptorImpl(
|
val descriptor = ConeTypeAliasDescriptorImpl(
|
||||||
typeParameters,
|
typeParameters,
|
||||||
ClassId(packageFqName, className.child(typeAlias.name), false),
|
ClassId(packageFqName, classLikeName.child(typeAlias.name), false),
|
||||||
expandedType
|
expandedType
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -86,4 +105,18 @@ class FirClassifierResolveTransformer : FirTransformer<Nothing?>() {
|
|||||||
): CompositeTransformResult<FirDeclaration> {
|
): CompositeTransformResult<FirDeclaration> {
|
||||||
return resolvedTypeAlias.compose()
|
return resolvedTypeAlias.compose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun transformResolvedTypeParameter(
|
||||||
|
resolvedTypeParameter: FirResolvedTypeParameter,
|
||||||
|
data: Nothing?
|
||||||
|
): CompositeTransformResult<FirDeclaration> {
|
||||||
|
return resolvedTypeParameter.compose()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun transformTypeParameter(typeParameter: FirTypeParameter, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||||
|
typeParameter.transformChildren(this, data)
|
||||||
|
|
||||||
|
val descriptor = ConeTypeParameterDescriptorImpl(typeParameter.symbol)
|
||||||
|
return FirResolvedTypeParameterImpl(typeParameter, descriptor).compose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+41
-22
@@ -6,16 +6,11 @@
|
|||||||
package org.jetbrains.kotlin.descriptors
|
package org.jetbrains.kotlin.descriptors
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.FirElement
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
import org.jetbrains.kotlin.fir.FirRenderer
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.FirTypeResolver
|
import org.jetbrains.kotlin.fir.resolve.FirTypeResolver
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirCompositeScope
|
import org.jetbrains.kotlin.fir.scopes.impl.*
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitImportingScope
|
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirNestedClassifierScope
|
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirSelfImportingScope
|
|
||||||
import org.jetbrains.kotlin.fir.transformSingle
|
import org.jetbrains.kotlin.fir.transformSingle
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeImpl
|
||||||
@@ -26,6 +21,8 @@ import org.jetbrains.kotlin.fir.visitors.compose
|
|||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
|
fun FirElement.render(): String = buildString { this@render.accept(FirRenderer(this)) }
|
||||||
|
|
||||||
class FirTypeResolveTransformer(val superTypesOnly: Boolean = false) : FirTransformer<Nothing?>() {
|
class FirTypeResolveTransformer(val superTypesOnly: Boolean = false) : FirTransformer<Nothing?>() {
|
||||||
override fun <E : FirElement> transformElement(element: E, data: Nothing?): CompositeTransformResult<E> {
|
override fun <E : FirElement> transformElement(element: E, data: Nothing?): CompositeTransformResult<E> {
|
||||||
return if (superTypesOnly) {
|
return if (superTypesOnly) {
|
||||||
@@ -37,7 +34,7 @@ class FirTypeResolveTransformer(val superTypesOnly: Boolean = false) : FirTransf
|
|||||||
|
|
||||||
lateinit var scope: FirCompositeScope
|
lateinit var scope: FirCompositeScope
|
||||||
lateinit var packageFqName: FqName
|
lateinit var packageFqName: FqName
|
||||||
var className: FqName = FqName.ROOT
|
private var classLikeName: FqName = FqName.ROOT
|
||||||
|
|
||||||
override fun transformFile(file: FirFile, data: Nothing?): CompositeTransformResult<FirFile> {
|
override fun transformFile(file: FirFile, data: Nothing?): CompositeTransformResult<FirFile> {
|
||||||
scope = FirCompositeScope(
|
scope = FirCompositeScope(
|
||||||
@@ -56,26 +53,48 @@ class FirTypeResolveTransformer(val superTypesOnly: Boolean = false) : FirTransf
|
|||||||
return superTypesBuilder.classes
|
return superTypesBuilder.classes
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun transformClass(klass: FirClass, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
private fun resolveSuperTypesAndExpansions(element: FirMemberDeclaration) {
|
||||||
klass.transformChildren(SuperTypeResolver(), null)
|
try {
|
||||||
className = className.child(klass.name)
|
element.transformChildren(SuperTypeResolver(), null)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
class SuperTypeResolveException(cause: Exception) : Exception(element.render(), cause)
|
||||||
|
throw SuperTypeResolveException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scope.scopes += FirNestedClassifierScope(ClassId(packageFqName, className, false), klass.session)
|
override fun transformClass(klass: FirClass, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||||
scope.scopes.addAll(lookupSuperTypes(klass).map { FirNestedClassifierScope(it, klass.session) })
|
classLikeName = classLikeName.child(klass.name)
|
||||||
|
val classId = ClassId(packageFqName, classLikeName, false)
|
||||||
|
scope = FirCompositeScope(mutableListOf(scope))
|
||||||
|
scope.scopes += FirClassLikeTypeParameterScope(classId, klass.session)
|
||||||
|
resolveSuperTypesAndExpansions(klass)
|
||||||
|
|
||||||
|
scope.scopes += FirNestedClassifierScope(classId, klass.session)
|
||||||
|
val superTypeScopes = lookupSuperTypes(klass).map { FirNestedClassifierScope(it, klass.session) }
|
||||||
|
scope.scopes.addAll(superTypeScopes)
|
||||||
val result = super.transformClass(klass, data)
|
val result = super.transformClass(klass, data)
|
||||||
scope.scopes.also { it.removeAt(it.lastIndex) }
|
scope = scope.scopes[0] as FirCompositeScope
|
||||||
className = className.parent()
|
classLikeName = classLikeName.parent()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun transformTypeAlias(typeAlias: FirTypeAlias, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
override fun transformTypeAlias(typeAlias: FirTypeAlias, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||||
typeAlias.transformChildren(SuperTypeResolver(), null)
|
classLikeName = classLikeName.child(typeAlias.name)
|
||||||
|
val classId = ClassId(packageFqName, classLikeName, false)
|
||||||
|
scope = FirCompositeScope(mutableListOf(scope))
|
||||||
|
scope.scopes += FirClassLikeTypeParameterScope(classId, typeAlias.session)
|
||||||
|
|
||||||
|
resolveSuperTypesAndExpansions(typeAlias)
|
||||||
|
|
||||||
|
scope = scope.scopes[0] as FirCompositeScope
|
||||||
|
classLikeName = classLikeName.parent()
|
||||||
return super.transformTypeAlias(typeAlias, data)
|
return super.transformTypeAlias(typeAlias, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun transformType(type: FirType, data: Nothing?): CompositeTransformResult<FirType> {
|
override fun transformType(type: FirType, data: Nothing?): CompositeTransformResult<FirType> {
|
||||||
val typeResolver = FirTypeResolver.getInstance(type.session)
|
val typeResolver = FirTypeResolver.getInstance(type.session)
|
||||||
|
type.transformChildren(this, data)
|
||||||
return FirResolvedTypeImpl(
|
return FirResolvedTypeImpl(
|
||||||
type.session,
|
type.session,
|
||||||
type.psi,
|
type.psi,
|
||||||
@@ -98,7 +117,7 @@ class FirTypeResolveTransformer(val superTypesOnly: Boolean = false) : FirTransf
|
|||||||
override fun transformType(type: FirType, data: Nothing?): CompositeTransformResult<FirType> {
|
override fun transformType(type: FirType, data: Nothing?): CompositeTransformResult<FirType> {
|
||||||
val transformedType = this@FirTypeResolveTransformer.transformType(type, data).single as FirResolvedType
|
val transformedType = this@FirTypeResolveTransformer.transformType(type, data).single as FirResolvedType
|
||||||
|
|
||||||
val classId = (transformedType.type as? ConeClassType)?.fqName ?: return transformedType.compose()
|
val classId = (transformedType.type as? ConeClassLikeType)?.symbol?.classId ?: return transformedType.compose()
|
||||||
val firProvider = FirProvider.getInstance(transformedType.session)
|
val firProvider = FirProvider.getInstance(transformedType.session)
|
||||||
|
|
||||||
val classes = generateSequence(classId) { it.outerClassId }.toList()
|
val classes = generateSequence(classId) { it.outerClassId }.toList()
|
||||||
@@ -123,10 +142,10 @@ class FirTypeResolveTransformer(val superTypesOnly: Boolean = false) : FirTransf
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
private tailrec fun ConeClassType.computePartialExpansion(): ClassId {
|
private tailrec fun ConeClassLikeType.computePartialExpansion(): ClassId {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
!is ConeAbbreviatedType -> this.fqName
|
!is ConeAbbreviatedType -> this.symbol.classId
|
||||||
else -> (this.directExpansion as ConeClassType).computePartialExpansion()
|
else -> this.directExpansion.computePartialExpansion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +153,7 @@ class FirTypeResolveTransformer(val superTypesOnly: Boolean = false) : FirTransf
|
|||||||
|
|
||||||
override fun visitResolvedType(resolvedType: FirResolvedType, data: Nothing?): Boolean {
|
override fun visitResolvedType(resolvedType: FirResolvedType, data: Nothing?): Boolean {
|
||||||
val provider = FirProvider.getInstance(resolvedType.session)
|
val provider = FirProvider.getInstance(resolvedType.session)
|
||||||
val targetClassId = resolvedType.coneTypeSafe<ConeClassType>()?.computePartialExpansion() ?: return false
|
val targetClassId = resolvedType.coneTypeSafe<ConeClassLikeType>()?.computePartialExpansion() ?: return false
|
||||||
val classifier = provider.getFirClassifierByFqName(targetClassId)!!
|
val classifier = provider.getFirClassifierByFqName(targetClassId)!!
|
||||||
when (classifier) {
|
when (classifier) {
|
||||||
is FirClass -> {
|
is FirClass -> {
|
||||||
|
|||||||
@@ -6,22 +6,20 @@
|
|||||||
package org.jetbrains.kotlin.fir.resolve
|
package org.jetbrains.kotlin.fir.resolve
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
|
||||||
import org.jetbrains.kotlin.fir.service
|
import org.jetbrains.kotlin.fir.service
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
|
|
||||||
interface FirProvider {
|
interface FirProvider {
|
||||||
fun getFirClassifierByFqName(fqName: ClassId): FirMemberDeclaration?
|
fun getFirClassifierByFqName(fqName: ClassId): FirMemberDeclaration? // FirSymbol?
|
||||||
|
|
||||||
fun getFirTypeParameterByFqName(fqName: ClassId, parameterName: Name): FirTypeParameter?
|
|
||||||
|
|
||||||
fun getFirClassifierContainerFile(fqName: ClassId): FirFile
|
fun getFirClassifierContainerFile(fqName: ClassId): FirFile
|
||||||
|
|
||||||
|
fun getFirClassifierBySymbol(symbol: ConeSymbol): FirMemberDeclaration?
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getInstance(session: FirSession): FirProvider = session.service()
|
fun getInstance(session: FirSession): FirProvider = session.service()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,22 @@ import org.jetbrains.kotlin.fir.FirElement
|
|||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
|
|
||||||
class FirProviderImpl(val session: FirSession) : FirProvider {
|
class FirProviderImpl(val session: FirSession) : FirProvider {
|
||||||
|
override fun getFirClassifierBySymbol(symbol: ConeSymbol): FirMemberDeclaration? {
|
||||||
|
return when(symbol) {
|
||||||
|
is FirBasedSymbol<*> -> symbol.fir as? FirMemberDeclaration
|
||||||
|
is ConeClassLikeSymbol -> getFirClassifierByFqName(symbol.classId)
|
||||||
|
else -> error("!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun getFirClassifierContainerFile(fqName: ClassId): FirFile {
|
override fun getFirClassifierContainerFile(fqName: ClassId): FirFile {
|
||||||
return classifierContainerFileMap[fqName] ?: error("Couldn't find container for $fqName")
|
return classifierContainerFileMap[fqName] ?: error("Couldn't find container for $fqName")
|
||||||
}
|
}
|
||||||
@@ -60,9 +70,4 @@ class FirProviderImpl(val session: FirSession) : FirProvider {
|
|||||||
return classifierMap[fqName]
|
return classifierMap[fqName]
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getFirTypeParameterByFqName(fqName: ClassId, parameterName: Name): FirTypeParameter? {
|
|
||||||
val typeParameterContainer = (getFirClassifierByFqName(fqName) as? FirTypeParameterContainer) ?: return null
|
|
||||||
// TODO: Optimize search here
|
|
||||||
return typeParameterContainer.typeParameters.find { it.name == parameterName }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+11
-11
@@ -11,11 +11,9 @@ import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
||||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.FirQualifierResolver
|
import org.jetbrains.kotlin.fir.resolve.FirQualifierResolver
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.toSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeAbbreviatedTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl
|
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeKotlinTypeProjectionInImpl
|
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeKotlinTypeProjectionOutImpl
|
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
@@ -42,15 +40,17 @@ class FirQualifierResolverImpl(val session: FirSession) : FirQualifierResolver {
|
|||||||
private fun FirMemberDeclaration.toConeKotlinType(fqName: ClassId, parts: List<FirQualifierPart>): ConeKotlinType? {
|
private fun FirMemberDeclaration.toConeKotlinType(fqName: ClassId, parts: List<FirQualifierPart>): ConeKotlinType? {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is FirClass -> {
|
is FirClass -> {
|
||||||
ConeClassTypeImpl(fqName, parts.toTypeProjections())
|
ConeClassTypeImpl(fqName.toSymbol(), parts.toTypeProjections())
|
||||||
}
|
}
|
||||||
is FirTypeAlias -> {
|
is FirTypeAlias -> {
|
||||||
ConeAbbreviatedTypeImpl(
|
val expansion = expandedType.coneTypeSafe<ConeClassLikeType>()
|
||||||
abbreviationFqName = fqName,
|
?: return ConeKotlinErrorType("Couldn't resolve expansion")
|
||||||
typeArguments = parts.toTypeProjections(),
|
|
||||||
directExpansion = (this.expandedType as FirResolvedType).type
|
|
||||||
)
|
|
||||||
|
|
||||||
|
ConeAbbreviatedTypeImpl(
|
||||||
|
abbreviationSymbol = fqName.toSymbol(),
|
||||||
|
typeArguments = parts.toTypeProjections(),
|
||||||
|
directExpansion = expansion
|
||||||
|
)
|
||||||
}
|
}
|
||||||
else -> error("!")
|
else -> error("!")
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ class FirQualifierResolverImpl(val session: FirSession) : FirQualifierResolver {
|
|||||||
|
|
||||||
val fqName = ClassId(
|
val fqName = ClassId(
|
||||||
prefix.packageFqName,
|
prefix.packageFqName,
|
||||||
parts.fold(prefix.relativeClassName) { prefix, suffix -> prefix.child(suffix.name) },
|
parts.drop(1).fold(prefix.relativeClassName) { prefix, suffix -> prefix.child(suffix.name) },
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
val foundClassifier = firProvider.getFirClassifierByFqName(fqName)
|
val foundClassifier = firProvider.getFirClassifierByFqName(fqName)
|
||||||
|
|||||||
+14
-2
@@ -8,8 +8,11 @@ package org.jetbrains.kotlin.fir.resolve.impl
|
|||||||
import org.jetbrains.kotlin.fir.resolve.FirQualifierResolver
|
import org.jetbrains.kotlin.fir.resolve.FirQualifierResolver
|
||||||
import org.jetbrains.kotlin.fir.resolve.FirTypeResolver
|
import org.jetbrains.kotlin.fir.resolve.FirTypeResolver
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeKotlinErrorType
|
import org.jetbrains.kotlin.fir.types.impl.ConeKotlinErrorType
|
||||||
|
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||||
|
|
||||||
class FirTypeResolverImpl : FirTypeResolver {
|
class FirTypeResolverImpl : FirTypeResolver {
|
||||||
override fun resolveType(type: FirType, scope: FirScope): ConeKotlinType {
|
override fun resolveType(type: FirType, scope: FirScope): ConeKotlinType {
|
||||||
@@ -20,8 +23,17 @@ class FirTypeResolverImpl : FirTypeResolver {
|
|||||||
val qualifierResolver = FirQualifierResolver.getInstance(type.session)
|
val qualifierResolver = FirQualifierResolver.getInstance(type.session)
|
||||||
|
|
||||||
var resolvedType: ConeKotlinType? = null
|
var resolvedType: ConeKotlinType? = null
|
||||||
scope.processClassifiersByName(type.qualifier.first().name) { fqName ->
|
scope.processClassifiersByName(type.qualifier.first().name) { symbol ->
|
||||||
resolvedType = qualifierResolver.resolveTypeWithPrefix(type.qualifier.drop(1), fqName)
|
resolvedType = when (symbol) {
|
||||||
|
is ConeClassLikeSymbol -> {
|
||||||
|
qualifierResolver.resolveTypeWithPrefix(type.qualifier, symbol.classId)
|
||||||
|
}
|
||||||
|
is ConeTypeParameterSymbol -> {
|
||||||
|
assert(type.qualifier.size == 1)
|
||||||
|
ConeTypeParameterTypeImpl(symbol)
|
||||||
|
}
|
||||||
|
else -> error("!")
|
||||||
|
}
|
||||||
resolvedType == null
|
resolvedType == null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.scopes
|
package org.jetbrains.kotlin.fir.scopes
|
||||||
|
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
interface FirScope {
|
interface FirScope {
|
||||||
fun processClassifiersByName(name: Name, processor: (ClassId) -> Boolean): Boolean
|
fun processClassifiersByName(name: Name, processor: (ConeSymbol) -> Boolean): Boolean
|
||||||
}
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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.scopes.impl
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||||
|
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||||
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
|
class FirClassLikeTypeParameterScope(val classId: ClassId, val session: FirSession) : FirScope {
|
||||||
|
|
||||||
|
private val firProvider = FirProvider.getInstance(session)
|
||||||
|
|
||||||
|
val typeParameters = firProvider.getFirClassifierByFqName(classId)?.typeParameters.orEmpty().groupBy { it.name }
|
||||||
|
|
||||||
|
override fun processClassifiersByName(name: Name, processor: (ConeSymbol) -> Boolean): Boolean {
|
||||||
|
val matchedTypeParameters = typeParameters[name] ?: return true
|
||||||
|
|
||||||
|
return matchedTypeParameters.all { processor(it.symbol) }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,11 +6,11 @@
|
|||||||
package org.jetbrains.kotlin.fir.scopes.impl
|
package org.jetbrains.kotlin.fir.scopes.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class FirCompositeScope(val scopes: MutableList<FirScope>) : FirScope {
|
class FirCompositeScope(val scopes: MutableList<FirScope>) : FirScope {
|
||||||
override fun processClassifiersByName(name: Name, processor: (ClassId) -> Boolean): Boolean {
|
override fun processClassifiersByName(name: Name, processor: (ConeSymbol) -> Boolean): Boolean {
|
||||||
for (scope in scopes) {
|
for (scope in scopes) {
|
||||||
if (!scope.processClassifiersByName(name, processor)) {
|
if (!scope.processClassifiersByName(name, processor)) {
|
||||||
return false
|
return false
|
||||||
|
|||||||
+4
-3
@@ -8,7 +8,8 @@ package org.jetbrains.kotlin.fir.scopes.impl
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirImport
|
import org.jetbrains.kotlin.fir.declarations.FirImport
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport
|
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.toSymbol
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class FirExplicitImportingScope(imports: List<FirImport>) : FirScope {
|
class FirExplicitImportingScope(imports: List<FirImport>) : FirScope {
|
||||||
@@ -19,10 +20,10 @@ class FirExplicitImportingScope(imports: List<FirImport>) : FirScope {
|
|||||||
.filter { !it.isAllUnder }
|
.filter { !it.isAllUnder }
|
||||||
.groupBy { it.aliasName ?: it.resolvedFqName.shortClassName }
|
.groupBy { it.aliasName ?: it.resolvedFqName.shortClassName }
|
||||||
|
|
||||||
override fun processClassifiersByName(name: Name, processor: (ClassId) -> Boolean): Boolean {
|
override fun processClassifiersByName(name: Name, processor: (ConeSymbol) -> Boolean): Boolean {
|
||||||
val imports = simpleImports[name] ?: return true
|
val imports = simpleImports[name] ?: return true
|
||||||
for (import in imports) {
|
for (import in imports) {
|
||||||
if (!processor(import.resolvedFqName)) {
|
if (!processor(import.resolvedFqName.toSymbol())) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -9,6 +9,8 @@ import org.jetbrains.kotlin.fir.FirSession
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
||||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.toSymbol
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
@@ -20,8 +22,8 @@ class FirNestedClassifierScope(val classId: ClassId, val session: FirSession) :
|
|||||||
return firProvider.getFirClassifierByFqName(this)
|
return firProvider.getFirClassifierByFqName(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processClassifiersByName(name: Name, processor: (ClassId) -> Boolean): Boolean {
|
override fun processClassifiersByName(name: Name, processor: (ConeSymbol) -> Boolean): Boolean {
|
||||||
val child = ClassId(classId.packageFqName, classId.relativeClassName.child(name), false)
|
val child = ClassId(classId.packageFqName, classId.relativeClassName.child(name), false)
|
||||||
return child.getFir() == null || processor(child)
|
return child.getFir() == null || processor(child.toSymbol())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -9,22 +9,22 @@ import org.jetbrains.kotlin.fir.FirSession
|
|||||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||||
import org.jetbrains.kotlin.fir.service
|
import org.jetbrains.kotlin.fir.service
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.toSymbol
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class FirSelfImportingScope(val fqName: FqName, val session: FirSession) : FirScope {
|
class FirSelfImportingScope(val fqName: FqName, val session: FirSession) : FirScope {
|
||||||
override fun processClassifiersByName(name: Name, processor: (ClassId) -> Boolean): Boolean {
|
override fun processClassifiersByName(name: Name, processor: (ConeSymbol) -> Boolean): Boolean {
|
||||||
|
|
||||||
|
|
||||||
val unambiguousFqName = ClassId(fqName, name)
|
val unambiguousFqName = ClassId(fqName, name)
|
||||||
|
|
||||||
val firProvider = session.service<FirProvider>()
|
val firProvider = session.service<FirProvider>()
|
||||||
|
|
||||||
if (firProvider.getFirClassifierByFqName(unambiguousFqName) != null) {
|
return if (firProvider.getFirClassifierByFqName(unambiguousFqName) != null) {
|
||||||
return processor(unambiguousFqName)
|
processor(unambiguousFqName.toSymbol())
|
||||||
} else {
|
} else {
|
||||||
return true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,9 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
|||||||
import org.jetbrains.kotlin.descriptors.Visibility
|
import org.jetbrains.kotlin.descriptors.Visibility
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeKotlinErrorType
|
import org.jetbrains.kotlin.fir.types.impl.ConeKotlinErrorType
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||||
@@ -293,6 +296,11 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
|||||||
println()
|
println()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitResolvedTypeParameter(resolvedTypeParameter: FirResolvedTypeParameter) {
|
||||||
|
print("(resolved) ")
|
||||||
|
visitTypeParameter(resolvedTypeParameter)
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitTypeParameter(typeParameter: FirTypeParameter) {
|
override fun visitTypeParameter(typeParameter: FirTypeParameter) {
|
||||||
typeParameter.annotations.renderAnnotations()
|
typeParameter.annotations.renderAnnotations()
|
||||||
typeParameter.variance.renderVariance()
|
typeParameter.variance.renderVariance()
|
||||||
@@ -399,33 +407,38 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
|||||||
visitTypeWithNullability(functionType)
|
visitTypeWithNullability(functionType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun ConeSymbol.asString(): String {
|
||||||
|
return when (this) {
|
||||||
|
is ConeClassLikeSymbol -> classId.asString()
|
||||||
|
is FirTypeParameterSymbol -> fir.name.asString()
|
||||||
|
else -> "Unsupported: ${this::class}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun ConeKotlinType.asString(): String {
|
private fun ConeKotlinType.asString(): String {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is ConeKotlinErrorType -> "error: $reason"
|
is ConeKotlinErrorType -> "error: $reason"
|
||||||
is ConeClassType -> {
|
is ConeClassLikeType -> {
|
||||||
val sb = StringBuilder()
|
val sb = StringBuilder()
|
||||||
val fqName = fqName
|
sb.append(symbol.classId.asString())
|
||||||
val packageFqName = fqName.packageFqName
|
if (typeArguments.isNotEmpty()) {
|
||||||
if (packageFqName.isRoot) {
|
sb.append(typeArguments.joinToString(prefix = "<", postfix = ">") { it ->
|
||||||
sb.append("<root>")
|
when (it) {
|
||||||
} else {
|
StarProjection -> "*"
|
||||||
sb.append(packageFqName.asString().replace('.', '/'))
|
is ConeKotlinTypeProjectionIn -> "in ${it.type.asString()}"
|
||||||
|
is ConeKotlinTypeProjectionOut -> "out ${it.type.asString()}"
|
||||||
|
is ConeKotlinType -> it.asString()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
sb.append('.')
|
|
||||||
sb.append(fqName.relativeClassName.asString())
|
|
||||||
sb.append(typeArguments.joinToString { it ->
|
|
||||||
when (it) {
|
|
||||||
StarProjection -> "*"
|
|
||||||
is ConeKotlinTypeProjectionIn -> "in ${it.type.asString()}"
|
|
||||||
is ConeKotlinTypeProjectionOut -> "out ${it.type.asString()}"
|
|
||||||
is ConeKotlinType -> it.asString()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (this is ConeAbbreviatedType) {
|
if (this is ConeAbbreviatedType) {
|
||||||
sb.append(" = ${this.directExpansion.asString()}")
|
sb.append(" = ${this.directExpansion.asString()}")
|
||||||
}
|
}
|
||||||
sb.toString()
|
sb.toString()
|
||||||
}
|
}
|
||||||
|
is ConeTypeParameterType -> {
|
||||||
|
symbol.asString()
|
||||||
|
}
|
||||||
else -> "Unsupported: $this"
|
else -> "Unsupported: $this"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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.fir.FirDescriptorOwner
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||||
|
|
||||||
|
interface FirResolvedTypeParameter : FirTypeParameter, FirDescriptorOwner<FirResolvedTypeParameter> {
|
||||||
|
|
||||||
|
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R =
|
||||||
|
visitor.visitResolvedTypeParameter(this, data)
|
||||||
|
}
|
||||||
@@ -7,16 +7,22 @@ package org.jetbrains.kotlin.fir.declarations
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.fir.BaseTransformedType
|
import org.jetbrains.kotlin.fir.BaseTransformedType
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationContainer
|
import org.jetbrains.kotlin.fir.expressions.FirAnnotationContainer
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.FirType
|
import org.jetbrains.kotlin.fir.types.FirType
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
@BaseTransformedType
|
@BaseTransformedType
|
||||||
interface FirTypeParameter : FirNamedDeclaration, FirAnnotationContainer {
|
interface FirTypeParameter : FirNamedDeclaration, FirAnnotationContainer, FirSymbolOwner<FirTypeParameter> {
|
||||||
val variance: Variance
|
val variance: Variance
|
||||||
|
|
||||||
|
val isReified: Boolean
|
||||||
|
|
||||||
val bounds: List<FirType>
|
val bounds: List<FirType>
|
||||||
|
|
||||||
|
override val symbol: FirTypeParameterSymbol
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R =
|
||||||
visitor.visitTypeParameter(this, data)
|
visitor.visitTypeParameter(this, data)
|
||||||
|
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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.fir.FirBasedDescriptor
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirResolvedTypeParameter
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||||
|
|
||||||
|
class FirResolvedTypeParameterImpl(val delegate: FirTypeParameter, override val descriptor: FirBasedDescriptor<FirResolvedTypeParameter>) :
|
||||||
|
FirResolvedTypeParameter, FirTypeParameter by delegate {
|
||||||
|
|
||||||
|
init {
|
||||||
|
symbol.bind(this)
|
||||||
|
descriptor.bind(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun accept(visitor: FirVisitorVoid) {
|
||||||
|
return super<FirResolvedTypeParameter>.accept(visitor)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R {
|
||||||
|
return super<FirResolvedTypeParameter>.accept(visitor, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.descriptors.Visibility
|
|||||||
import org.jetbrains.kotlin.fir.FirElement
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
||||||
|
import org.jetbrains.kotlin.fir.transformInplace
|
||||||
import org.jetbrains.kotlin.fir.transformSingle
|
import org.jetbrains.kotlin.fir.transformSingle
|
||||||
import org.jetbrains.kotlin.fir.types.FirType
|
import org.jetbrains.kotlin.fir.types.FirType
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||||
@@ -24,6 +25,7 @@ class FirTypeAliasImpl(
|
|||||||
override var expandedType: FirType
|
override var expandedType: FirType
|
||||||
) : FirAbstractMemberDeclaration(session, psi, name, visibility, Modality.FINAL), FirTypeAlias {
|
) : FirAbstractMemberDeclaration(session, psi, name, visibility, Modality.FINAL), FirTypeAlias {
|
||||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
||||||
|
typeParameters.transformInplace(transformer, data)
|
||||||
expandedType = expandedType.transformSingle(transformer, data)
|
expandedType = expandedType.transformSingle(transformer, data)
|
||||||
|
|
||||||
return this
|
return this
|
||||||
|
|||||||
+17
-1
@@ -6,9 +6,13 @@
|
|||||||
package org.jetbrains.kotlin.fir.declarations.impl
|
package org.jetbrains.kotlin.fir.declarations.impl
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.transformInplace
|
||||||
import org.jetbrains.kotlin.fir.types.FirType
|
import org.jetbrains.kotlin.fir.types.FirType
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
@@ -16,7 +20,19 @@ class FirTypeParameterImpl(
|
|||||||
session: FirSession,
|
session: FirSession,
|
||||||
psi: PsiElement?,
|
psi: PsiElement?,
|
||||||
name: Name,
|
name: Name,
|
||||||
override val variance: Variance
|
override val variance: Variance,
|
||||||
|
override val isReified: Boolean,
|
||||||
|
override val symbol: FirTypeParameterSymbol
|
||||||
) : FirAbstractNamedAnnotatedDeclaration(session, psi, name), FirTypeParameter {
|
) : FirAbstractNamedAnnotatedDeclaration(session, psi, name), FirTypeParameter {
|
||||||
|
init {
|
||||||
|
symbol.bind(this)
|
||||||
|
}
|
||||||
|
|
||||||
override val bounds = mutableListOf<FirType>()
|
override val bounds = mutableListOf<FirType>()
|
||||||
|
|
||||||
|
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
||||||
|
bounds.transformInplace(transformer, data)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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.symbols
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
|
|
||||||
|
abstract class AbstractFirBasedSymbol<E> : FirBasedSymbol<E> where E : FirElement, E : FirSymbolOwner<E> {
|
||||||
|
|
||||||
|
override lateinit var fir: E
|
||||||
|
|
||||||
|
override fun bind(e: E) {
|
||||||
|
fir = e
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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.symbols
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
|
|
||||||
|
interface FirBasedSymbol<E> : ConeSymbol where E : FirElement, E : FirSymbolOwner<E> {
|
||||||
|
val fir: E
|
||||||
|
|
||||||
|
fun bind(e: E)
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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.symbols
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
|
|
||||||
|
interface FirSymbolOwner<E> where E : FirElement, E : FirSymbolOwner<E> {
|
||||||
|
val symbol: FirBasedSymbol<E>
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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.symbols.impl
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterSymbol
|
||||||
|
|
||||||
|
class FirTypeParameterSymbol : AbstractFirBasedSymbol<FirTypeParameter>(), ConeTypeParameterSymbol
|
||||||
@@ -15,4 +15,4 @@ interface FirResolvedType : FirTypeWithNullability {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified T : ConeKotlinType> FirType.coneTypeUnsafe() = (this as FirResolvedType).type as T
|
inline fun <reified T : ConeKotlinType> FirType.coneTypeUnsafe() = (this as FirResolvedType).type as T
|
||||||
inline fun <reified T : ConeKotlinType> FirType.coneTypeSafe() = (this as FirResolvedType).type as? T
|
inline fun <reified T : ConeKotlinType> FirType.coneTypeSafe() = (this as? FirResolvedType)?.type as? T
|
||||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.types.impl
|
|||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.toSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||||
import org.jetbrains.kotlin.fir.types.FirResolvedType
|
import org.jetbrains.kotlin.fir.types.FirResolvedType
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
@@ -23,7 +24,8 @@ sealed class FirBuiltinType(
|
|||||||
ClassId(
|
ClassId(
|
||||||
KOTLIN_PACKAGE_FQ_NAME,
|
KOTLIN_PACKAGE_FQ_NAME,
|
||||||
Name.identifier(name)
|
Name.identifier(name)
|
||||||
), emptyList()
|
).toSymbol(),
|
||||||
|
emptyList()
|
||||||
)
|
)
|
||||||
|
|
||||||
final override val isNullable = false
|
final override val isNullable = false
|
||||||
|
|||||||
@@ -6,17 +6,29 @@
|
|||||||
package org.jetbrains.kotlin.fir.types.impl
|
package org.jetbrains.kotlin.fir.types.impl
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||||
|
import org.jetbrains.kotlin.fir.transformInplace
|
||||||
|
import org.jetbrains.kotlin.fir.transformSingle
|
||||||
import org.jetbrains.kotlin.fir.types.FirFunctionType
|
import org.jetbrains.kotlin.fir.types.FirFunctionType
|
||||||
import org.jetbrains.kotlin.fir.types.FirType
|
import org.jetbrains.kotlin.fir.types.FirType
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||||
|
|
||||||
class FirFunctionTypeImpl(
|
class FirFunctionTypeImpl(
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
psi: PsiElement?,
|
psi: PsiElement?,
|
||||||
isNullable: Boolean,
|
isNullable: Boolean,
|
||||||
override val receiverType: FirType?,
|
override var receiverType: FirType?,
|
||||||
override val returnType: FirType
|
override var returnType: FirType
|
||||||
) : FirAbstractAnnotatedType(session, psi, isNullable), FirFunctionType {
|
) : FirAbstractAnnotatedType(session, psi, isNullable), FirFunctionType {
|
||||||
override val valueParameters = mutableListOf<FirValueParameter>()
|
override val valueParameters = mutableListOf<FirValueParameter>()
|
||||||
|
|
||||||
|
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
||||||
|
receiverType = receiverType?.transformSingle(transformer, data)
|
||||||
|
returnType = returnType.transformSingle(transformer, data)
|
||||||
|
valueParameters.transformInplace(transformer, data)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+11
-2
@@ -6,14 +6,23 @@
|
|||||||
package org.jetbrains.kotlin.fir.types.impl
|
package org.jetbrains.kotlin.fir.types.impl
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
|
import org.jetbrains.kotlin.fir.transformSingle
|
||||||
import org.jetbrains.kotlin.fir.types.FirType
|
import org.jetbrains.kotlin.fir.types.FirType
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeProjectionWithVariance
|
import org.jetbrains.kotlin.fir.types.FirTypeProjectionWithVariance
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
class FirTypeProjectionWithVarianceImpl(
|
class FirTypeProjectionWithVarianceImpl(
|
||||||
override val session: FirSession,
|
override val session: FirSession,
|
||||||
override val psi: PsiElement?,
|
override val psi: PsiElement?,
|
||||||
override val variance: Variance,
|
override val variance: Variance,
|
||||||
override val type: FirType
|
override var type: FirType
|
||||||
) : FirTypeProjectionWithVariance
|
) : FirTypeProjectionWithVariance {
|
||||||
|
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
||||||
|
type = type.transformSingle(transformer, data)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,14 @@
|
|||||||
package org.jetbrains.kotlin.fir.types.impl
|
package org.jetbrains.kotlin.fir.types.impl
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
|
import org.jetbrains.kotlin.fir.transformInplace
|
||||||
import org.jetbrains.kotlin.fir.types.FirQualifierPart
|
import org.jetbrains.kotlin.fir.types.FirQualifierPart
|
||||||
|
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
||||||
import org.jetbrains.kotlin.fir.types.FirUserType
|
import org.jetbrains.kotlin.fir.types.FirUserType
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||||
|
import org.jetbrains.kotlin.types.TypeProjectionBase
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class FirUserTypeImpl(
|
class FirUserTypeImpl(
|
||||||
@@ -17,4 +22,12 @@ class FirUserTypeImpl(
|
|||||||
isNullable: Boolean
|
isNullable: Boolean
|
||||||
) : FirAbstractAnnotatedType(session, psi, isNullable), FirUserType {
|
) : FirAbstractAnnotatedType(session, psi, isNullable), FirUserType {
|
||||||
override val qualifier = LinkedList<FirQualifierPart>()
|
override val qualifier = LinkedList<FirQualifierPart>()
|
||||||
|
|
||||||
|
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
||||||
|
for (part in qualifier) {
|
||||||
|
(part.typeArguments as MutableList<FirTypeProjection>).transformInplace(transformer, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+12
-4
@@ -82,6 +82,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
|||||||
return transformNamedDeclaration(typeParameter, data)
|
return transformNamedDeclaration(typeParameter, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun transformResolvedTypeParameter(resolvedTypeParameter: FirResolvedTypeParameter, data: D): CompositeTransformResult<FirDeclaration> {
|
||||||
|
return transformTypeParameter(resolvedTypeParameter, data)
|
||||||
|
}
|
||||||
|
|
||||||
open fun transformProperty(property: FirProperty, data: D): CompositeTransformResult<FirDeclaration> {
|
open fun transformProperty(property: FirProperty, data: D): CompositeTransformResult<FirDeclaration> {
|
||||||
return transformDeclaration(property, data)
|
return transformDeclaration(property, data)
|
||||||
}
|
}
|
||||||
@@ -246,6 +250,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
|||||||
return transformTypeAlias(typeAlias, data)
|
return transformTypeAlias(typeAlias, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override fun visitTypeParameter(typeParameter: FirTypeParameter, data: D): CompositeTransformResult<FirElement> {
|
||||||
|
return transformTypeParameter(typeParameter, data)
|
||||||
|
}
|
||||||
|
|
||||||
final override fun visitTypeProjection(typeProjection: FirTypeProjection, data: D): CompositeTransformResult<FirElement> {
|
final override fun visitTypeProjection(typeProjection: FirTypeProjection, data: D): CompositeTransformResult<FirElement> {
|
||||||
return transformTypeProjection(typeProjection, data)
|
return transformTypeProjection(typeProjection, data)
|
||||||
}
|
}
|
||||||
@@ -322,10 +330,6 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
|||||||
return transformResolvedImport(resolvedImport, data)
|
return transformResolvedImport(resolvedImport, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
final override fun visitTypeParameter(typeParameter: FirTypeParameter, data: D): CompositeTransformResult<FirElement> {
|
|
||||||
return transformTypeParameter(typeParameter, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
final override fun visitFile(file: FirFile, data: D): CompositeTransformResult<FirElement> {
|
final override fun visitFile(file: FirFile, data: D): CompositeTransformResult<FirElement> {
|
||||||
return transformFile(file, data)
|
return transformFile(file, data)
|
||||||
}
|
}
|
||||||
@@ -346,6 +350,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
|||||||
return transformResolvedTypeAlias(resolvedTypeAlias, data)
|
return transformResolvedTypeAlias(resolvedTypeAlias, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override fun visitResolvedTypeParameter(resolvedTypeParameter: FirResolvedTypeParameter, data: D): CompositeTransformResult<FirElement> {
|
||||||
|
return transformResolvedTypeParameter(resolvedTypeParameter, data)
|
||||||
|
}
|
||||||
|
|
||||||
final override fun visitStarProjection(starProjection: FirStarProjection, data: D): CompositeTransformResult<FirElement> {
|
final override fun visitStarProjection(starProjection: FirStarProjection, data: D): CompositeTransformResult<FirElement> {
|
||||||
return transformStarProjection(starProjection, data)
|
return transformStarProjection(starProjection, data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ abstract class FirVisitor<out R, in D> {
|
|||||||
return visitNamedDeclaration(typeParameter, data)
|
return visitNamedDeclaration(typeParameter, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun visitResolvedTypeParameter(resolvedTypeParameter: FirResolvedTypeParameter, data: D): R {
|
||||||
|
return visitTypeParameter(resolvedTypeParameter, data)
|
||||||
|
}
|
||||||
|
|
||||||
open fun visitProperty(property: FirProperty, data: D): R {
|
open fun visitProperty(property: FirProperty, data: D): R {
|
||||||
return visitDeclaration(property, data)
|
return visitDeclaration(property, data)
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-4
@@ -82,6 +82,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
|||||||
visitNamedDeclaration(typeParameter, null)
|
visitNamedDeclaration(typeParameter, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun visitResolvedTypeParameter(resolvedTypeParameter: FirResolvedTypeParameter) {
|
||||||
|
visitTypeParameter(resolvedTypeParameter, null)
|
||||||
|
}
|
||||||
|
|
||||||
open fun visitProperty(property: FirProperty) {
|
open fun visitProperty(property: FirProperty) {
|
||||||
visitDeclaration(property, null)
|
visitDeclaration(property, null)
|
||||||
}
|
}
|
||||||
@@ -246,6 +250,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
|||||||
visitTypeAlias(typeAlias)
|
visitTypeAlias(typeAlias)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override fun visitTypeParameter(typeParameter: FirTypeParameter, data: Nothing?) {
|
||||||
|
visitTypeParameter(typeParameter)
|
||||||
|
}
|
||||||
|
|
||||||
final override fun visitTypeProjection(typeProjection: FirTypeProjection, data: Nothing?) {
|
final override fun visitTypeProjection(typeProjection: FirTypeProjection, data: Nothing?) {
|
||||||
visitTypeProjection(typeProjection)
|
visitTypeProjection(typeProjection)
|
||||||
}
|
}
|
||||||
@@ -322,10 +330,6 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
|||||||
visitResolvedImport(resolvedImport)
|
visitResolvedImport(resolvedImport)
|
||||||
}
|
}
|
||||||
|
|
||||||
final override fun visitTypeParameter(typeParameter: FirTypeParameter, data: Nothing?) {
|
|
||||||
visitTypeParameter(typeParameter)
|
|
||||||
}
|
|
||||||
|
|
||||||
final override fun visitFile(file: FirFile, data: Nothing?) {
|
final override fun visitFile(file: FirFile, data: Nothing?) {
|
||||||
visitFile(file)
|
visitFile(file)
|
||||||
}
|
}
|
||||||
@@ -346,6 +350,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
|||||||
visitResolvedTypeAlias(resolvedTypeAlias)
|
visitResolvedTypeAlias(resolvedTypeAlias)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override fun visitResolvedTypeParameter(resolvedTypeParameter: FirResolvedTypeParameter, data: Nothing?) {
|
||||||
|
visitResolvedTypeParameter(resolvedTypeParameter)
|
||||||
|
}
|
||||||
|
|
||||||
final override fun visitStarProjection(starProjection: FirStarProjection, data: Nothing?) {
|
final override fun visitStarProjection(starProjection: FirStarProjection, data: Nothing?) {
|
||||||
visitStarProjection(starProjection)
|
visitStarProjection(starProjection)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
FILE: genericFunctions.kt
|
FILE: genericFunctions.kt
|
||||||
public? final? interface Any() {
|
public? final? interface Any() {
|
||||||
}
|
}
|
||||||
<T : Any> public? final? inline function safeAsAny.(): T? {
|
<reified T : Any> public? final? inline function safeAsAny.(): T? {
|
||||||
STUB
|
STUB
|
||||||
}
|
}
|
||||||
public? abstract class Summator() {
|
public? abstract class Summator() {
|
||||||
|
|||||||
@@ -22,6 +22,6 @@ FILE: simpleClass.kt
|
|||||||
|
|
||||||
public? final? property fau(var): Double
|
public? final? property fau(var): Double
|
||||||
public? get(): Double
|
public? get(): Double
|
||||||
public? set(value: Double): R/kotlin.Unit/
|
public? set(value: Double): R/kotlin/Unit/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ FILE: typeAliasWithGeneric.kt
|
|||||||
}
|
}
|
||||||
<S, T : A> public? final? interface B() {
|
<S, T : A> public? final? interface B() {
|
||||||
}
|
}
|
||||||
public? final typealias C = B<T, A>
|
<T> public? final typealias C = B<T, A>
|
||||||
public? final? class D() : C<A> {
|
public? final? class D() : C<A> {
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
FILE: F.kt
|
FILE: F.kt
|
||||||
(resolved) public? open class A() {
|
(resolved) public? open class A() {
|
||||||
}
|
}
|
||||||
(resolved) public? final class B() : R/<root>.A/ {
|
(resolved) public? final class B() : R/A/ {
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -4,9 +4,9 @@ FILE: NestedOfAliasedType.kt
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
(resolved) public? final typealias TA = R/<root>.A/
|
(resolved) public? final typealias TA = R/A/
|
||||||
(resolved) public? final class B() : R/<root>.TA = <root>.A/ {
|
(resolved) public? final class B() : R/TA = A/ {
|
||||||
(resolved) public? final class NestedInB() : R/<root>.A.Nested/ {
|
(resolved) public? final class NestedInB() : R/A.Nested/ {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1,14 +1,14 @@
|
|||||||
FILE: NestedSuperType.kt
|
FILE: NestedSuperType.kt
|
||||||
(resolved) public? abstract class My() {
|
(resolved) public? abstract class My() {
|
||||||
(resolved) public? abstract class NestedOne() : R/p.My/ {
|
(resolved) public? abstract class NestedOne() : R/p/My/ {
|
||||||
(resolved) public? abstract class NestedTwo() : R/p.My.NestedOne/ {
|
(resolved) public? abstract class NestedTwo() : R/p/My.NestedOne/ {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
(resolved) public? final class Your() : R/p.My/ {
|
(resolved) public? final class Your() : R/p/My/ {
|
||||||
(resolved) public? final class NestedThree() : R/p.My.NestedOne/ {
|
(resolved) public? final class NestedThree() : R/p/My.NestedOne/ {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
FILE: TwoDeclarationsInSameFile.kt
|
FILE: TwoDeclarationsInSameFile.kt
|
||||||
(resolved) public? open class A() {
|
(resolved) public? open class A() {
|
||||||
}
|
}
|
||||||
(resolved) public? final class B() : R/p.A/ {
|
(resolved) public? final class B() : R/p/A/ {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
FILE: NestedSuperType.kt
|
FILE: NestedSuperType.kt
|
||||||
(resolved) public? final class A() : R/b.B/ {
|
(resolved) public? final class A() : R/b/B/ {
|
||||||
(resolved) public? final class NestedInA1() : R/b.B.NestedInB/ {
|
(resolved) public? final class NestedInA1() : R/b/B.NestedInB/ {
|
||||||
}
|
}
|
||||||
|
|
||||||
(resolved) public? final class NestedInA2() : R/c.C.NestedInC/ {
|
(resolved) public? final class NestedInA2() : R/c/C.NestedInC/ {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
FILE: simpleAliasedImport.kt
|
FILE: simpleAliasedImport.kt
|
||||||
(resolved) public? final class YourClass() : R/b.MyClass/ {
|
(resolved) public? final class YourClass() : R/b/MyClass/ {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
FILE: simpleImport.kt
|
FILE: simpleImport.kt
|
||||||
(resolved) public? final class YourClass() : R/b.MyClass/ {
|
(resolved) public? final class YourClass() : R/b/MyClass/ {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
FILE: simpleImportNested.kt
|
FILE: simpleImportNested.kt
|
||||||
(resolved) public? final class YourClass() : R/a.MyClass.MyNested/ {
|
(resolved) public? final class YourClass() : R/a/MyClass.MyNested/ {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
FILE: simpleImportOuter.kt
|
FILE: simpleImportOuter.kt
|
||||||
(resolved) public? final class My() : R/a.Outer.Nested/ {
|
(resolved) public? final class My() : R/a/Outer.Nested/ {
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@ FILE: simpleClass.kt
|
|||||||
public? get(): R/error: Failed to resolve qualified type/
|
public? get(): R/error: Failed to resolve qualified type/
|
||||||
|
|
||||||
}
|
}
|
||||||
(resolved) public? final class SomeClass() : R/<root>.SomeInterface/ {
|
(resolved) public? final class SomeClass() : R/SomeInterface/ {
|
||||||
private final? property baz(val): R/error: Not supported: FirImplicitTypeImpl/ = STUB
|
private final? property baz(val): R/error: Not supported: FirImplicitTypeImpl/ = STUB
|
||||||
public? get(): R/error: Not supported: FirImplicitTypeImpl/
|
public? get(): R/error: Not supported: FirImplicitTypeImpl/
|
||||||
|
|
||||||
@@ -22,6 +22,6 @@ FILE: simpleClass.kt
|
|||||||
|
|
||||||
public? final? property fau(var): R/error: Failed to resolve qualified type/
|
public? final? property fau(var): R/error: Failed to resolve qualified type/
|
||||||
public? get(): R/error: Failed to resolve qualified type/
|
public? get(): R/error: Failed to resolve qualified type/
|
||||||
public? set(value: R/error: Failed to resolve qualified type/): R/kotlin.Unit/
|
public? set(value: R/error: Failed to resolve qualified type/): R/kotlin/Unit/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
FILE: simpleTypeAlias.kt
|
FILE: simpleTypeAlias.kt
|
||||||
(resolved) public? abstract interface B() {
|
(resolved) public? abstract interface B() {
|
||||||
}
|
}
|
||||||
(resolved) public? final typealias C = R/<root>.B/
|
(resolved) public? final typealias C = R/B/
|
||||||
(resolved) public? final class D() : R/<root>.C = <root>.B/ {
|
(resolved) public? final class D() : R/C = B/ {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
open class A
|
||||||
|
|
||||||
|
interface B<S, T : A>
|
||||||
|
|
||||||
|
typealias C<T> = B<T, A>
|
||||||
|
|
||||||
|
class D : C<A>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
FILE: typeAliasWithGeneric.kt
|
||||||
|
(resolved) public? open class A() {
|
||||||
|
}
|
||||||
|
(resolved) <(resolved) S, (resolved) T : R/A/> public? abstract interface B() {
|
||||||
|
}
|
||||||
|
(resolved) <(resolved) T> public? final typealias C = R/B<T, A>/
|
||||||
|
(resolved) public? final class D() : R/C<A> = B<T, A>/ {
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
interface Some
|
||||||
|
|
||||||
|
abstract class My<T : Some> {
|
||||||
|
inner class T
|
||||||
|
|
||||||
|
abstract val x: T
|
||||||
|
|
||||||
|
abstract fun foo(arg: T)
|
||||||
|
|
||||||
|
abstract val y: My.T
|
||||||
|
|
||||||
|
abstract val z: test.My.T
|
||||||
|
|
||||||
|
class Some : T()
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
FILE: typeParameterVsNested.kt
|
||||||
|
(resolved) public? abstract interface Some() {
|
||||||
|
}
|
||||||
|
(resolved) <(resolved) T : R/test/Some/> public? abstract class My() {
|
||||||
|
(resolved) public? final class T(inner) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public? abstract property x(val): R/T/
|
||||||
|
public? get(): R/T/
|
||||||
|
|
||||||
|
public? abstract function foo(arg: R/T/): R/error: Not supported: FirImplicitTypeImpl/
|
||||||
|
|
||||||
|
public? abstract property y(val): R/test/My.T/
|
||||||
|
public? get(): R/test/My.T/
|
||||||
|
|
||||||
|
public? abstract property z(val): R/test/My.T/
|
||||||
|
public? get(): R/test/My.T/
|
||||||
|
|
||||||
|
(resolved) public? final class Some() : R/T/ {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -61,6 +61,18 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeAliasWithGeneric.kt")
|
||||||
|
public void testTypeAliasWithGeneric() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/fir/resolve/typeAliasWithGeneric.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeParameterVsNested.kt")
|
||||||
|
public void testTypeParameterVsNested() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/fir/resolve/typeParameterVsNested.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/fir/resolve/multifile")
|
@TestMetadata("compiler/testData/fir/resolve/multifile")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user