[FIR] Fix warnings in FIR modules and enable -Werror in them
This commit is contained in:
committed by
TeamCityServer
parent
0e31551797
commit
0c4bca4bde
@@ -327,10 +327,6 @@ extra["tasksWithWarnings"] = listOf(
|
|||||||
":kotlin-stdlib-jdk8:compileTestKotlin",
|
":kotlin-stdlib-jdk8:compileTestKotlin",
|
||||||
":compiler:cli:compileKotlin",
|
":compiler:cli:compileKotlin",
|
||||||
":compiler:frontend:compileKotlin",
|
":compiler:frontend:compileKotlin",
|
||||||
":compiler:fir:tree:compileKotlin",
|
|
||||||
":compiler:fir:resolve:compileKotlin",
|
|
||||||
":compiler:fir:checkers:compileKotlin",
|
|
||||||
":compiler:fir:java:compileKotlin",
|
|
||||||
":kotlin-scripting-compiler:compileKotlin",
|
":kotlin-scripting-compiler:compileKotlin",
|
||||||
":plugins:uast-kotlin:compileKotlin",
|
":plugins:uast-kotlin:compileKotlin",
|
||||||
":plugins:uast-kotlin:compileTestKotlin",
|
":plugins:uast-kotlin:compileTestKotlin",
|
||||||
|
|||||||
+5
@@ -19,11 +19,14 @@ class FirControlFlowAnalyzer(session: FirSession) {
|
|||||||
private val cfaCheckers = session.checkersComponent.declarationCheckers.controlFlowAnalyserCheckers
|
private val cfaCheckers = session.checkersComponent.declarationCheckers.controlFlowAnalyserCheckers
|
||||||
private val variableAssignmentCheckers = session.checkersComponent.declarationCheckers.variableAssignmentCfaBasedCheckers
|
private val variableAssignmentCheckers = session.checkersComponent.declarationCheckers.variableAssignmentCfaBasedCheckers
|
||||||
|
|
||||||
|
// Currently declaration in analyzeXXX is not used, but it may be useful in future
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
fun analyzeClassInitializer(klass: FirClass<*>, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) {
|
fun analyzeClassInitializer(klass: FirClass<*>, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
if (graph.owner != null) return
|
if (graph.owner != null) return
|
||||||
cfaCheckers.forEach { it.analyze(graph, reporter, context) }
|
cfaCheckers.forEach { it.analyze(graph, reporter, context) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
fun analyzeFunction(function: FirFunction<*>, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) {
|
fun analyzeFunction(function: FirFunction<*>, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
if (graph.owner != null) return
|
if (graph.owner != null) return
|
||||||
|
|
||||||
@@ -32,6 +35,7 @@ class FirControlFlowAnalyzer(session: FirSession) {
|
|||||||
runAssignmentCfaCheckers(graph, reporter, context)
|
runAssignmentCfaCheckers(graph, reporter, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
fun analyzePropertyInitializer(property: FirProperty, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) {
|
fun analyzePropertyInitializer(property: FirProperty, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
if (graph.owner != null) return
|
if (graph.owner != null) return
|
||||||
|
|
||||||
@@ -39,6 +43,7 @@ class FirControlFlowAnalyzer(session: FirSession) {
|
|||||||
runAssignmentCfaCheckers(graph, reporter, context)
|
runAssignmentCfaCheckers(graph, reporter, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
fun analyzePropertyAccessor(
|
fun analyzePropertyAccessor(
|
||||||
accessor: FirPropertyAccessor,
|
accessor: FirPropertyAccessor,
|
||||||
graph: ControlFlowGraph,
|
graph: ControlFlowGraph,
|
||||||
|
|||||||
+1
@@ -242,6 +242,7 @@ object FirOverrideChecker : FirRegularClassChecker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER") // TODO: delete me after implementing body
|
||||||
private fun DiagnosticReporter.reportNothingToOverride(declaration: FirMemberDeclaration, context: CheckerContext) {
|
private fun DiagnosticReporter.reportNothingToOverride(declaration: FirMemberDeclaration, context: CheckerContext) {
|
||||||
// TODO: not ready yet, e.g., Collections
|
// TODO: not ready yet, e.g., Collections
|
||||||
// reportOn(declaration.source, FirErrors.NOTHING_TO_OVERRIDE, declaration, context)
|
// reportOn(declaration.source, FirErrors.NOTHING_TO_OVERRIDE, declaration, context)
|
||||||
|
|||||||
+11
-14
@@ -11,8 +11,6 @@ import org.jetbrains.kotlin.fir.FirSession
|
|||||||
import org.jetbrains.kotlin.fir.deserialization.AbstractAnnotationDeserializer
|
import org.jetbrains.kotlin.fir.deserialization.AbstractAnnotationDeserializer
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.builder.buildAnnotationCall
|
import org.jetbrains.kotlin.fir.expressions.builder.buildAnnotationCall
|
||||||
import org.jetbrains.kotlin.fir.resolve.symbolProvider
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirCompositeSymbolProvider
|
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
|
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
|
||||||
import org.jetbrains.kotlin.load.kotlin.MemberSignature
|
import org.jetbrains.kotlin.load.kotlin.MemberSignature
|
||||||
@@ -52,7 +50,7 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
typeTable: TypeTable
|
typeTable: TypeTable
|
||||||
): List<FirAnnotationCall> {
|
): List<FirAnnotationCall> {
|
||||||
val signature = getCallableSignature(constructorProto, nameResolver, typeTable) ?: return emptyList()
|
val signature = getCallableSignature(constructorProto, nameResolver, typeTable) ?: return emptyList()
|
||||||
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature)
|
return findJvmBinaryClassAndLoadMemberAnnotations(signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadFunctionAnnotations(
|
override fun loadFunctionAnnotations(
|
||||||
@@ -62,7 +60,7 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
typeTable: TypeTable
|
typeTable: TypeTable
|
||||||
): List<FirAnnotationCall> {
|
): List<FirAnnotationCall> {
|
||||||
val signature = getCallableSignature(functionProto, nameResolver, typeTable) ?: return emptyList()
|
val signature = getCallableSignature(functionProto, nameResolver, typeTable) ?: return emptyList()
|
||||||
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature)
|
return findJvmBinaryClassAndLoadMemberAnnotations(signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadPropertyAnnotations(
|
override fun loadPropertyAnnotations(
|
||||||
@@ -72,7 +70,7 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
typeTable: TypeTable
|
typeTable: TypeTable
|
||||||
): List<FirAnnotationCall> {
|
): List<FirAnnotationCall> {
|
||||||
val signature = getPropertySignature(propertyProto, nameResolver, typeTable, synthetic = true) ?: return emptyList()
|
val signature = getPropertySignature(propertyProto, nameResolver, typeTable, synthetic = true) ?: return emptyList()
|
||||||
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature).map {
|
return findJvmBinaryClassAndLoadMemberAnnotations(signature).map {
|
||||||
buildAnnotationCall {
|
buildAnnotationCall {
|
||||||
annotationTypeRef = it.annotationTypeRef
|
annotationTypeRef = it.annotationTypeRef
|
||||||
argumentList = it.argumentList
|
argumentList = it.argumentList
|
||||||
@@ -95,7 +93,7 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
if (signature.isDelegated) {
|
if (signature.isDelegated) {
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature).map {
|
return findJvmBinaryClassAndLoadMemberAnnotations(signature).map {
|
||||||
buildAnnotationCall {
|
buildAnnotationCall {
|
||||||
annotationTypeRef = it.annotationTypeRef
|
annotationTypeRef = it.annotationTypeRef
|
||||||
argumentList = it.argumentList
|
argumentList = it.argumentList
|
||||||
@@ -115,7 +113,7 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
if (!signature.isDelegated) {
|
if (!signature.isDelegated) {
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature).map {
|
return findJvmBinaryClassAndLoadMemberAnnotations(signature).map {
|
||||||
buildAnnotationCall {
|
buildAnnotationCall {
|
||||||
annotationTypeRef = it.annotationTypeRef
|
annotationTypeRef = it.annotationTypeRef
|
||||||
argumentList = it.argumentList
|
argumentList = it.argumentList
|
||||||
@@ -133,7 +131,7 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
getterFlags: Int
|
getterFlags: Int
|
||||||
): List<FirAnnotationCall> {
|
): List<FirAnnotationCall> {
|
||||||
val signature = getCallableSignature(propertyProto, nameResolver, typeTable, CallableKind.PROPERTY_GETTER) ?: return emptyList()
|
val signature = getCallableSignature(propertyProto, nameResolver, typeTable, CallableKind.PROPERTY_GETTER) ?: return emptyList()
|
||||||
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature)
|
return findJvmBinaryClassAndLoadMemberAnnotations(signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadPropertySetterAnnotations(
|
override fun loadPropertySetterAnnotations(
|
||||||
@@ -144,7 +142,7 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
setterFlags: Int
|
setterFlags: Int
|
||||||
): List<FirAnnotationCall> {
|
): List<FirAnnotationCall> {
|
||||||
val signature = getCallableSignature(propertyProto, nameResolver, typeTable, CallableKind.PROPERTY_SETTER) ?: return emptyList()
|
val signature = getCallableSignature(propertyProto, nameResolver, typeTable, CallableKind.PROPERTY_SETTER) ?: return emptyList()
|
||||||
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature)
|
return findJvmBinaryClassAndLoadMemberAnnotations(signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadValueParameterAnnotations(
|
override fun loadValueParameterAnnotations(
|
||||||
@@ -160,7 +158,7 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
val methodSignature = getCallableSignature(callableProto, nameResolver, typeTable, kind) ?: return emptyList()
|
val methodSignature = getCallableSignature(callableProto, nameResolver, typeTable, kind) ?: return emptyList()
|
||||||
val index = parameterIndex + computeJvmParameterIndexShift(classProto, callableProto)
|
val index = parameterIndex + computeJvmParameterIndexShift(classProto, callableProto)
|
||||||
val paramSignature = MemberSignature.fromMethodSignatureAndParameterIndex(methodSignature, index)
|
val paramSignature = MemberSignature.fromMethodSignatureAndParameterIndex(methodSignature, index)
|
||||||
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, paramSignature)
|
return findJvmBinaryClassAndLoadMemberAnnotations(paramSignature)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadExtensionReceiverParameterAnnotations(
|
override fun loadExtensionReceiverParameterAnnotations(
|
||||||
@@ -172,7 +170,7 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
): List<FirAnnotationCall> {
|
): List<FirAnnotationCall> {
|
||||||
val methodSignature = getCallableSignature(callableProto, nameResolver, typeTable, kind) ?: return emptyList()
|
val methodSignature = getCallableSignature(callableProto, nameResolver, typeTable, kind) ?: return emptyList()
|
||||||
val paramSignature = MemberSignature.fromMethodSignatureAndParameterIndex(methodSignature, 0)
|
val paramSignature = MemberSignature.fromMethodSignatureAndParameterIndex(methodSignature, 0)
|
||||||
return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, paramSignature)
|
return findJvmBinaryClassAndLoadMemberAnnotations(paramSignature)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun computeJvmParameterIndexShift(classProto: ProtoBuf.Class?, message: MessageLite): Int {
|
private fun computeJvmParameterIndexShift(classProto: ProtoBuf.Class?, message: MessageLite): Int {
|
||||||
@@ -255,7 +253,6 @@ class JvmBinaryAnnotationDeserializer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun findJvmBinaryClassAndLoadMemberAnnotations(
|
private fun findJvmBinaryClassAndLoadMemberAnnotations(
|
||||||
containerSource: DeserializedContainerSource?,
|
|
||||||
memberSignature: MemberSignature
|
memberSignature: MemberSignature
|
||||||
): List<FirAnnotationCall> {
|
): List<FirAnnotationCall> {
|
||||||
return annotationInfo.memberAnnotations[memberSignature] ?: emptyList()
|
return annotationInfo.memberAnnotations[memberSignature] ?: emptyList()
|
||||||
@@ -271,11 +268,11 @@ private fun FirSession.loadMemberAnnotations(kotlinBinaryClass: KotlinJvmBinaryC
|
|||||||
val annotationsLoader = AnnotationsLoader(this)
|
val annotationsLoader = AnnotationsLoader(this)
|
||||||
|
|
||||||
kotlinBinaryClass.visitMembers(object : KotlinJvmBinaryClass.MemberVisitor {
|
kotlinBinaryClass.visitMembers(object : KotlinJvmBinaryClass.MemberVisitor {
|
||||||
override fun visitMethod(name: Name, desc: String): KotlinJvmBinaryClass.MethodAnnotationVisitor? {
|
override fun visitMethod(name: Name, desc: String): KotlinJvmBinaryClass.MethodAnnotationVisitor {
|
||||||
return AnnotationVisitorForMethod(MemberSignature.fromMethodNameAndDesc(name.asString(), desc))
|
return AnnotationVisitorForMethod(MemberSignature.fromMethodNameAndDesc(name.asString(), desc))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitField(name: Name, desc: String, initializer: Any?): KotlinJvmBinaryClass.AnnotationVisitor? {
|
override fun visitField(name: Name, desc: String, initializer: Any?): KotlinJvmBinaryClass.AnnotationVisitor {
|
||||||
val signature = MemberSignature.fromFieldNameAndDesc(name.asString(), desc)
|
val signature = MemberSignature.fromFieldNameAndDesc(name.asString(), desc)
|
||||||
if (initializer != null) {
|
if (initializer != null) {
|
||||||
// TODO: load constant
|
// TODO: load constant
|
||||||
|
|||||||
+4
-28
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.resolve.calls
|
package org.jetbrains.kotlin.fir.resolve.calls
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRefsOwner
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRefsOwner
|
||||||
import org.jetbrains.kotlin.fir.renderWithType
|
import org.jetbrains.kotlin.fir.renderWithType
|
||||||
@@ -15,8 +14,8 @@ import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents
|
|||||||
import org.jetbrains.kotlin.fir.resolve.inference.model.ConeDeclaredUpperBoundConstraintPosition
|
import org.jetbrains.kotlin.fir.resolve.inference.model.ConeDeclaredUpperBoundConstraintPosition
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
|
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
||||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||||
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.FirTypePlaceholderProjection
|
import org.jetbrains.kotlin.fir.types.impl.FirTypePlaceholderProjection
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation
|
||||||
@@ -32,7 +31,7 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() {
|
|||||||
}
|
}
|
||||||
val csBuilder = candidate.system.getBuilder()
|
val csBuilder = candidate.system.getBuilder()
|
||||||
val (substitutor, freshVariables) =
|
val (substitutor, freshVariables) =
|
||||||
createToFreshVariableSubstitutorAndAddInitialConstraints(declaration, candidate, csBuilder, callInfo.session)
|
createToFreshVariableSubstitutorAndAddInitialConstraints(declaration, csBuilder)
|
||||||
candidate.substitutor = substitutor
|
candidate.substitutor = substitutor
|
||||||
candidate.freshVariables = freshVariables
|
candidate.freshVariables = freshVariables
|
||||||
|
|
||||||
@@ -102,7 +101,7 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() {
|
|||||||
return symbol.fir.bounds.any {
|
return symbol.fir.bounds.any {
|
||||||
val type = it.coneType
|
val type = it.coneType
|
||||||
type is ConeFlexibleType || with(context) {
|
type is ConeFlexibleType || with(context) {
|
||||||
(type.typeConstructor() as? FirTypeParameterSymbol)?.fir?.shouldBeFlexible(context) ?: false
|
(type.typeConstructor() as? ConeTypeParameterLookupTag)?.symbol?.fir?.shouldBeFlexible(context) ?: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,9 +110,7 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() {
|
|||||||
|
|
||||||
private fun createToFreshVariableSubstitutorAndAddInitialConstraints(
|
private fun createToFreshVariableSubstitutorAndAddInitialConstraints(
|
||||||
declaration: FirTypeParameterRefsOwner,
|
declaration: FirTypeParameterRefsOwner,
|
||||||
candidate: Candidate,
|
csBuilder: ConstraintSystemOperation
|
||||||
csBuilder: ConstraintSystemOperation,
|
|
||||||
session: FirSession
|
|
||||||
): Pair<ConeSubstitutor, List<ConeTypeVariable>> {
|
): Pair<ConeSubstitutor, List<ConeTypeVariable>> {
|
||||||
|
|
||||||
val typeParameters = declaration.typeParameters
|
val typeParameters = declaration.typeParameters
|
||||||
@@ -153,26 +150,5 @@ private fun createToFreshVariableSubstitutorAndAddInitialConstraints(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (candidateDescriptor is TypeAliasConstructorDescriptor) {
|
|
||||||
// val typeAliasDescriptor = candidateDescriptor.typeAliasDescriptor
|
|
||||||
// val originalTypes = typeAliasDescriptor.underlyingType.arguments.map { it.type }
|
|
||||||
// val originalTypeParameters = candidateDescriptor.underlyingConstructorDescriptor.typeParameters
|
|
||||||
// for (index in typeParameters.indices) {
|
|
||||||
// val typeParameter = typeParameters[index]
|
|
||||||
// val freshVariable = freshTypeVariables[index]
|
|
||||||
// val typeMapping = originalTypes.mapIndexedNotNull { i: Int, kotlinType: KotlinType ->
|
|
||||||
// if (kotlinType == typeParameter.defaultType) i else null
|
|
||||||
// }
|
|
||||||
// for (originalIndex in typeMapping) {
|
|
||||||
// // there can be null in case we already captured type parameter in outer class (in case of inner classes)
|
|
||||||
// // see test innerClassTypeAliasConstructor.kt
|
|
||||||
// val originalTypeParameter = originalTypeParameters.getOrNull(originalIndex) ?: continue
|
|
||||||
// val position = DeclaredUpperBoundConstraintPosition(originalTypeParameter)
|
|
||||||
// for (upperBound in originalTypeParameter.upperBounds) {
|
|
||||||
// freshVariable.addSubtypeConstraint(upperBound, position)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return toFreshVariables to freshTypeVariables
|
return toFreshVariables to freshTypeVariables
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -92,6 +92,7 @@ class FirBuilderInferenceSession(
|
|||||||
return !skipCall(call)
|
return !skipCall(call)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED_PARAMETER")
|
||||||
private fun <T> skipCall(call: T): Boolean where T : FirResolvable, T : FirStatement {
|
private fun <T> skipCall(call: T): Boolean where T : FirResolvable, T : FirStatement {
|
||||||
// TODO: what is FIR analog?
|
// TODO: what is FIR analog?
|
||||||
// if (descriptor is FakeCallableDescriptorForObject) return true
|
// if (descriptor is FakeCallableDescriptorForObject) return true
|
||||||
|
|||||||
+2
-9
@@ -198,15 +198,8 @@ fun ConeKotlinType.isKClassType(): Boolean {
|
|||||||
return classId == StandardClassIds.KClass
|
return classId == StandardClassIds.KClass
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ConeKotlinType.receiverType(expectedTypeRef: FirTypeRef?, session: FirSession): ConeKotlinType? {
|
|
||||||
if (isBuiltinFunctionalType(session) && isExtensionFunctionType(session)) {
|
|
||||||
return (this.fullyExpandedType(session).typeArguments.first() as ConeKotlinTypeProjection).type
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ConeKotlinType.receiverType(session: FirSession): ConeKotlinType? {
|
fun ConeKotlinType.receiverType(session: FirSession): ConeKotlinType? {
|
||||||
if (isBuiltinFunctionalType(session)) {
|
if (isBuiltinFunctionalType(session) && isExtensionFunctionType(session)) {
|
||||||
return (this.fullyExpandedType(session).typeArguments.first() as ConeKotlinTypeProjection).type
|
return (this.fullyExpandedType(session).typeArguments.first() as ConeKotlinTypeProjection).type
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
@@ -250,7 +243,7 @@ fun extractLambdaInfoFromFunctionalType(
|
|||||||
}
|
}
|
||||||
if (!expectedType.isBuiltinFunctionalType(session)) return null
|
if (!expectedType.isBuiltinFunctionalType(session)) return null
|
||||||
|
|
||||||
val receiverType = argument.receiverType ?: expectedType.receiverType(expectedTypeRef, session)
|
val receiverType = argument.receiverType ?: expectedType.receiverType(session)
|
||||||
val returnType = argument.returnType ?: expectedType.returnType(session) ?: return null
|
val returnType = argument.returnType ?: expectedType.returnType(session) ?: return null
|
||||||
val parameters = extractLambdaParameters(expectedType, argument, expectedType.isExtensionFunctionType(session), session)
|
val parameters = extractLambdaParameters(expectedType, argument, expectedType.isExtensionFunctionType(session), session)
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -112,9 +112,9 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
|||||||
|
|
||||||
if (property.isLocal) {
|
if (property.isLocal) {
|
||||||
prepareSignatureForBodyResolve(property)
|
prepareSignatureForBodyResolve(property)
|
||||||
property.transformStatus(this, property.resolveStatus(property.status).mode())
|
property.transformStatus(this, property.resolveStatus().mode())
|
||||||
property.getter?.let { it.transformStatus(this, it.resolveStatus(it.status).mode()) }
|
property.getter?.let { it.transformStatus(this, it.resolveStatus().mode()) }
|
||||||
property.setter?.let { it.transformStatus(this, it.resolveStatus(it.status).mode()) }
|
property.setter?.let { it.transformStatus(this, it.resolveStatus().mode()) }
|
||||||
return transformLocalVariable(property)
|
return transformLocalVariable(property)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FirDeclaration.resolveStatus(status: FirDeclarationStatus, containingClass: FirClass<*>? = null): FirDeclarationStatus {
|
private fun FirDeclaration.resolveStatus(containingClass: FirClass<*>? = null): FirDeclarationStatus {
|
||||||
val containingDeclaration = context.containerIfAny
|
val containingDeclaration = context.containerIfAny
|
||||||
return statusResolver.resolveStatus(
|
return statusResolver.resolveStatus(
|
||||||
this,
|
this,
|
||||||
@@ -528,7 +528,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
|||||||
if (containingDeclaration != null && containingDeclaration !is FirClass<*>) {
|
if (containingDeclaration != null && containingDeclaration !is FirClass<*>) {
|
||||||
// For class members everything should be already prepared
|
// For class members everything should be already prepared
|
||||||
prepareSignatureForBodyResolve(simpleFunction)
|
prepareSignatureForBodyResolve(simpleFunction)
|
||||||
simpleFunction.transformStatus(this, simpleFunction.resolveStatus(simpleFunction.status).mode())
|
simpleFunction.transformStatus(this, simpleFunction.resolveStatus().mode())
|
||||||
}
|
}
|
||||||
|
|
||||||
withFullBodyResolve {
|
withFullBodyResolve {
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ val compileKotlin by tasks
|
|||||||
|
|
||||||
compileKotlin.dependsOn(generateTree)
|
compileKotlin.dependsOn(generateTree)
|
||||||
|
|
||||||
|
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs += "-Xinline-classes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||||
apply(plugin = "idea")
|
apply(plugin = "idea")
|
||||||
idea {
|
idea {
|
||||||
|
|||||||
Reference in New Issue
Block a user