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
@@ -160,7 +160,6 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P
val item = testCases.item(i) as Element
val failure = item.getElementsByTagName("failure")
val name = item.getAttribute("name")
val clazz = item.getAttribute("classname")
if (failure.length == 0) {
object : TestCase(name) {
@@ -49,7 +49,7 @@ object KotlinCompilerRunnerUtils {
additionalJvmParams: Array<String> = arrayOf()
): CompileServiceSession? {
val daemonJVMOptions = configureDaemonJVMOptions(
additionalParams = additionalJvmParams,
*additionalJvmParams,
inheritMemoryLimits = true,
inheritOtherJvmOptions = false,
inheritAdditionalProperties = true
@@ -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)
@@ -17,7 +17,7 @@ class ActualDiagnostic constructor(val diagnostic: Diagnostic, override val plat
TextDiagnostic.InferenceCompatibility.OLD
override val name: String
get() = diagnostic.factory.name!!
get() = diagnostic.factory.name
val file: PsiFile
get() = diagnostic.psiFile
@@ -205,7 +205,7 @@ object DebugInfoUtil {
}
abstract class DebugInfoReporter {
fun preProcessReference(expression: KtReferenceExpression) {
fun preProcessReference(@Suppress("UNUSED_PARAMETER") expression: KtReferenceExpression) {
// do nothing
}
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.diagnostics;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import kotlin.DeprecationLevel;
import java.util.List;
@@ -43,6 +44,7 @@ public abstract class DiagnosticFactoryWithPsiElement<E extends PsiElement, D ex
@SuppressWarnings("MethodOverloadsMethodOfSuperclass")
@Deprecated
@kotlin.Deprecated(message = "Use `cast` from the superclass.", level = DeprecationLevel.HIDDEN)
// ABI-compatibility only (used in Android plugin)
public D cast(Diagnostic d) {
return super.cast(d);
@@ -164,7 +164,7 @@ abstract class KotlinSuppressCache {
companion object {
private fun getDiagnosticSuppressKey(diagnostic: Diagnostic): String =
diagnostic.factory.name!!.toLowerCase()
diagnostic.factory.name.toLowerCase()
private fun isSuppressedByStrings(key: String, strings: Set<String>, severity: Severity): Boolean =
severity == Severity.WARNING && "warnings" in strings || key in strings
@@ -447,7 +447,7 @@ class LocalDeclarationsLowering(
}
override fun visitDeclaration(declaration: IrDeclarationBase): IrStatement {
if (declaration is IrSymbolOwner && declaration in transformedDeclarations) {
if (declaration in transformedDeclarations) {
TODO()
}
return super.visitDeclaration(declaration)
@@ -458,17 +458,15 @@ class EnumSyntheticFunctionsLowering(val context: JsCommonBackendContext) : Decl
private val IrClass.initEntryInstancesFun: IrSimpleFunction? by context.mapping.enumClassToInitEntryInstancesFun
override fun transformFlat(declaration: IrDeclaration): List<IrDeclaration>? {
if (declaration is IrConstructor && declaration.isPrimary) {
declaration.parentEnumClassOrNull?.let { enumClass ->
if (declaration.parentClassOrNull?.isCompanion == true) {
(declaration.body as? IrSyntheticBody)?.let { originalBody ->
declaration.parentEnumClassOrNull?.let { enumClass ->
declaration.body = context.irFactory.createBlockBody(UNDEFINED_OFFSET, UNDEFINED_OFFSET) {
statements += context.createIrBuilder(declaration.symbol).irBlockBody {
+irCall(enumClass.initEntryInstancesFun!!.symbol)
}.statements + originalBody.statements
}
}
if (declaration is IrConstructor && declaration.isPrimary && declaration.parentEnumClassOrNull != null &&
declaration.parentClassOrNull?.isCompanion == true
) {
(declaration.body as? IrSyntheticBody)?.let { originalBody ->
declaration.parentEnumClassOrNull?.let { enumClass ->
declaration.body = context.irFactory.createBlockBody(UNDEFINED_OFFSET, UNDEFINED_OFFSET) {
statements += context.createIrBuilder(declaration.symbol).irBlockBody {
+irCall(enumClass.initEntryInstancesFun!!.symbol)
}.statements + originalBody.statements
}
}
}
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.ir.util.*
class InvokeStaticInitializersLowering(val context: JsIrBackendContext) : BodyLoweringPass {
override fun lower(irBody: IrBody, container: IrDeclaration) {
if (container !is IrConstructor) return
if (container?.parentClassOrNull?.isEnumClass == true) return
if (container.parentClassOrNull?.isEnumClass == true) return
val irClass = container.constructedClass
if (irClass.isEffectivelyExternal()) {
@@ -32,4 +32,4 @@ class InvokeStaticInitializersLowering(val context: JsIrBackendContext) : BodyLo
(irBody as IrStatementContainer).statements.add(0, getInstanceCall)
}
}
}
@@ -16,7 +16,10 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrLoop
import org.jetbrains.kotlin.ir.expressions.IrWhen
import org.jetbrains.kotlin.ir.types.isUnit
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
import org.jetbrains.kotlin.ir.util.isEffectivelyExternal
import org.jetbrains.kotlin.ir.util.isEnumClass
import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
import org.jetbrains.kotlin.ir.visitors.acceptVoid
@@ -370,7 +373,7 @@ class NameTables(
}
override fun visitDeclaration(declaration: IrDeclarationBase) {
if (declaration is IrDeclarationWithName && declaration is IrSymbolOwner) {
if (declaration is IrDeclarationWithName) {
table.declareFreshName(declaration, declaration.name.asString())
}
super.visitDeclaration(declaration)
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.*
@@ -39,7 +38,6 @@ import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.org.objectweb.asm.Type
internal val suspendLambdaPhase = makeIrFilePhase(
@@ -225,14 +223,14 @@ private class SuspendLambdaLowering(context: JvmBackendContext) : SuspendLowerin
private fun IrClass.addInvokeSuspendForLambda(
irFunction: IrFunction,
suspendLambda: IrClass,
fields: List<ParameterInfo>
parameterInfos: List<ParameterInfo>
): IrSimpleFunction {
val superMethod = suspendLambda.functions.single {
it.name.asString() == INVOKE_SUSPEND_METHOD_NAME && it.valueParameters.size == 1 &&
it.valueParameters[0].type.isKotlinResult()
}
return addFunctionOverride(superMethod, irFunction.startOffset, irFunction.endOffset).apply {
val localVals: List<IrVariable?> = fields.mapIndexed { index, param ->
val localVals: List<IrVariable?> = parameterInfos.map { param ->
if (param.isUsed) {
buildVariable(
parent = this,
@@ -139,7 +139,7 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV
val wasmGcType: WasmSymbol<WasmTypeDeclaration> = context.referenceGcType(klass.symbol)
klass.getWasmArrayAnnotation()?.let { wasmArrayInfo ->
if (klass.getWasmArrayAnnotation() != null) {
require(expression.valueArgumentsCount == 1) { "@WasmArrayOf constructs must have exactly one argument" }
generateExpression(expression.getValueArgument(0)!!)
body.buildRttCanon(context.transformType(klass.defaultType))
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.ir.util.isFunction
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.wasm.ir.*
class WasmModuleCodegenContextImpl(
override val backendContext: WasmBackendContext,
private val wasmFragment: WasmCompiledModuleFragment
@@ -100,8 +99,8 @@ class WasmModuleCodegenContextImpl(
wasmFragment.globals.define(irField, wasmGlobal)
}
override fun defineGcType(irClass: IrClassSymbol, wasmStruct: WasmTypeDeclaration) {
wasmFragment.gcTypes.define(irClass, wasmStruct)
override fun defineGcType(irClass: IrClassSymbol, wasmType: WasmTypeDeclaration) {
wasmFragment.gcTypes.define(irClass, wasmType)
}
override fun defineRTT(irClass: IrClassSymbol, wasmGlobal: WasmGlobal) {
@@ -1251,9 +1251,7 @@ open class IrFileSerializer(
if (backendSpecificExplicitRoot(file)) {
for (declaration in file.declarations) {
if (declaration is IrSymbolOwner) {
proto.addExplicitlyExportedToCompiler(serializeIrSymbol(declaration.symbol))
}
proto.addExplicitlyExportedToCompiler(serializeIrSymbol(declaration.symbol))
}
} else {
file.acceptVoid(
@@ -135,6 +135,7 @@ inline fun <reified T : PsiElement, reified V : PsiElement, reified U : PsiEleme
}
inline fun <reified T : PsiElement> PsiElement.getParentOfType(strict: Boolean, vararg stopAt: Class<out PsiElement>): T? {
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
return PsiTreeUtil.getParentOfType(this, T::class.java, strict, *stopAt)
}
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.codeMetaInfo.renderConfigurations
import com.intellij.util.containers.ContainerUtil
import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFactory1
import org.jetbrains.kotlin.codeMetaInfo.model.CodeMetaInfo
import org.jetbrains.kotlin.codeMetaInfo.model.DiagnosticCodeMetaInfo
@@ -39,8 +38,7 @@ open class DiagnosticCodeMetaInfoRenderConfiguration(
else -> DefaultErrorMessages.getRendererForDiagnostic(codeMetaInfo.diagnostic)
}
if (renderer is AbstractDiagnosticWithParametersRenderer) {
val renderParameters = renderer.renderParameters(codeMetaInfo.diagnostic)
params.addAll(ContainerUtil.map(renderParameters) { it.toString() })
renderer.renderParameters(codeMetaInfo.diagnostic).mapTo(params, Any::toString)
}
if (renderSeverity)
params.add("severity='${codeMetaInfo.diagnostic.severity}'")
@@ -75,9 +75,7 @@ object Conditions {
fun <T> not(c: Condition<T>): Condition<T> {
if (c === alwaysTrue<Any>()) return alwaysFalse()
if (c === alwaysFalse<Any>()) return alwaysTrue()
return if (c is Not<*>) {
(c as Not<T>).c as Condition<T>
} else Not(c)
return if (c is Not<*>) (c as Not<T>).c else Not(c)
}
fun <T> and(c1: Condition<T>, c2: Condition<T>): Condition<T> {
@@ -44,7 +44,7 @@ object TargetPlatformParser {
return runIf(platformString == JS) { JsPlatforms.DefaultSimpleJsPlatform }
}
private fun tryParseNativePlatform(platformString: String): NativePlatform? {
private fun tryParseNativePlatform(@Suppress("UNUSED_PARAMETER") platformString: String): NativePlatform? {
// TODO: support native platforms
return null
}
@@ -86,13 +86,13 @@ class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testSe
private fun callBoxMethodAndCheckResult(
classLoader: URLClassLoader,
clazz: Class<*>?,
@Suppress("UNUSED_PARAMETER") clazz: Class<*>?,
method: Method,
unexpectedBehaviour: Boolean
) {
val result = if (BOX_IN_SEPARATE_PROCESS_PORT != null) {
TODO()
// result = invokeBoxInSeparateProcess(classLoader, aClass)
// result = invokeBoxInSeparateProcess(classLoader, clazz)
} else {
val savedClassLoader = Thread.currentThread().contextClassLoader
if (savedClassLoader !== classLoader) {
@@ -30,7 +30,7 @@ class ClassicFrontend2IrConverter(
module: TestModule,
inputArtifact: ClassicFrontendOutputArtifact
): IrBackendInput {
val (psiFiles, analysisResult, project, languageVersionSettings) = inputArtifact
val (psiFiles, analysisResult, project, _) = inputArtifact
val configuration = testServices.compilerConfigurationProvider.getCompilerConfiguration(module)
@@ -73,6 +73,7 @@ class FirDiagnosticCodeMetaRenderConfiguration(
val diagnostic = codeMetaInfo.diagnostic
@Suppress("UNCHECKED_CAST")
val renderer = FirDefaultErrorMessages.getRendererForDiagnostic(diagnostic) as FirDiagnosticRenderer<FirDiagnostic<*>>
params.add(renderer.render(diagnostic))
@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.checkers
import com.google.common.collect.Lists
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.checkers.diagnostics.ActualDiagnostic
@@ -228,8 +227,8 @@ class CheckerTestUtilTest : KotlinTestWithEnvironment() {
private fun missing(data: DiagnosticData) = missing(data.name, data.startOffset, data.endOffset)
private fun asTextDiagnostic(diagnosticData: DiagnosticData, vararg params: String) =
diagnosticData.name + "(" + StringUtil.join(params, "; ") + ")"
private fun asTextDiagnostic(diagnosticData: DiagnosticData, vararg params: String): String =
params.joinToString(prefix = diagnosticData.name + "(", postfix = ")", separator = "; ")
private fun asDiagnosticRange(diagnosticData: DiagnosticData, vararg textDiagnostics: String): DiagnosedRange {
val range = DiagnosedRange(diagnosticData.startOffset)
@@ -205,7 +205,7 @@ abstract class AbstractFirDiagnosticsTest : AbstractFirBaseDiagnosticsTest() {
// Lambda argument is always (?) duplicated by function literal
// Block expression is always (?) duplicated by single block expression
if (sourceElement.elementType == KtNodeTypes.LAMBDA_ARGUMENT || sourceElement.elementType == KtNodeTypes.BLOCK) return null
val name = name ?: return null
val name = name
if (diagnosedRangesToDiagnosticNames[sourceElement.startOffset..sourceElement.endOffset]?.contains(name) != true) return null
val argumentText = argument()
@@ -184,12 +184,10 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
@OptIn(ObsoleteDescriptorBasedAPI::class)
override fun visitDeclaration(declaration: IrDeclarationBase) {
if (declaration is IrSymbolOwner) {
declaration.symbol.checkBinding("decl", declaration)
declaration.symbol.checkBinding("decl", declaration)
require(declaration.symbol.owner == declaration) {
"Symbol is not bound to declaration: ${declaration.render()}"
}
require(declaration.symbol.owner == declaration) {
"Symbol is not bound to declaration: ${declaration.render()}"
}
val containingDeclarationDescriptor = declaration.descriptor.containingDeclaration
@@ -31,7 +31,7 @@ class SpecTestsConsistencyTest : TestCase() {
@com.intellij.testFramework.Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getTestFiles(klass: Class<*>): List<Array<String>> {
fun getTestFiles(@Suppress("UNUSED_PARAMETER") klass: Class<*>): List<Array<String>> {
val testFiles = mutableListOf<Array<String>>()
TestArea.values().forEach { testArea ->
@@ -58,10 +58,10 @@ fun notLinkedSpecTestsPrint() {
}
}
fun main(args: Array<String>) {
fun main() {
println("==================================================")
linkedSpecTestsPrint()
println("==================================================")
notLinkedSpecTestsPrint()
println("==================================================")
}
}
@@ -52,7 +52,7 @@ class DiagnosticTestTypeValidator(
private fun collectDiagnostics(files: List<BaseDiagnosticsTest.TestFile>) {
files.forEach { file ->
file.actualDiagnostics.forEach {
val diagnosticName = it.diagnostic.factory.name!!
val diagnosticName = it.diagnostic.factory.name
diagnosticStats.run { put(diagnosticName, getOrDefault(diagnosticName, 0) + 1) }
diagnostics.add(it.diagnostic)
}
@@ -68,4 +68,4 @@ class DiagnosticTestTypeValidator(
val diagnostics = if (diagnosticStats.isNotEmpty()) "$diagnosticSeverityStats | $diagnosticStats" else "does not contain"
println("DIAGNOSTICS: $diagnostics")
}
}
}
@@ -146,6 +146,7 @@ public expect fun Throwable.printStackTrace(): Unit
* suppressed in order to deliver this exception.
*/
@SinceKotlin("1.4")
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
public expect fun Throwable.addSuppressed(exception: Throwable)
/**
@@ -157,4 +158,4 @@ public expect fun Throwable.addSuppressed(exception: Throwable)
* - if this [Throwable] instance has disabled the suppression.
*/
@SinceKotlin("1.4")
public expect val Throwable.suppressedExceptions: List<Throwable>
public expect val Throwable.suppressedExceptions: List<Throwable>
@@ -107,6 +107,7 @@ public expect annotation class JvmWildcard()
* Adding and removing the annotation is binary incompatible change, since inline classes' methods and functions with inline classes
* in their signature are mangled.
*/
@Suppress("NEWER_VERSION_IN_SINCE_KOTLIN")
@Target(CLASS)
@MustBeDocumented
@SinceKotlin("1.5")
@@ -116,6 +117,7 @@ public expect annotation class JvmInline()
/**
* Instructs compiler to mark the class as a record and generate relevant toString/equals/hashCode methods
*/
@Suppress("NEWER_VERSION_IN_SINCE_KOTLIN")
@Target(AnnotationTarget.CLASS)
@MustBeDocumented
@OptionalExpectation
@@ -140,6 +140,7 @@ public actual annotation class JvmWildcard
* Adding and removing the annotation is binary incompatible change, since inline classes' methods and functions with inline classes
* in their signature are mangled.
*/
@Suppress("NEWER_VERSION_IN_SINCE_KOTLIN")
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
@@ -149,6 +150,7 @@ public actual annotation class JvmInline
/**
* Instructs compiler to mark the class as a record and generate relevant toString/equals/hashCode methods
*/
@Suppress("NEWER_VERSION_IN_SINCE_KOTLIN")
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
@MustBeDocumented
@@ -34,9 +34,9 @@ abstract class AbstractAndroidBytecodeShapeTest : AbstractBytecodeTextTest() {
addAndroidExtensionsRuntimeLibrary(myEnvironment)
}
override fun doTest(path: String) {
val fileName = path + getTestName(true) + ".kt"
createAndroidAPIEnvironment(path)
override fun doTest(filePath: String) {
val fileName = filePath + getTestName(true) + ".kt"
createAndroidAPIEnvironment(filePath)
loadFileByFullPath(fileName)
val expected = readExpectedOccurrences(fileName)
val actual = generateToText()
@@ -8,7 +8,8 @@ package org.jetbrains.kotlin.importsDumper
import com.intellij.openapi.util.io.FileUtil
import com.intellij.testFramework.TestDataPath
import junit.framework.TestCase
import org.jetbrains.kotlin.cli.AbstractCliTest.*
import org.jetbrains.kotlin.cli.AbstractCliTest.executeCompilerGrabOutput
import org.jetbrains.kotlin.cli.AbstractCliTest.getNormalizedCompilerOutput
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
@@ -58,7 +59,8 @@ class ImportsDumperTest : TestCaseWithTmpdir() {
tmpDir.path,
"-Xplugin=${importsDumperJarInDist.path}",
"-P",
"plugin:${ImportsDumperCommandLineProcessor.PLUGIN_ID}:${ImportsDumperCliOptions.DESTINATION.name}=${actualDumpFile.path}"
"plugin:${ImportsDumperCommandLineProcessor.PLUGIN_ID}:" +
"${ImportsDumperCliOptions.DESTINATION.optionName}=${actualDumpFile.path}"
)
)
@@ -65,7 +65,7 @@ class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), Custom
@Test
fun testParameterNames() {
test("DefaultParameterValues", "test.Anno") { set, roundEnv, env ->
test("DefaultParameterValues", "test.Anno") { set, roundEnv, _ ->
val user = roundEnv.getElementsAnnotatedWith(set.single()).single() as TypeElement
val nameField = user.enclosedElements.filterIsInstance<VariableElement>().single()
assertEquals("John", nameField.constantValue)
@@ -14,5 +14,7 @@ private const val BUNDLE = "messages.KotlinParcelizeBundle"
object KotlinParcelizeBundle : AbstractKotlinBundle(BUNDLE) {
@JvmStatic
fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String = getMessage(key, *params)
}
fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String =
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
getMessage(key, *params)
}
@@ -28,7 +28,10 @@ import org.jetbrains.kotlin.scripting.resolve.KtFileScriptSource
import org.junit.Assert
import java.io.File
import kotlin.script.experimental.annotations.KotlinScript
import kotlin.script.experimental.api.*
import kotlin.script.experimental.api.ResultWithDiagnostics
import kotlin.script.experimental.api.ScriptCompilationConfiguration
import kotlin.script.experimental.api.compilerOptions
import kotlin.script.experimental.api.fileExtension
import kotlin.script.experimental.host.toScriptSource
import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration
import kotlin.script.experimental.jvmhost.createJvmScriptDefinitionFromTemplate
@@ -52,7 +55,7 @@ abstract class AbstractSamWithReceiverScriptNewDefTest : AbstractDiagnosticsTest
override fun analyzeAndCheck(testDataFile: File, files: List<TestFile>) {
val definition = createJvmScriptDefinitionFromTemplate<ScriptForSamWithReceiversNewDef>()
val scriptCompiler = ScriptJvmCompilerFromEnvironment(environment)
val (scripts, regular) = files.partition {
val scripts = files.filter {
it.ktFile?.virtualFile?.extension == definition.compilationConfiguration[ScriptCompilationConfiguration.fileExtension]
}
super.analyzeAndCheck(testDataFile, files)
@@ -327,7 +327,7 @@ class JvmIdeServicesTest : TestCase() {
private data class CliCompilationResult(val exitCode: ExitCode, val outputJarPath: String)
private fun compileFile(inputKtFileName: String, outputJarName: String): CliCompilationResult {
val jarPath = outputJarDir.resolve(outputJarName).toAbsolutePath().invariantSeparatorsPath
val jarPath = outputJarDir.resolve(outputJarName).toAbsolutePath().invariantSeparatorsPathString
val compilerArgs = arrayOf(
"$MODULE_PATH/testData/$inputKtFileName",