Fix warnings in stdlib/compiler/plugins/test code

This commit is contained in:
Alexander Udalov
2020-11-26 21:25:01 +01:00
parent b3d85e656e
commit 221f44da5f
48 changed files with 109 additions and 101 deletions
@@ -18,6 +18,7 @@ open class SourceElementPositioningStrategy<in E : PsiElement>(
fun markDiagnostic(diagnostic: FirDiagnostic<*>): List<TextRange> {
val element = diagnostic.element
if (element is FirPsiSourceElement<*>) {
@Suppress("UNCHECKED_CAST")
return psiStrategy.mark(element.psi as E)
}
return lightTreeStrategy.mark(element.lighterASTNode, element.treeStructure)
@@ -25,6 +26,7 @@ open class SourceElementPositioningStrategy<in E : PsiElement>(
fun isValid(element: FirSourceElement): Boolean {
if (element is FirPsiSourceElement<*>) {
@Suppress("UNCHECKED_CAST")
return psiStrategy.isValid(element.psi as E)
}
return lightTreeStrategy.isValid(element.lighterASTNode, element.treeStructure)
@@ -33,4 +35,4 @@ open class SourceElementPositioningStrategy<in E : PsiElement>(
companion object {
val DEFAULT: SourceElementPositioningStrategy<PsiElement> = SourceElementPositioningStrategies.DEFAULT
}
}
}
@@ -36,7 +36,7 @@ data class CallableId(
constructor(packageName: FqName, callableName: Name) : this(packageName, null, callableName)
@Deprecated("TODO: Better solution for local callables?")
@LocalCallableIdConstructor
constructor(
callableName: Name,
// Currently, it's only used for debug info
@@ -67,4 +67,5 @@ data class CallableId(
}
}
@RequiresOptIn("TODO: Better solution for local callables?")
annotation class LocalCallableIdConstructor
@@ -767,6 +767,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
}
}
@OptIn(ExperimentalUnsignedTypes::class)
when (expression.kind) {
FirConstKind.Null -> keyword("null")
FirConstKind.Boolean -> keyword(value.toString())
@@ -253,7 +253,7 @@ class Fir2IrDeclarationStorage(
private fun <T : IrFunction> T.declareDefaultSetterParameter(type: IrType): T {
valueParameters = listOf(
createDefaultSetterParameter(startOffset, endOffset, origin, type, parent = this)
createDefaultSetterParameter(startOffset, endOffset, type, parent = this)
)
return this
}
@@ -261,7 +261,6 @@ class Fir2IrDeclarationStorage(
internal fun createDefaultSetterParameter(
startOffset: Int,
endOffset: Int,
origin: IrDeclarationOrigin,
type: IrType,
parent: IrFunction
): IrValueParameter {
@@ -170,7 +170,7 @@ class CallAndReferenceGenerator(
return null
}
private fun FirExpression.superQualifierSymbol(callSymbol: IrSymbol?): IrClassSymbol? {
private fun FirExpression.superQualifierSymbol(): IrClassSymbol? {
if (this !is FirQualifiedAccess) {
return null
}
@@ -220,7 +220,7 @@ class CallAndReferenceGenerator(
typeArgumentsCount = symbol.owner.typeParameters.size,
valueArgumentsCount = symbol.owner.valueParameters.size,
origin = qualifiedAccess.calleeReference.statementOrigin(),
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol)
superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
)
}
is IrLocalDelegatedPropertySymbol -> {
@@ -229,7 +229,7 @@ class CallAndReferenceGenerator(
typeArgumentsCount = symbol.owner.getter.typeParameters.size,
valueArgumentsCount = 0,
origin = IrStatementOrigin.GET_LOCAL_PROPERTY,
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol)
superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
)
}
is IrPropertySymbol -> {
@@ -241,11 +241,11 @@ class CallAndReferenceGenerator(
typeArgumentsCount = getter.typeParameters.size,
valueArgumentsCount = 0,
origin = IrStatementOrigin.GET_PROPERTY,
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol)
superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
)
backingField != null -> IrGetFieldImpl(
startOffset, endOffset, backingField.symbol, type,
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol)
superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
)
else -> IrErrorCallExpressionImpl(
startOffset, endOffset, type,
@@ -256,7 +256,7 @@ class CallAndReferenceGenerator(
is IrFieldSymbol -> IrGetFieldImpl(
startOffset, endOffset, symbol, type,
origin = IrStatementOrigin.GET_PROPERTY.takeIf { qualifiedAccess.calleeReference !is FirDelegateFieldReference },
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol)
superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
)
is IrValueSymbol -> IrGetValueImpl(
startOffset, endOffset, type, symbol,
@@ -297,7 +297,7 @@ class CallAndReferenceGenerator(
typeArgumentsCount = setter.typeParameters.size,
valueArgumentsCount = 1,
origin = origin,
superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol(symbol)
superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol()
).apply {
putValueArgument(0, assignedValue)
}
@@ -314,14 +314,14 @@ class CallAndReferenceGenerator(
typeArgumentsCount = setter.typeParameters.size,
valueArgumentsCount = 1,
origin = origin,
superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol(symbol)
superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol()
).apply {
putValueArgument(0, assignedValue)
}
backingField != null -> IrSetFieldImpl(
startOffset, endOffset, backingField.symbol, type,
origin = null, // NB: to be consistent with PSI2IR, origin should be null here
superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol(symbol)
superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol()
).apply {
value = assignedValue
}
@@ -68,7 +68,7 @@ class Fir2IrLazyPropertyAccessor(
declarationStorage.enterScope(this)
listOf(
declarationStorage.createDefaultSetterParameter(
startOffset, endOffset, origin,
startOffset, endOffset,
(firAccessor?.valueParameters?.firstOrNull()?.returnTypeRef ?: firParentProperty.returnTypeRef).toIrType(
typeConverter, conversionTypeContext
),
@@ -88,4 +88,4 @@ class Fir2IrLazyPropertyAccessor(
get() = firParentProperty.containerSource
private val conversionTypeContext = if (isSetter) ConversionTypeContext.DEFAULT.inSetter() else ConversionTypeContext.DEFAULT
}
}
@@ -131,11 +131,11 @@ class FirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
createMemoryDump(moduleData)
val disambiguatedName = moduleData.disambiguatedName()
dumpFir(disambiguatedName, moduleData, firFiles)
dumpFirHtml(disambiguatedName, moduleData, firFiles)
dumpFir(disambiguatedName, firFiles)
dumpFirHtml(disambiguatedName, firFiles)
}
private fun dumpFir(disambiguatedName: String, moduleData: ModuleData, firFiles: List<FirFile>) {
private fun dumpFir(disambiguatedName: String, firFiles: List<FirFile>) {
if (!DUMP_FIR) return
val dumpRoot = File(FIR_DUMP_PATH).resolve(disambiguatedName)
firFiles.forEach {
@@ -150,13 +150,13 @@ class FirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
val baseName = qualifiedName
var disambiguatedName = baseName
var counter = 1
while(!dumpedModules.add(disambiguatedName)) {
while (!dumpedModules.add(disambiguatedName)) {
disambiguatedName = "$baseName.${counter++}"
}
return disambiguatedName
}
private fun dumpFirHtml(disambiguatedName: String, moduleData: ModuleData, firFiles: List<FirFile>) {
private fun dumpFirHtml(disambiguatedName: String, firFiles: List<FirFile>) {
if (!DUMP_FIR) return
dump.module(disambiguatedName) {
firFiles.forEach(dump::indexFile)
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.fir
import com.intellij.openapi.util.Disposer
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
@@ -27,9 +27,7 @@ class NonFirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
private val times = mutableListOf<Long>()
private fun runAnalysis(moduleData: ModuleData, environment: KotlinCoreEnvironment) {
val project = environment.project
private fun runAnalysis(environment: KotlinCoreEnvironment) {
val time = measureNanoTime {
try {
KotlinToJVMBytecodeCompiler.analyze(environment)
@@ -98,7 +96,7 @@ class NonFirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
})
val environment = KotlinCoreEnvironment.createForTests(disposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
runAnalysis(moduleData, environment)
runAnalysis(environment)
Disposer.dispose(disposable)
return ProcessorAction.NEXT
@@ -122,4 +120,4 @@ class NonFirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
val bestPass = times.indexOf(bestTime)
dumpTime("Best pass: $bestPass", bestTime)
}
}
}
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.fir.references.impl.FirReferencePlaceholderForResolv
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.LocalCallableIdConstructor
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.builder.*
@@ -1540,7 +1541,7 @@ class DeclarationsConverter(
origin = FirDeclarationOrigin.Synthetic
name = delegateName
returnTypeRef = firTypeRef
symbol = FirFieldSymbol(CallableId(name))
symbol = FirFieldSymbol(@OptIn(LocalCallableIdConstructor::class) CallableId(name))
isVar = false
status = FirDeclarationStatusImpl(Visibilities.Local, Modality.FINAL)
}
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.fir.references.builder.*
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.LocalCallableIdConstructor
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.builder.*
@@ -559,7 +560,7 @@ class RawFirBuilder(
origin = FirDeclarationOrigin.Synthetic
name = delegateName
returnTypeRef = type
symbol = FirFieldSymbol(CallableId(name))
symbol = FirFieldSymbol(@OptIn(LocalCallableIdConstructor::class) CallableId(name))
isVar = false
status = FirDeclarationStatusImpl(Visibilities.Local, Modality.FINAL)
}
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.fir.references.FirReference
import org.jetbrains.kotlin.fir.references.builder.*
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.LocalCallableIdConstructor
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
@@ -116,7 +117,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
else
result.child(Name.identifier(firFunctionTarget.labelName!!))
}
CallableId(name, pathFqName)
@OptIn(LocalCallableIdConstructor::class) CallableId(name, pathFqName)
}
context.className == FqName.ROOT -> CallableId(context.packageFqName, name)
context.className.shortName() == ANONYMOUS_OBJECT_NAME -> CallableId(ANONYMOUS_CLASS_ID, name)
@@ -12,19 +12,19 @@ import org.jetbrains.kotlin.fir.declarations.FirVariable
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.LocalCallableIdConstructor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
open class FirVariableSymbol<D : FirVariable<D>>(override val callableId: CallableId) : FirCallableSymbol<D>() {
constructor(name: Name) : this(CallableId(name)) // TODO?
constructor(name: Name) : this(@OptIn(LocalCallableIdConstructor::class) CallableId(name)) // TODO?
}
open class FirPropertySymbol(
callableId: CallableId,
) : FirVariableSymbol<FirProperty>(callableId) {
// TODO: should we use this constructor for local variables?
constructor(name: Name) : this(CallableId(name))
constructor(name: Name) : this(@OptIn(LocalCallableIdConstructor::class) CallableId(name))
}
class FirBackingFieldSymbol(callableId: CallableId) : FirVariableSymbol<FirProperty>(callableId)