[FIR] Implement checker for missing dependency supertypes
#KT-60778 Fixed
This commit is contained in:
+8
@@ -423,6 +423,14 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
|||||||
token,
|
token,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
add(FirErrors.MISSING_DEPENDENCY_SUPERCLASS) { firDiagnostic ->
|
||||||
|
MissingDependencySuperclassImpl(
|
||||||
|
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
|
||||||
|
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.b),
|
||||||
|
firDiagnostic as KtPsiDiagnostic,
|
||||||
|
token,
|
||||||
|
)
|
||||||
|
}
|
||||||
add(FirErrors.CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS) { firDiagnostic ->
|
add(FirErrors.CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS) { firDiagnostic ->
|
||||||
CreatingAnInstanceOfAbstractClassImpl(
|
CreatingAnInstanceOfAbstractClassImpl(
|
||||||
firDiagnostic as KtPsiDiagnostic,
|
firDiagnostic as KtPsiDiagnostic,
|
||||||
|
|||||||
+6
@@ -343,6 +343,12 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
|||||||
val type: KtType
|
val type: KtType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface MissingDependencySuperclass : KtFirDiagnostic<PsiElement> {
|
||||||
|
override val diagnosticClass get() = MissingDependencySuperclass::class
|
||||||
|
val missingType: KtType
|
||||||
|
val declarationType: KtType
|
||||||
|
}
|
||||||
|
|
||||||
interface CreatingAnInstanceOfAbstractClass : KtFirDiagnostic<KtExpression> {
|
interface CreatingAnInstanceOfAbstractClass : KtFirDiagnostic<KtExpression> {
|
||||||
override val diagnosticClass get() = CreatingAnInstanceOfAbstractClass::class
|
override val diagnosticClass get() = CreatingAnInstanceOfAbstractClass::class
|
||||||
}
|
}
|
||||||
|
|||||||
+7
@@ -395,6 +395,13 @@ internal class MissingDependencyClassImpl(
|
|||||||
token: KtLifetimeToken,
|
token: KtLifetimeToken,
|
||||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.MissingDependencyClass
|
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.MissingDependencyClass
|
||||||
|
|
||||||
|
internal class MissingDependencySuperclassImpl(
|
||||||
|
override val missingType: KtType,
|
||||||
|
override val declarationType: KtType,
|
||||||
|
firDiagnostic: KtPsiDiagnostic,
|
||||||
|
token: KtLifetimeToken,
|
||||||
|
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.MissingDependencySuperclass
|
||||||
|
|
||||||
internal class CreatingAnInstanceOfAbstractClassImpl(
|
internal class CreatingAnInstanceOfAbstractClassImpl(
|
||||||
firDiagnostic: KtPsiDiagnostic,
|
firDiagnostic: KtPsiDiagnostic,
|
||||||
token: KtLifetimeToken,
|
token: KtLifetimeToken,
|
||||||
|
|||||||
+12
@@ -6,11 +6,13 @@
|
|||||||
package org.jetbrains.kotlin.analysis.test.framework.services.libraries
|
package org.jetbrains.kotlin.analysis.test.framework.services.libraries
|
||||||
|
|
||||||
import org.jetbrains.kotlin.analysis.test.framework.utils.SkipTestException
|
import org.jetbrains.kotlin.analysis.test.framework.utils.SkipTestException
|
||||||
|
import org.jetbrains.kotlin.config.JvmTarget
|
||||||
import org.jetbrains.kotlin.test.MockLibraryUtil
|
import org.jetbrains.kotlin.test.MockLibraryUtil
|
||||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
|
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
|
||||||
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
|
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
|
||||||
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||||
import org.jetbrains.kotlin.test.model.TestModule
|
import org.jetbrains.kotlin.test.model.TestModule
|
||||||
|
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.absolutePathString
|
import kotlin.io.path.absolutePathString
|
||||||
import kotlin.io.path.div
|
import kotlin.io.path.div
|
||||||
@@ -56,6 +58,16 @@ object CompilerExecutor {
|
|||||||
|
|
||||||
module.directives[JvmEnvironmentConfigurationDirectives.JVM_TARGET].firstOrNull()?.let { jvmTarget ->
|
module.directives[JvmEnvironmentConfigurationDirectives.JVM_TARGET].firstOrNull()?.let { jvmTarget ->
|
||||||
addAll(listOf("-jvm-target", jvmTarget.description))
|
addAll(listOf("-jvm-target", jvmTarget.description))
|
||||||
|
|
||||||
|
val jdkHome = when {
|
||||||
|
jvmTarget <= JvmTarget.JVM_1_8 -> KtTestUtil.getJdk8Home()
|
||||||
|
jvmTarget <= JvmTarget.JVM_11 -> KtTestUtil.getJdk11Home()
|
||||||
|
jvmTarget <= JvmTarget.JVM_17 -> KtTestUtil.getJdk17Home()
|
||||||
|
jvmTarget <= JvmTarget.JVM_21 -> KtTestUtil.getJdk21Home()
|
||||||
|
else -> error("JDK for $jvmTarget is not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
addAll(listOf("-jdk-home", jdkHome.toString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
addAll(module.directives[Directives.COMPILER_ARGUMENTS])
|
addAll(module.directives[Directives.COMPILER_ARGUMENTS])
|
||||||
|
|||||||
+4
@@ -183,6 +183,10 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
|
|||||||
val MISSING_DEPENDENCY_CLASS by error<PsiElement>(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED) {
|
val MISSING_DEPENDENCY_CLASS by error<PsiElement>(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED) {
|
||||||
parameter<ConeKotlinType>("type")
|
parameter<ConeKotlinType>("type")
|
||||||
}
|
}
|
||||||
|
val MISSING_DEPENDENCY_SUPERCLASS by error<PsiElement>(PositioningStrategy.REFERENCED_NAME_BY_QUALIFIED) {
|
||||||
|
parameter<ConeKotlinType>("missingType")
|
||||||
|
parameter<ConeKotlinType>("declarationType")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val CALL_RESOLUTION by object : DiagnosticGroup("Call resolution") {
|
val CALL_RESOLUTION by object : DiagnosticGroup("Call resolution") {
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ object FirErrors {
|
|||||||
val UNRESOLVED_IMPORT by error1<PsiElement, String>(SourceElementPositioningStrategies.IMPORT_LAST_NAME)
|
val UNRESOLVED_IMPORT by error1<PsiElement, String>(SourceElementPositioningStrategies.IMPORT_LAST_NAME)
|
||||||
val DUPLICATE_PARAMETER_NAME_IN_FUNCTION_TYPE by error0<KtTypeReference>()
|
val DUPLICATE_PARAMETER_NAME_IN_FUNCTION_TYPE by error0<KtTypeReference>()
|
||||||
val MISSING_DEPENDENCY_CLASS by error1<PsiElement, ConeKotlinType>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
|
val MISSING_DEPENDENCY_CLASS by error1<PsiElement, ConeKotlinType>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
|
||||||
|
val MISSING_DEPENDENCY_SUPERCLASS by error2<PsiElement, ConeKotlinType, ConeKotlinType>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
|
||||||
|
|
||||||
// Call resolution
|
// Call resolution
|
||||||
val CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS by error0<KtExpression>()
|
val CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS by error0<KtExpression>()
|
||||||
|
|||||||
+1
@@ -54,6 +54,7 @@ val FIR_NON_SUPPRESSIBLE_ERROR_NAMES: Set<String> = setOf(
|
|||||||
"UNRESOLVED_IMPORT",
|
"UNRESOLVED_IMPORT",
|
||||||
"DUPLICATE_PARAMETER_NAME_IN_FUNCTION_TYPE",
|
"DUPLICATE_PARAMETER_NAME_IN_FUNCTION_TYPE",
|
||||||
"MISSING_DEPENDENCY_CLASS",
|
"MISSING_DEPENDENCY_CLASS",
|
||||||
|
"MISSING_DEPENDENCY_SUPERCLASS",
|
||||||
"CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS",
|
"CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS",
|
||||||
"NO_CONSTRUCTOR",
|
"NO_CONSTRUCTOR",
|
||||||
"FUNCTION_CALL_EXPECTED",
|
"FUNCTION_CALL_EXPECTED",
|
||||||
|
|||||||
+2
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.analysis.checkers.declaration.*
|
|||||||
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirAnonymousFunctionParametersChecker
|
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirAnonymousFunctionParametersChecker
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirFiniteBoundRestrictionChecker
|
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirFiniteBoundRestrictionChecker
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirInlinedLambdaNonSourceAnnotationsChecker
|
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirInlinedLambdaNonSourceAnnotationsChecker
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirMissingDependencySupertypeChecker
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.syntax.*
|
import org.jetbrains.kotlin.fir.analysis.checkers.syntax.*
|
||||||
|
|
||||||
object CommonDeclarationCheckers : DeclarationCheckers() {
|
object CommonDeclarationCheckers : DeclarationCheckers() {
|
||||||
@@ -35,6 +36,7 @@ object CommonDeclarationCheckers : DeclarationCheckers() {
|
|||||||
FirOptInMarkedDeclarationChecker,
|
FirOptInMarkedDeclarationChecker,
|
||||||
FirExpectConsistencyChecker,
|
FirExpectConsistencyChecker,
|
||||||
FirOptionalExpectationDeclarationChecker,
|
FirOptionalExpectationDeclarationChecker,
|
||||||
|
FirMissingDependencySupertypeChecker.ForDeclarations,
|
||||||
)
|
)
|
||||||
|
|
||||||
override val classLikeCheckers: Set<FirClassLikeChecker>
|
override val classLikeCheckers: Set<FirClassLikeChecker>
|
||||||
|
|||||||
+2
-1
@@ -54,6 +54,8 @@ object CommonExpressionCheckers : ExpressionCheckers() {
|
|||||||
FirAbstractClassInstantiationChecker,
|
FirAbstractClassInstantiationChecker,
|
||||||
FirInlineBodyQualifiedAccessExpressionChecker,
|
FirInlineBodyQualifiedAccessExpressionChecker,
|
||||||
FirIncompatibleClassExpressionChecker,
|
FirIncompatibleClassExpressionChecker,
|
||||||
|
FirMissingDependencyClassChecker,
|
||||||
|
FirMissingDependencySupertypeChecker.ForQualifiedAccessExpressions,
|
||||||
)
|
)
|
||||||
|
|
||||||
override val callCheckers: Set<FirCallChecker>
|
override val callCheckers: Set<FirCallChecker>
|
||||||
@@ -69,7 +71,6 @@ object CommonExpressionCheckers : ExpressionCheckers() {
|
|||||||
FirSpreadOfNullableChecker,
|
FirSpreadOfNullableChecker,
|
||||||
FirAssignmentOperatorCallChecker,
|
FirAssignmentOperatorCallChecker,
|
||||||
FirNamedVarargChecker,
|
FirNamedVarargChecker,
|
||||||
FirMissingDependencyClassChecker,
|
|
||||||
FirUnderscoredTypeArgumentSyntaxChecker,
|
FirUnderscoredTypeArgumentSyntaxChecker,
|
||||||
FirContractNotFirstStatementChecker,
|
FirContractNotFirstStatementChecker,
|
||||||
FirProtectedConstructorNotInSuperCallChecker,
|
FirProtectedConstructorNotInSuperCallChecker,
|
||||||
|
|||||||
+30
-21
@@ -801,28 +801,37 @@ fun FirElement.isLhsOfAssignment(context: CheckerContext): Boolean {
|
|||||||
*/
|
*/
|
||||||
fun ConeKotlinType?.collectUpperBounds(): Set<ConeClassLikeType> {
|
fun ConeKotlinType?.collectUpperBounds(): Set<ConeClassLikeType> {
|
||||||
if (this == null) return emptySet()
|
if (this == null) return emptySet()
|
||||||
return when (this) {
|
|
||||||
is ConeErrorType -> emptySet() // Ignore error types
|
|
||||||
is ConeLookupTagBasedType -> when (this) {
|
|
||||||
is ConeClassLikeType -> setOf(this)
|
|
||||||
is ConeTypeVariableType -> {
|
|
||||||
(lookupTag.originalTypeParameter as? ConeTypeParameterLookupTag)?.typeParameterSymbol.collectUpperBounds()
|
|
||||||
}
|
|
||||||
is ConeTypeParameterType -> lookupTag.typeParameterSymbol.collectUpperBounds()
|
|
||||||
else -> throw IllegalStateException("missing branch for ${javaClass.name}")
|
|
||||||
}
|
|
||||||
is ConeDefinitelyNotNullType -> original.collectUpperBounds()
|
|
||||||
is ConeIntersectionType -> intersectedTypes.flatMap { it.collectUpperBounds() }.toSet()
|
|
||||||
is ConeFlexibleType -> upperBound.collectUpperBounds()
|
|
||||||
is ConeCapturedType -> constructor.supertypes?.flatMap { it.collectUpperBounds() }?.toSet().orEmpty()
|
|
||||||
is ConeIntegerConstantOperatorType -> setOf(getApproximatedType())
|
|
||||||
is ConeStubType, is ConeIntegerLiteralConstantType -> throw IllegalStateException("$this should not reach here")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun FirTypeParameterSymbol?.collectUpperBounds(): Set<ConeClassLikeType> {
|
val upperBounds = mutableSetOf<ConeClassLikeType>()
|
||||||
if (this == null) return emptySet()
|
val seen = mutableSetOf<ConeKotlinType>()
|
||||||
return resolvedBounds.flatMap { it.coneType.collectUpperBounds() }.toSet()
|
fun collect(type: ConeKotlinType) {
|
||||||
|
if (!seen.add(type)) return // Avoid infinite recursion.
|
||||||
|
|
||||||
|
when (type) {
|
||||||
|
is ConeErrorType -> return // Ignore error types
|
||||||
|
is ConeLookupTagBasedType -> when (type) {
|
||||||
|
is ConeClassLikeType -> upperBounds.add(type)
|
||||||
|
is ConeTypeVariableType -> {
|
||||||
|
val symbol = (type.lookupTag.originalTypeParameter as? ConeTypeParameterLookupTag)?.typeParameterSymbol ?: return
|
||||||
|
symbol.resolvedBounds.forEach { collect(it.coneType) }
|
||||||
|
}
|
||||||
|
is ConeTypeParameterType -> {
|
||||||
|
val symbol = type.lookupTag.typeParameterSymbol
|
||||||
|
symbol.resolvedBounds.forEach { collect(it.coneType) }
|
||||||
|
}
|
||||||
|
else -> throw IllegalStateException("missing branch for ${javaClass.name}")
|
||||||
|
}
|
||||||
|
is ConeDefinitelyNotNullType -> collect(type.original)
|
||||||
|
is ConeIntersectionType -> type.intersectedTypes.forEach(::collect)
|
||||||
|
is ConeFlexibleType -> collect(type.upperBound)
|
||||||
|
is ConeCapturedType -> type.constructor.supertypes?.forEach(::collect)
|
||||||
|
is ConeIntegerConstantOperatorType -> upperBounds.add(type.getApproximatedType())
|
||||||
|
is ConeStubType, is ConeIntegerLiteralConstantType -> throw IllegalStateException("$type should not reach here")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
collect(this)
|
||||||
|
return upperBounds
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ConeKotlinType.leastUpperBound(session: FirSession): ConeKotlinType {
|
fun ConeKotlinType.leastUpperBound(session: FirSession): ConeKotlinType {
|
||||||
|
|||||||
+21
-17
@@ -9,28 +9,26 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
|||||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||||
import org.jetbrains.kotlin.fir.references.isError
|
import org.jetbrains.kotlin.fir.references.isError
|
||||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeInapplicableCandidateError
|
import org.jetbrains.kotlin.fir.references.toResolvedCallableSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeDiagnosticWithSingleCandidate
|
||||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.jetbrains.kotlin.resolve.checkers.MissingDependencyClassChecker
|
* @see org.jetbrains.kotlin.resolve.checkers.MissingDependencyClassChecker
|
||||||
*/
|
*/
|
||||||
object FirMissingDependencyClassChecker : FirFunctionCallChecker() {
|
object FirMissingDependencyClassChecker : FirQualifiedAccessExpressionChecker() {
|
||||||
override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) {
|
override fun check(expression: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
val calleeReference = expression.calleeReference
|
val calleeReference = expression.calleeReference
|
||||||
if (calleeReference.isError()) {
|
|
||||||
// To replicate K1 behavior, MISSING_DEPENDENCY_CLASS errors should still be reported on unsafe calls.
|
|
||||||
// All other callee errors should skip reporting of MISSING_DEPENDENCY_CLASS.
|
|
||||||
val diagnostic = calleeReference.diagnostic
|
|
||||||
if (diagnostic !is ConeInapplicableCandidateError || diagnostic.applicability != CandidateApplicability.UNSAFE_CALL) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// To replicate K1 behavior, MISSING_DEPENDENCY_CLASS errors should still be reported on error references with a single candidate.
|
||||||
|
// All other callee errors should skip reporting of MISSING_DEPENDENCY_CLASS.
|
||||||
|
if (calleeReference.isError() && calleeReference.diagnostic !is ConeDiagnosticWithSingleCandidate) return
|
||||||
|
|
||||||
|
val missingTypes = mutableSetOf<ConeKotlinType>()
|
||||||
fun consider(type: ConeKotlinType) {
|
fun consider(type: ConeKotlinType) {
|
||||||
var hasError = false
|
var hasError = false
|
||||||
var hasMissingClass = false
|
var hasMissingClass = false
|
||||||
@@ -42,13 +40,19 @@ object FirMissingDependencyClassChecker : FirFunctionCallChecker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasMissingClass && !hasError) {
|
if (hasMissingClass && !hasError) {
|
||||||
reporter.reportOn(expression.source, FirErrors.MISSING_DEPENDENCY_CLASS, type, context)
|
val reportedType = type.withNullability(ConeNullability.NOT_NULL, context.session.typeContext).withArguments(emptyArray())
|
||||||
|
missingTypes.add(reportedType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
consider(expression.resolvedType)
|
val symbol = calleeReference.toResolvedCallableSymbol() ?: return
|
||||||
expression.extensionReceiver?.resolvedType?.let(::consider)
|
consider(symbol.resolvedReturnTypeRef.coneType)
|
||||||
expression.argumentList.arguments.forEach { consider(it.resolvedType) }
|
symbol.resolvedReceiverTypeRef?.coneType?.let(::consider)
|
||||||
|
(symbol as? FirFunctionSymbol<*>)?.valueParameterSymbols?.forEach { consider(it.resolvedReturnTypeRef.coneType) }
|
||||||
|
|
||||||
|
for (missingType in missingTypes) {
|
||||||
|
reporter.reportOn(expression.source, FirErrors.MISSING_DEPENDENCY_CLASS, missingType, context)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeKotlinType.forEachClassLikeType(action: (ConeClassLikeType) -> Unit) {
|
private fun ConeKotlinType.forEachClassLikeType(action: (ConeClassLikeType) -> Unit) {
|
||||||
|
|||||||
+125
@@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.fir.analysis.checkers.expression
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.KtSourceElement
|
||||||
|
import org.jetbrains.kotlin.config.AnalysisFlags
|
||||||
|
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||||
|
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||||
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.checkers.collectUpperBounds
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirBasicDeclarationChecker
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRefsOwner
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||||
|
import org.jetbrains.kotlin.fir.getOwnerLookupTag
|
||||||
|
import org.jetbrains.kotlin.fir.references.toResolvedCallableSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousFunctionSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jetbrains.kotlin.resolve.checkers.MissingDependencySupertypeChecker
|
||||||
|
*/
|
||||||
|
object FirMissingDependencySupertypeChecker {
|
||||||
|
object ForDeclarations : FirBasicDeclarationChecker() {
|
||||||
|
override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
|
if (declaration is FirClass) {
|
||||||
|
checkSupertypes(declaration.symbol, declaration.source, reporter, context)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (declaration is FirTypeParameterRefsOwner) {
|
||||||
|
for (typeParameter in declaration.typeParameters) {
|
||||||
|
for (upperBound in typeParameter.toConeType().collectUpperBounds()) {
|
||||||
|
checkSupertypes(upperBound, typeParameter.source, reporter, context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object ForQualifiedAccessExpressions : FirQualifiedAccessExpressionChecker() {
|
||||||
|
override fun check(expression: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
|
val source = expression.source
|
||||||
|
|
||||||
|
val symbol = expression.calleeReference.toResolvedCallableSymbol()
|
||||||
|
if (symbol == null) {
|
||||||
|
val receiverType = expression.explicitReceiver?.resolvedType
|
||||||
|
?.lowerBoundIfFlexible()?.originalIfDefinitelyNotNullable()?.fullyExpandedType(context.session)
|
||||||
|
checkSupertypes(receiverType, source, reporter, context)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val missingSupertype = checkSupertypes(symbol.dispatchReceiverType, source, reporter, context)
|
||||||
|
|
||||||
|
val eagerChecksAllowed = context.languageVersionSettings.getFlag(AnalysisFlags.extendedCompilerChecks)
|
||||||
|
val unresolvedLazySupertypesByDefault = symbol is FirConstructorSymbol || symbol is FirAnonymousFunctionSymbol
|
||||||
|
|
||||||
|
if (eagerChecksAllowed || !unresolvedLazySupertypesByDefault && !missingSupertype) {
|
||||||
|
checkSupertypes(symbol.getOwnerLookupTag()?.toSymbol(context.session), source, reporter, context)
|
||||||
|
checkSupertypes(symbol.resolvedReceiverTypeRef?.coneTypeOrNull, source, reporter, context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkSupertypes(
|
||||||
|
classifierType: ConeKotlinType?,
|
||||||
|
source: KtSourceElement?,
|
||||||
|
reporter: DiagnosticReporter,
|
||||||
|
context: CheckerContext,
|
||||||
|
): Boolean = checkSupertypes(classifierType?.toSymbol(context.session), source, reporter, context)
|
||||||
|
|
||||||
|
fun checkSupertypes(
|
||||||
|
declaration: FirBasedSymbol<*>?,
|
||||||
|
source: KtSourceElement?,
|
||||||
|
reporter: DiagnosticReporter,
|
||||||
|
context: CheckerContext,
|
||||||
|
): Boolean {
|
||||||
|
if (declaration !is FirClassSymbol<*>) return false
|
||||||
|
|
||||||
|
var missingSupertype = false
|
||||||
|
val superTypes = declaration.collectSuperTypes(context.session)
|
||||||
|
for (superType in superTypes) {
|
||||||
|
if (superType is ConeErrorType || superType is ConeDynamicType) continue // Ignore types which are already errors.
|
||||||
|
|
||||||
|
val superTypeSymbol = superType.toSymbol(context.session)
|
||||||
|
if (superTypeSymbol == null) {
|
||||||
|
missingSupertype = true
|
||||||
|
|
||||||
|
reporter.reportOn(
|
||||||
|
source,
|
||||||
|
FirErrors.MISSING_DEPENDENCY_SUPERCLASS,
|
||||||
|
superType.withArguments(emptyArray()).withNullability(ConeNullability.NOT_NULL, context.session.typeContext),
|
||||||
|
declaration.constructType(emptyArray(), false),
|
||||||
|
context
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return missingSupertype
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun FirClassSymbol<*>.collectSuperTypes(session: FirSession): Set<ConeKotlinType> {
|
||||||
|
val superTypes = mutableSetOf<ConeKotlinType>()
|
||||||
|
fun collect(symbol: FirClassSymbol<*>) {
|
||||||
|
for (superType in symbol.resolvedSuperTypes) {
|
||||||
|
if (superTypes.add(superType)) {
|
||||||
|
(superType.toSymbol(session) as? FirClassSymbol<*>)?.let(::collect)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
collect(this)
|
||||||
|
return superTypes
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
@@ -373,6 +373,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.METHOD_OF_ANY_IMP
|
|||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISPLACED_TYPE_PARAMETER_CONSTRAINTS
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISPLACED_TYPE_PARAMETER_CONSTRAINTS
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_CONSTRUCTOR_KEYWORD
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_CONSTRUCTOR_KEYWORD
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_DEPENDENCY_CLASS
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_DEPENDENCY_CLASS
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_DEPENDENCY_SUPERCLASS
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_STDLIB_CLASS
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_STDLIB_CLASS
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_VAL_ON_ANNOTATION_PARAMETER
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_VAL_ON_ANNOTATION_PARAMETER
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MIXING_FUNCTIONAL_KINDS_IN_SUPERTYPES
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MIXING_FUNCTIONAL_KINDS_IN_SUPERTYPES
|
||||||
@@ -765,6 +766,12 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
|||||||
"Cannot access class ''{0}''. Check your module classpath for missing or conflicting dependencies.",
|
"Cannot access class ''{0}''. Check your module classpath for missing or conflicting dependencies.",
|
||||||
RENDER_TYPE,
|
RENDER_TYPE,
|
||||||
)
|
)
|
||||||
|
map.put(
|
||||||
|
MISSING_DEPENDENCY_SUPERCLASS,
|
||||||
|
"Cannot access ''{0}'' which is a supertype of ''{1}''. Check your module classpath for missing or conflicting dependencies.",
|
||||||
|
RENDER_TYPE,
|
||||||
|
RENDER_TYPE,
|
||||||
|
)
|
||||||
|
|
||||||
map.put(ASSIGNMENT_IN_EXPRESSION_CONTEXT, "Only expressions are allowed in this context.")
|
map.put(ASSIGNMENT_IN_EXPRESSION_CONTEXT, "Only expressions are allowed in this context.")
|
||||||
map.put(EXPRESSION_EXPECTED, "Only expressions are allowed here.")
|
map.put(EXPRESSION_EXPECTED, "Only expressions are allowed here.")
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ compiler/testData/cli/jvm/firDeprecationJava.kt:3:12: warning: '@Deprecated(...)
|
|||||||
compiler/testData/cli/jvm/firDeprecationJava.kt:4:17: warning: '@Deprecated(...) fun bar(a: String!, b: Int, c: Double): String!' is deprecated. Deprecated in Java.
|
compiler/testData/cli/jvm/firDeprecationJava.kt:4:17: warning: '@Deprecated(...) fun bar(a: String!, b: Int, c: Double): String!' is deprecated. Deprecated in Java.
|
||||||
JavaClass().bar("", 1, 2.0)
|
JavaClass().bar("", 1, 2.0)
|
||||||
^
|
^
|
||||||
compiler/testData/cli/jvm/firDeprecationJava.kt:5:27: warning: '@Deprecated(...) field baz: List!' is deprecated. Deprecated in Java.
|
compiler/testData/cli/jvm/firDeprecationJava.kt:5:27: warning: '@Deprecated(...) field baz: ft<MutableList<String!>, List<String!>?>' is deprecated. Deprecated in Java.
|
||||||
val baz = JavaClass().baz
|
val baz = JavaClass().baz
|
||||||
^
|
^
|
||||||
OK
|
OK
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class JavaClass {
|
public class JavaClass {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String bar(String a, int b, double c) {
|
public String bar(String a, int b, double c) {
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
compiler/testData/cli/jvm/singleJavaFileRoots/test.kt:7:9: error: cannot access class 'C!'. Check your module classpath for missing or conflicting dependencies.
|
compiler/testData/cli/jvm/singleJavaFileRoots/test.kt:7:9: error: cannot access class 'C'. Check your module classpath for missing or conflicting dependencies.
|
||||||
B().c()
|
B().c()
|
||||||
^
|
^
|
||||||
compiler/testData/cli/jvm/singleJavaFileRoots/test.kt:8:5: error: unresolved reference 'C'.
|
compiler/testData/cli/jvm/singleJavaFileRoots/test.kt:8:5: error: unresolved reference 'C'.
|
||||||
|
|||||||
+1
-3
@@ -1,7 +1,5 @@
|
|||||||
// IGNORE_BACKEND_K1: ANY
|
// IGNORE_BACKEND_K1: ANY
|
||||||
// IGNORE_REASON: new rules for supertypes matching are implemented only in K2
|
// IGNORE_REASON: new rules for supertypes matching are implemented only in K2
|
||||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
|
||||||
// IGNORE_REASON: `JsName` in js.translator/testData/_commonFiles/testUtils.kt is invisible for some reason
|
|
||||||
// LANGUAGE: +MultiPlatformProjects
|
// LANGUAGE: +MultiPlatformProjects
|
||||||
// ISSUE: KT-59356
|
// ISSUE: KT-59356
|
||||||
|
|
||||||
@@ -16,7 +14,7 @@ fun commonBox(): String {
|
|||||||
return C().foo()
|
return C().foo()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE: platform-jvm()()(common)
|
// MODULE: platform()()(common)
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
open class B : A() {
|
open class B : A() {
|
||||||
override fun foo(): String = "OK"
|
override fun foo(): String = "OK"
|
||||||
|
|||||||
+1
-3
@@ -1,7 +1,5 @@
|
|||||||
// IGNORE_BACKEND_K1: ANY
|
// IGNORE_BACKEND_K1: ANY
|
||||||
// IGNORE_REASON: KT-59355 is fixed only in K2
|
// IGNORE_REASON: KT-59355 is fixed only in K2
|
||||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
|
||||||
// IGNORE_REASON: `JsName` in js.translator/testData/_commonFiles/testUtils.kt is invisible for some reason
|
|
||||||
// LANGUAGE: +MultiPlatformProjects
|
// LANGUAGE: +MultiPlatformProjects
|
||||||
// ISSUE: KT-59355
|
// ISSUE: KT-59355
|
||||||
|
|
||||||
@@ -29,7 +27,7 @@ fun commonBox(): String {
|
|||||||
return x + y
|
return x + y
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE: platform-jvm()()(common)
|
// MODULE: platform()()(common)
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
public actual open class Some actual constructor() {
|
public actual open class Some actual constructor() {
|
||||||
public actual class ProtectedNested actual constructor() {
|
public actual class ProtectedNested actual constructor() {
|
||||||
|
|||||||
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
// !LANGUAGE: +MultiPlatformProjects
|
// !LANGUAGE: +MultiPlatformProjects
|
||||||
// IGNORE_BACKEND: JS
|
// IGNORE_BACKEND: JS
|
||||||
// IGNORE_BACKEND: JS_IR
|
// IGNORE_BACKEND_K1: JS_IR
|
||||||
// IGNORE_BACKEND: JS_IR_ES6
|
// IGNORE_BACKEND_K1: JS_IR_ES6
|
||||||
// IGNORE_BACKEND_K1: WASM
|
// IGNORE_BACKEND_K1: WASM
|
||||||
|
|
||||||
// MODULE: lib-common
|
// MODULE: lib-common
|
||||||
@@ -11,7 +11,7 @@ package test
|
|||||||
|
|
||||||
expect enum class E
|
expect enum class E
|
||||||
|
|
||||||
// MODULE: lib-jvm()()(lib-common)
|
// MODULE: lib()()(lib-common)
|
||||||
// FILE: jvm.kt
|
// FILE: jvm.kt
|
||||||
|
|
||||||
package test
|
package test
|
||||||
@@ -22,7 +22,7 @@ enum class F {
|
|||||||
OK;
|
OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODULE: main(lib-jvm)
|
// MODULE: main(lib)
|
||||||
// FILE: jvm2.kt
|
// FILE: jvm2.kt
|
||||||
|
|
||||||
import test.E.*
|
import test.E.*
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/computeSupertypeWithMissingDependency/source.kt:7:11: error: cannot access class 'a.A'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b.foo()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/computeSupertypeWithMissingDependency/source.kt:9:11: error: cannot access class 'a.A'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b.bar()
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:3:1: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
class SubSub : Sub()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:4:14: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
class Client<T : Sub>(val prop: T)
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:5:6: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
fun <T : Sub> withTypeParam() {}
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:12:11: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
Sub().unresolved()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:12:11: error: unresolved reference 'unresolved'.
|
||||||
|
Sub().unresolved()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:13:14: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
SubSub().unresolved()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:13:14: error: unresolved reference 'unresolved'.
|
||||||
|
SubSub().unresolved()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:14:15: error: cannot access 'test.Super' which is a supertype of '<anonymous>'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
val obj = object : Sub() {}
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:15:25: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
withCallRefArg(Sub::resolved)
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:16:11: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
Sub().resolved()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:17:11: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
Sub().extension()
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInJava/source.kt:3:1: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
class SubSub : Sub()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInJava/source.kt:5:22: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
fun bar() = SubSub().foo()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInJava/source.kt:5:22: error: unresolved reference 'foo'.
|
||||||
|
fun bar() = SubSub().foo()
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInKotlin/source.kt:3:1: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
class SubSub : Sub()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInKotlin/source.kt:5:22: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
fun bar() = SubSub().foo()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInKotlin/source.kt:5:22: error: unresolved reference 'foo'.
|
||||||
|
fun bar() = SubSub().foo()
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyMissingInterface/source.kt:5:15: error: cannot access 'test.A' which is a supertype of 'test.B'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
D.m(B.n())
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyOfEnclosingClass/source.kt:6:16: error: cannot access 'test.Super' which is a supertype of 'test.SubClass'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
SubClass().Inner() // Error - dispatch receiver misses supertype
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyWithExtendedCompilerChecks/source.kt:12:32: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
fun simpleFun(arg: Sub): Sub = Sub()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyWithExtendedCompilerChecks/source.kt:19:18: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
val x: Sub = Sub()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyWithExtendedCompilerChecks/source.kt:21:18: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
useCallRef(::Sub)
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyWithExtendedCompilerChecks/source.kt:22:15: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
simpleFun(Sub())
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyWithExtendedCompilerChecks/source.kt:23:20: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
inlineFun<Sub>(Sub())
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyConflictingLibraries/source.kt:7:8: error: cannot access class 'a.A.Inner'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b2.consumeA(b1.produceA())
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyConflictingLibraries/source.kt:7:20: error: cannot access class 'a.A.Inner'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b2.consumeA(b1.produceA())
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyConflictingLibraries/source.kt:8:8: error: cannot access class 'a.A.Inner'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b2.consumeA(b1.produceAGeneric("foo"))
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyConflictingLibraries/source.kt:8:20: error: cannot access class 'a.A.Inner'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b2.consumeA(b1.produceAGeneric("foo"))
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyConflictingLibraries/source.kt:12:8: error: cannot access class 'a.AA.Inner'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b2.consumeAA(b1.produceAA())
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyConflictingLibraries/source.kt:12:21: error: cannot access class 'a.AA.Inner'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b2.consumeAA(b1.produceAA())
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyConflictingLibraries/source.kt:16:8: error: cannot access class 'a.AAA.Inner.InnerInner'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b2.consumeAAA(b1.produceAAA())
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyConflictingLibraries/source.kt:16:22: error: cannot access class 'a.AAA.Inner.InnerInner'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b2.consumeAAA(b1.produceAAA())
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyDifferentCases/source.kt:6:7: error: cannot access class 'a.A'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b.returnType()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyDifferentCases/source.kt:7:7: error: cannot access class 'a.A'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b.parameter(null)
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyDifferentCases/source.kt:8:10: error: cannot access class 'a.A'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
null.extensionReceiver()
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyJava/source.kt:4:17: error: cannot access class 'test.Bar'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
val bar = f.getBar()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyJava/source.kt:5:5: error: cannot access class 'test.Bar'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
bar.bar()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyJava/source.kt:5:9: error: unresolved reference 'bar'.
|
||||||
|
bar.bar()
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyJavaConflictingLibraries/source.kt:4:8: error: cannot access class 'test.A.Inner'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b2.consumeA(b1.produceA())
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencyJavaConflictingLibraries/source.kt:4:20: error: cannot access class 'test.A.Inner'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b2.consumeA(b1.produceA())
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
Vendored
+13
@@ -0,0 +1,13 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencySimple/source.kt:7:7: error: cannot access class 'a.A'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
b.foo()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencySimple/source.kt:10:21: error: initializer type mismatch: expected 'kotlin.String', actual 'a.A'.
|
||||||
|
val x: String = b.foo()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencySimple/source.kt:10:21: error: type mismatch: inferred type is 'a.A', but 'kotlin.String' was expected.
|
||||||
|
val x: String = b.foo()
|
||||||
|
^
|
||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingDependencySimple/source.kt:10:23: error: cannot access class 'a.A'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
val x: String = b.foo()
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
compiler/testData/compileKotlinAgainstCustomBinaries/missingStaticClass/source.kt:4:15: error: cannot access class 'test.C.D'. Check your module classpath for missing or conflicting dependencies.
|
||||||
|
val c = C.makeD()
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+13
-25
@@ -154,18 +154,15 @@ abstract class AbstractCompileKotlinAgainstCustomBinariesTest : AbstractKotlinCo
|
|||||||
doTestBrokenLibrary("library", "a/E.class")
|
doTestBrokenLibrary("library", "a/E.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testIncompleteHierarchyInJava() {
|
||||||
fun testIncompleteHierarchyInJava() = muteForK2 {
|
|
||||||
doTestBrokenLibrary("library", "test/Super.class")
|
doTestBrokenLibrary("library", "test/Super.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testIncompleteHierarchyInKotlin() {
|
||||||
fun testIncompleteHierarchyInKotlin() = muteForK2 {
|
|
||||||
doTestBrokenLibrary("library", "test/Super.class")
|
doTestBrokenLibrary("library", "test/Super.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testIncompleteHierarchyMissingInterface() {
|
||||||
fun testIncompleteHierarchyMissingInterface() = muteForK2 {
|
|
||||||
doTestBrokenLibrary("library", "test/A.class")
|
doTestBrokenLibrary("library", "test/A.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,8 +170,7 @@ abstract class AbstractCompileKotlinAgainstCustomBinariesTest : AbstractKotlinCo
|
|||||||
doTestBrokenLibrary("library", "test/Super.class")
|
doTestBrokenLibrary("library", "test/Super.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testMissingStaticClass() {
|
||||||
fun testMissingStaticClass() = muteForK2 {
|
|
||||||
doTestBrokenLibrary("library", "test/C\$D.class")
|
doTestBrokenLibrary("library", "test/C\$D.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +179,7 @@ abstract class AbstractCompileKotlinAgainstCustomBinariesTest : AbstractKotlinCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
||||||
fun testIncompleteHierarchyWithExtendedCompilerChecks() = muteForK2 {
|
fun testIncompleteHierarchyWithExtendedCompilerChecks() {
|
||||||
doTestBrokenLibrary(
|
doTestBrokenLibrary(
|
||||||
"library",
|
"library",
|
||||||
"test/Super.class",
|
"test/Super.class",
|
||||||
@@ -191,18 +187,15 @@ abstract class AbstractCompileKotlinAgainstCustomBinariesTest : AbstractKotlinCo
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testIncompleteHierarchyErrorPositions() {
|
||||||
fun testIncompleteHierarchyErrorPositions() = muteForK2 {
|
|
||||||
doTestBrokenLibrary("library", "test/Super.class")
|
doTestBrokenLibrary("library", "test/Super.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testIncompleteHierarchyOfEnclosingClass() {
|
||||||
fun testIncompleteHierarchyOfEnclosingClass() = muteForK2 {
|
|
||||||
doTestBrokenLibrary("library", "test/Super.class")
|
doTestBrokenLibrary("library", "test/Super.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testMissingDependencySimple() {
|
||||||
fun testMissingDependencySimple() = muteForK2 {
|
|
||||||
doTestBrokenLibrary("library", "a/A.class")
|
doTestBrokenLibrary("library", "a/A.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,13 +203,11 @@ abstract class AbstractCompileKotlinAgainstCustomBinariesTest : AbstractKotlinCo
|
|||||||
doTestBrokenLibrary("library", "my/Some.class", additionalOptions = listOf("-Xuse-javac", "-Xcompile-java"))
|
doTestBrokenLibrary("library", "my/Some.class", additionalOptions = listOf("-Xuse-javac", "-Xcompile-java"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testComputeSupertypeWithMissingDependency() {
|
||||||
fun testComputeSupertypeWithMissingDependency() = muteForK2 {
|
|
||||||
doTestBrokenLibrary("library", "a/A.class")
|
doTestBrokenLibrary("library", "a/A.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testMissingDependencyDifferentCases() {
|
||||||
fun testMissingDependencyDifferentCases() = muteForK2 {
|
|
||||||
doTestBrokenLibrary("library", "a/A.class")
|
doTestBrokenLibrary("library", "a/A.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,8 +215,7 @@ abstract class AbstractCompileKotlinAgainstCustomBinariesTest : AbstractKotlinCo
|
|||||||
doTestBrokenLibrary("library", "a/A\$Anno.class")
|
doTestBrokenLibrary("library", "a/A\$Anno.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testMissingDependencyConflictingLibraries() {
|
||||||
fun testMissingDependencyConflictingLibraries() = muteForK2 {
|
|
||||||
val library1 = copyJarFileWithoutEntry(
|
val library1 = copyJarFileWithoutEntry(
|
||||||
compileLibrary("library1"),
|
compileLibrary("library1"),
|
||||||
"a/A.class", "a/A\$Inner.class", "a/AA.class", "a/AA\$Inner.class",
|
"a/A.class", "a/A\$Inner.class", "a/AA.class", "a/AA\$Inner.class",
|
||||||
@@ -239,13 +229,11 @@ abstract class AbstractCompileKotlinAgainstCustomBinariesTest : AbstractKotlinCo
|
|||||||
compileKotlin("source.kt", tmpdir, listOf(library1, library2))
|
compileKotlin("source.kt", tmpdir, listOf(library1, library2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testMissingDependencyJava() {
|
||||||
fun testMissingDependencyJava() = muteForK2 {
|
|
||||||
doTestBrokenLibrary("library", "test/Bar.class")
|
doTestBrokenLibrary("library", "test/Bar.class")
|
||||||
}
|
}
|
||||||
|
|
||||||
// KT-60778 K2: implement MISSING_DEPENDENCY_CLASS(_SUPERCLASS) errors
|
fun testMissingDependencyJavaConflictingLibraries() {
|
||||||
fun testMissingDependencyJavaConflictingLibraries() = muteForK2 {
|
|
||||||
val library1 = copyJarFileWithoutEntry(compileLibrary("library1"), "test/A.class", "test/A\$Inner.class")
|
val library1 = copyJarFileWithoutEntry(compileLibrary("library1"), "test/A.class", "test/A\$Inner.class")
|
||||||
val library2 = copyJarFileWithoutEntry(compileLibrary("library2"), "test/A.class", "test/A\$Inner.class")
|
val library2 = copyJarFileWithoutEntry(compileLibrary("library2"), "test/A.class", "test/A\$Inner.class")
|
||||||
compileKotlin("source.kt", tmpdir, listOf(library1, library2))
|
compileKotlin("source.kt", tmpdir, listOf(library1, library2))
|
||||||
|
|||||||
Reference in New Issue
Block a user