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 item = testCases.item(i) as Element
val failure = item.getElementsByTagName("failure") val failure = item.getElementsByTagName("failure")
val name = item.getAttribute("name") val name = item.getAttribute("name")
val clazz = item.getAttribute("classname")
if (failure.length == 0) { if (failure.length == 0) {
object : TestCase(name) { object : TestCase(name) {
@@ -49,7 +49,7 @@ object KotlinCompilerRunnerUtils {
additionalJvmParams: Array<String> = arrayOf() additionalJvmParams: Array<String> = arrayOf()
): CompileServiceSession? { ): CompileServiceSession? {
val daemonJVMOptions = configureDaemonJVMOptions( val daemonJVMOptions = configureDaemonJVMOptions(
additionalParams = additionalJvmParams, *additionalJvmParams,
inheritMemoryLimits = true, inheritMemoryLimits = true,
inheritOtherJvmOptions = false, inheritOtherJvmOptions = false,
inheritAdditionalProperties = true inheritAdditionalProperties = true
@@ -18,6 +18,7 @@ open class SourceElementPositioningStrategy<in E : PsiElement>(
fun markDiagnostic(diagnostic: FirDiagnostic<*>): List<TextRange> { fun markDiagnostic(diagnostic: FirDiagnostic<*>): List<TextRange> {
val element = diagnostic.element val element = diagnostic.element
if (element is FirPsiSourceElement<*>) { if (element is FirPsiSourceElement<*>) {
@Suppress("UNCHECKED_CAST")
return psiStrategy.mark(element.psi as E) return psiStrategy.mark(element.psi as E)
} }
return lightTreeStrategy.mark(element.lighterASTNode, element.treeStructure) return lightTreeStrategy.mark(element.lighterASTNode, element.treeStructure)
@@ -25,6 +26,7 @@ open class SourceElementPositioningStrategy<in E : PsiElement>(
fun isValid(element: FirSourceElement): Boolean { fun isValid(element: FirSourceElement): Boolean {
if (element is FirPsiSourceElement<*>) { if (element is FirPsiSourceElement<*>) {
@Suppress("UNCHECKED_CAST")
return psiStrategy.isValid(element.psi as E) return psiStrategy.isValid(element.psi as E)
} }
return lightTreeStrategy.isValid(element.lighterASTNode, element.treeStructure) return lightTreeStrategy.isValid(element.lighterASTNode, element.treeStructure)
@@ -33,4 +35,4 @@ open class SourceElementPositioningStrategy<in E : PsiElement>(
companion object { companion object {
val DEFAULT: SourceElementPositioningStrategy<PsiElement> = SourceElementPositioningStrategies.DEFAULT val DEFAULT: SourceElementPositioningStrategy<PsiElement> = SourceElementPositioningStrategies.DEFAULT
} }
} }
@@ -36,7 +36,7 @@ data class CallableId(
constructor(packageName: FqName, callableName: Name) : this(packageName, null, callableName) constructor(packageName: FqName, callableName: Name) : this(packageName, null, callableName)
@Deprecated("TODO: Better solution for local callables?") @LocalCallableIdConstructor
constructor( constructor(
callableName: Name, callableName: Name,
// Currently, it's only used for debug info // 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) { when (expression.kind) {
FirConstKind.Null -> keyword("null") FirConstKind.Null -> keyword("null")
FirConstKind.Boolean -> keyword(value.toString()) FirConstKind.Boolean -> keyword(value.toString())
@@ -253,7 +253,7 @@ class Fir2IrDeclarationStorage(
private fun <T : IrFunction> T.declareDefaultSetterParameter(type: IrType): T { private fun <T : IrFunction> T.declareDefaultSetterParameter(type: IrType): T {
valueParameters = listOf( valueParameters = listOf(
createDefaultSetterParameter(startOffset, endOffset, origin, type, parent = this) createDefaultSetterParameter(startOffset, endOffset, type, parent = this)
) )
return this return this
} }
@@ -261,7 +261,6 @@ class Fir2IrDeclarationStorage(
internal fun createDefaultSetterParameter( internal fun createDefaultSetterParameter(
startOffset: Int, startOffset: Int,
endOffset: Int, endOffset: Int,
origin: IrDeclarationOrigin,
type: IrType, type: IrType,
parent: IrFunction parent: IrFunction
): IrValueParameter { ): IrValueParameter {
@@ -170,7 +170,7 @@ class CallAndReferenceGenerator(
return null return null
} }
private fun FirExpression.superQualifierSymbol(callSymbol: IrSymbol?): IrClassSymbol? { private fun FirExpression.superQualifierSymbol(): IrClassSymbol? {
if (this !is FirQualifiedAccess) { if (this !is FirQualifiedAccess) {
return null return null
} }
@@ -220,7 +220,7 @@ class CallAndReferenceGenerator(
typeArgumentsCount = symbol.owner.typeParameters.size, typeArgumentsCount = symbol.owner.typeParameters.size,
valueArgumentsCount = symbol.owner.valueParameters.size, valueArgumentsCount = symbol.owner.valueParameters.size,
origin = qualifiedAccess.calleeReference.statementOrigin(), origin = qualifiedAccess.calleeReference.statementOrigin(),
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol) superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
) )
} }
is IrLocalDelegatedPropertySymbol -> { is IrLocalDelegatedPropertySymbol -> {
@@ -229,7 +229,7 @@ class CallAndReferenceGenerator(
typeArgumentsCount = symbol.owner.getter.typeParameters.size, typeArgumentsCount = symbol.owner.getter.typeParameters.size,
valueArgumentsCount = 0, valueArgumentsCount = 0,
origin = IrStatementOrigin.GET_LOCAL_PROPERTY, origin = IrStatementOrigin.GET_LOCAL_PROPERTY,
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol) superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
) )
} }
is IrPropertySymbol -> { is IrPropertySymbol -> {
@@ -241,11 +241,11 @@ class CallAndReferenceGenerator(
typeArgumentsCount = getter.typeParameters.size, typeArgumentsCount = getter.typeParameters.size,
valueArgumentsCount = 0, valueArgumentsCount = 0,
origin = IrStatementOrigin.GET_PROPERTY, origin = IrStatementOrigin.GET_PROPERTY,
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol) superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
) )
backingField != null -> IrGetFieldImpl( backingField != null -> IrGetFieldImpl(
startOffset, endOffset, backingField.symbol, type, startOffset, endOffset, backingField.symbol, type,
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol) superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
) )
else -> IrErrorCallExpressionImpl( else -> IrErrorCallExpressionImpl(
startOffset, endOffset, type, startOffset, endOffset, type,
@@ -256,7 +256,7 @@ class CallAndReferenceGenerator(
is IrFieldSymbol -> IrGetFieldImpl( is IrFieldSymbol -> IrGetFieldImpl(
startOffset, endOffset, symbol, type, startOffset, endOffset, symbol, type,
origin = IrStatementOrigin.GET_PROPERTY.takeIf { qualifiedAccess.calleeReference !is FirDelegateFieldReference }, origin = IrStatementOrigin.GET_PROPERTY.takeIf { qualifiedAccess.calleeReference !is FirDelegateFieldReference },
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol) superQualifierSymbol = dispatchReceiver.superQualifierSymbol()
) )
is IrValueSymbol -> IrGetValueImpl( is IrValueSymbol -> IrGetValueImpl(
startOffset, endOffset, type, symbol, startOffset, endOffset, type, symbol,
@@ -297,7 +297,7 @@ class CallAndReferenceGenerator(
typeArgumentsCount = setter.typeParameters.size, typeArgumentsCount = setter.typeParameters.size,
valueArgumentsCount = 1, valueArgumentsCount = 1,
origin = origin, origin = origin,
superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol(symbol) superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol()
).apply { ).apply {
putValueArgument(0, assignedValue) putValueArgument(0, assignedValue)
} }
@@ -314,14 +314,14 @@ class CallAndReferenceGenerator(
typeArgumentsCount = setter.typeParameters.size, typeArgumentsCount = setter.typeParameters.size,
valueArgumentsCount = 1, valueArgumentsCount = 1,
origin = origin, origin = origin,
superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol(symbol) superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol()
).apply { ).apply {
putValueArgument(0, assignedValue) putValueArgument(0, assignedValue)
} }
backingField != null -> IrSetFieldImpl( backingField != null -> IrSetFieldImpl(
startOffset, endOffset, backingField.symbol, type, startOffset, endOffset, backingField.symbol, type,
origin = null, // NB: to be consistent with PSI2IR, origin should be null here origin = null, // NB: to be consistent with PSI2IR, origin should be null here
superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol(symbol) superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol()
).apply { ).apply {
value = assignedValue value = assignedValue
} }
@@ -68,7 +68,7 @@ class Fir2IrLazyPropertyAccessor(
declarationStorage.enterScope(this) declarationStorage.enterScope(this)
listOf( listOf(
declarationStorage.createDefaultSetterParameter( declarationStorage.createDefaultSetterParameter(
startOffset, endOffset, origin, startOffset, endOffset,
(firAccessor?.valueParameters?.firstOrNull()?.returnTypeRef ?: firParentProperty.returnTypeRef).toIrType( (firAccessor?.valueParameters?.firstOrNull()?.returnTypeRef ?: firParentProperty.returnTypeRef).toIrType(
typeConverter, conversionTypeContext typeConverter, conversionTypeContext
), ),
@@ -88,4 +88,4 @@ class Fir2IrLazyPropertyAccessor(
get() = firParentProperty.containerSource get() = firParentProperty.containerSource
private val conversionTypeContext = if (isSetter) ConversionTypeContext.DEFAULT.inSetter() else ConversionTypeContext.DEFAULT private val conversionTypeContext = if (isSetter) ConversionTypeContext.DEFAULT.inSetter() else ConversionTypeContext.DEFAULT
} }
@@ -131,11 +131,11 @@ class FirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
createMemoryDump(moduleData) createMemoryDump(moduleData)
val disambiguatedName = moduleData.disambiguatedName() val disambiguatedName = moduleData.disambiguatedName()
dumpFir(disambiguatedName, moduleData, firFiles) dumpFir(disambiguatedName, firFiles)
dumpFirHtml(disambiguatedName, moduleData, 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 if (!DUMP_FIR) return
val dumpRoot = File(FIR_DUMP_PATH).resolve(disambiguatedName) val dumpRoot = File(FIR_DUMP_PATH).resolve(disambiguatedName)
firFiles.forEach { firFiles.forEach {
@@ -150,13 +150,13 @@ class FirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
val baseName = qualifiedName val baseName = qualifiedName
var disambiguatedName = baseName var disambiguatedName = baseName
var counter = 1 var counter = 1
while(!dumpedModules.add(disambiguatedName)) { while (!dumpedModules.add(disambiguatedName)) {
disambiguatedName = "$baseName.${counter++}" disambiguatedName = "$baseName.${counter++}"
} }
return disambiguatedName return disambiguatedName
} }
private fun dumpFirHtml(disambiguatedName: String, moduleData: ModuleData, firFiles: List<FirFile>) { private fun dumpFirHtml(disambiguatedName: String, firFiles: List<FirFile>) {
if (!DUMP_FIR) return if (!DUMP_FIR) return
dump.module(disambiguatedName) { dump.module(disambiguatedName) {
firFiles.forEach(dump::indexFile) firFiles.forEach(dump::indexFile)
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.fir
import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.Disposer
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY 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.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
@@ -27,9 +27,7 @@ class NonFirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
private val times = mutableListOf<Long>() private val times = mutableListOf<Long>()
private fun runAnalysis(moduleData: ModuleData, environment: KotlinCoreEnvironment) { private fun runAnalysis(environment: KotlinCoreEnvironment) {
val project = environment.project
val time = measureNanoTime { val time = measureNanoTime {
try { try {
KotlinToJVMBytecodeCompiler.analyze(environment) KotlinToJVMBytecodeCompiler.analyze(environment)
@@ -98,7 +96,7 @@ class NonFirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
}) })
val environment = KotlinCoreEnvironment.createForTests(disposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES) val environment = KotlinCoreEnvironment.createForTests(disposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
runAnalysis(moduleData, environment) runAnalysis(environment)
Disposer.dispose(disposable) Disposer.dispose(disposable)
return ProcessorAction.NEXT return ProcessorAction.NEXT
@@ -122,4 +120,4 @@ class NonFirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
val bestPass = times.indexOf(bestTime) val bestPass = times.indexOf(bestTime)
dumpTime("Best pass: $bestPass", 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.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.CallableId 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.symbols.impl.*
import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.builder.* import org.jetbrains.kotlin.fir.types.builder.*
@@ -1540,7 +1541,7 @@ class DeclarationsConverter(
origin = FirDeclarationOrigin.Synthetic origin = FirDeclarationOrigin.Synthetic
name = delegateName name = delegateName
returnTypeRef = firTypeRef returnTypeRef = firTypeRef
symbol = FirFieldSymbol(CallableId(name)) symbol = FirFieldSymbol(@OptIn(LocalCallableIdConstructor::class) CallableId(name))
isVar = false isVar = false
status = FirDeclarationStatusImpl(Visibilities.Local, Modality.FINAL) 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.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.CallableId 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.symbols.impl.*
import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.builder.* import org.jetbrains.kotlin.fir.types.builder.*
@@ -559,7 +560,7 @@ class RawFirBuilder(
origin = FirDeclarationOrigin.Synthetic origin = FirDeclarationOrigin.Synthetic
name = delegateName name = delegateName
returnTypeRef = type returnTypeRef = type
symbol = FirFieldSymbol(CallableId(name)) symbol = FirFieldSymbol(@OptIn(LocalCallableIdConstructor::class) CallableId(name))
isVar = false isVar = false
status = FirDeclarationStatusImpl(Visibilities.Local, Modality.FINAL) 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.builder.*
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
import org.jetbrains.kotlin.fir.symbols.CallableId 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.symbols.impl.*
import org.jetbrains.kotlin.fir.types.ConeClassLikeType import org.jetbrains.kotlin.fir.types.ConeClassLikeType
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
@@ -116,7 +117,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
else else
result.child(Name.identifier(firFunctionTarget.labelName!!)) 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 == FqName.ROOT -> CallableId(context.packageFqName, name)
context.className.shortName() == ANONYMOUS_OBJECT_NAME -> CallableId(ANONYMOUS_CLASS_ID, 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.diagnostics.ConeDiagnostic
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.symbols.CallableId 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.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
open class FirVariableSymbol<D : FirVariable<D>>(override val callableId: CallableId) : FirCallableSymbol<D>() { open class FirVariableSymbol<D : FirVariable<D>>(override val callableId: CallableId) : FirCallableSymbol<D>() {
constructor(name: Name) : this(@OptIn(LocalCallableIdConstructor::class) CallableId(name)) // TODO?
constructor(name: Name) : this(CallableId(name)) // TODO?
} }
open class FirPropertySymbol( open class FirPropertySymbol(
callableId: CallableId, callableId: CallableId,
) : FirVariableSymbol<FirProperty>(callableId) { ) : FirVariableSymbol<FirProperty>(callableId) {
// TODO: should we use this constructor for local variables? // 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) class FirBackingFieldSymbol(callableId: CallableId) : FirVariableSymbol<FirProperty>(callableId)
@@ -17,7 +17,7 @@ class ActualDiagnostic constructor(val diagnostic: Diagnostic, override val plat
TextDiagnostic.InferenceCompatibility.OLD TextDiagnostic.InferenceCompatibility.OLD
override val name: String override val name: String
get() = diagnostic.factory.name!! get() = diagnostic.factory.name
val file: PsiFile val file: PsiFile
get() = diagnostic.psiFile get() = diagnostic.psiFile
@@ -205,7 +205,7 @@ object DebugInfoUtil {
} }
abstract class DebugInfoReporter { abstract class DebugInfoReporter {
fun preProcessReference(expression: KtReferenceExpression) { fun preProcessReference(@Suppress("UNUSED_PARAMETER") expression: KtReferenceExpression) {
// do nothing // do nothing
} }
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.diagnostics;
import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import kotlin.DeprecationLevel;
import java.util.List; import java.util.List;
@@ -43,6 +44,7 @@ public abstract class DiagnosticFactoryWithPsiElement<E extends PsiElement, D ex
@SuppressWarnings("MethodOverloadsMethodOfSuperclass") @SuppressWarnings("MethodOverloadsMethodOfSuperclass")
@Deprecated @Deprecated
@kotlin.Deprecated(message = "Use `cast` from the superclass.", level = DeprecationLevel.HIDDEN)
// ABI-compatibility only (used in Android plugin) // ABI-compatibility only (used in Android plugin)
public D cast(Diagnostic d) { public D cast(Diagnostic d) {
return super.cast(d); return super.cast(d);
@@ -164,7 +164,7 @@ abstract class KotlinSuppressCache {
companion object { companion object {
private fun getDiagnosticSuppressKey(diagnostic: Diagnostic): String = 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 = private fun isSuppressedByStrings(key: String, strings: Set<String>, severity: Severity): Boolean =
severity == Severity.WARNING && "warnings" in strings || key in strings severity == Severity.WARNING && "warnings" in strings || key in strings
@@ -447,7 +447,7 @@ class LocalDeclarationsLowering(
} }
override fun visitDeclaration(declaration: IrDeclarationBase): IrStatement { override fun visitDeclaration(declaration: IrDeclarationBase): IrStatement {
if (declaration is IrSymbolOwner && declaration in transformedDeclarations) { if (declaration in transformedDeclarations) {
TODO() TODO()
} }
return super.visitDeclaration(declaration) return super.visitDeclaration(declaration)
@@ -458,17 +458,15 @@ class EnumSyntheticFunctionsLowering(val context: JsCommonBackendContext) : Decl
private val IrClass.initEntryInstancesFun: IrSimpleFunction? by context.mapping.enumClassToInitEntryInstancesFun private val IrClass.initEntryInstancesFun: IrSimpleFunction? by context.mapping.enumClassToInitEntryInstancesFun
override fun transformFlat(declaration: IrDeclaration): List<IrDeclaration>? { override fun transformFlat(declaration: IrDeclaration): List<IrDeclaration>? {
if (declaration is IrConstructor && declaration.isPrimary) { if (declaration is IrConstructor && declaration.isPrimary && declaration.parentEnumClassOrNull != null &&
declaration.parentEnumClassOrNull?.let { enumClass -> declaration.parentClassOrNull?.isCompanion == true
if (declaration.parentClassOrNull?.isCompanion == true) { ) {
(declaration.body as? IrSyntheticBody)?.let { originalBody -> (declaration.body as? IrSyntheticBody)?.let { originalBody ->
declaration.parentEnumClassOrNull?.let { enumClass -> declaration.parentEnumClassOrNull?.let { enumClass ->
declaration.body = context.irFactory.createBlockBody(UNDEFINED_OFFSET, UNDEFINED_OFFSET) { declaration.body = context.irFactory.createBlockBody(UNDEFINED_OFFSET, UNDEFINED_OFFSET) {
statements += context.createIrBuilder(declaration.symbol).irBlockBody { statements += context.createIrBuilder(declaration.symbol).irBlockBody {
+irCall(enumClass.initEntryInstancesFun!!.symbol) +irCall(enumClass.initEntryInstancesFun!!.symbol)
}.statements + originalBody.statements }.statements + originalBody.statements
}
}
} }
} }
} }
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.ir.util.*
class InvokeStaticInitializersLowering(val context: JsIrBackendContext) : BodyLoweringPass { class InvokeStaticInitializersLowering(val context: JsIrBackendContext) : BodyLoweringPass {
override fun lower(irBody: IrBody, container: IrDeclaration) { override fun lower(irBody: IrBody, container: IrDeclaration) {
if (container !is IrConstructor) return if (container !is IrConstructor) return
if (container?.parentClassOrNull?.isEnumClass == true) return if (container.parentClassOrNull?.isEnumClass == true) return
val irClass = container.constructedClass val irClass = container.constructedClass
if (irClass.isEffectivelyExternal()) { if (irClass.isEffectivelyExternal()) {
@@ -32,4 +32,4 @@ class InvokeStaticInitializersLowering(val context: JsIrBackendContext) : BodyLo
(irBody as IrStatementContainer).statements.add(0, getInstanceCall) (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.IrLoop
import org.jetbrains.kotlin.ir.expressions.IrWhen import org.jetbrains.kotlin.ir.expressions.IrWhen
import org.jetbrains.kotlin.ir.types.isUnit 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.IrElementVisitorVoid
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
import org.jetbrains.kotlin.ir.visitors.acceptVoid import org.jetbrains.kotlin.ir.visitors.acceptVoid
@@ -370,7 +373,7 @@ class NameTables(
} }
override fun visitDeclaration(declaration: IrDeclarationBase) { override fun visitDeclaration(declaration: IrDeclarationBase) {
if (declaration is IrDeclarationWithName && declaration is IrSymbolOwner) { if (declaration is IrDeclarationWithName) {
table.declareFreshName(declaration, declaration.name.asString()) table.declareFreshName(declaration, declaration.name.asString())
} }
super.visitDeclaration(declaration) 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.*
import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol 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.symbols.IrValueParameterSymbol
import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.* 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.Name
import org.jetbrains.kotlin.name.SpecialNames import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.resolve.jvm.AsmTypes import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.Type
internal val suspendLambdaPhase = makeIrFilePhase( internal val suspendLambdaPhase = makeIrFilePhase(
@@ -225,14 +223,14 @@ private class SuspendLambdaLowering(context: JvmBackendContext) : SuspendLowerin
private fun IrClass.addInvokeSuspendForLambda( private fun IrClass.addInvokeSuspendForLambda(
irFunction: IrFunction, irFunction: IrFunction,
suspendLambda: IrClass, suspendLambda: IrClass,
fields: List<ParameterInfo> parameterInfos: List<ParameterInfo>
): IrSimpleFunction { ): IrSimpleFunction {
val superMethod = suspendLambda.functions.single { val superMethod = suspendLambda.functions.single {
it.name.asString() == INVOKE_SUSPEND_METHOD_NAME && it.valueParameters.size == 1 && it.name.asString() == INVOKE_SUSPEND_METHOD_NAME && it.valueParameters.size == 1 &&
it.valueParameters[0].type.isKotlinResult() it.valueParameters[0].type.isKotlinResult()
} }
return addFunctionOverride(superMethod, irFunction.startOffset, irFunction.endOffset).apply { 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) { if (param.isUsed) {
buildVariable( buildVariable(
parent = this, parent = this,
@@ -139,7 +139,7 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV
val wasmGcType: WasmSymbol<WasmTypeDeclaration> = context.referenceGcType(klass.symbol) 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" } require(expression.valueArgumentsCount == 1) { "@WasmArrayOf constructs must have exactly one argument" }
generateExpression(expression.getValueArgument(0)!!) generateExpression(expression.getValueArgument(0)!!)
body.buildRttCanon(context.transformType(klass.defaultType)) 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.ir.util.parentAsClass
import org.jetbrains.kotlin.wasm.ir.* import org.jetbrains.kotlin.wasm.ir.*
class WasmModuleCodegenContextImpl( class WasmModuleCodegenContextImpl(
override val backendContext: WasmBackendContext, override val backendContext: WasmBackendContext,
private val wasmFragment: WasmCompiledModuleFragment private val wasmFragment: WasmCompiledModuleFragment
@@ -100,8 +99,8 @@ class WasmModuleCodegenContextImpl(
wasmFragment.globals.define(irField, wasmGlobal) wasmFragment.globals.define(irField, wasmGlobal)
} }
override fun defineGcType(irClass: IrClassSymbol, wasmStruct: WasmTypeDeclaration) { override fun defineGcType(irClass: IrClassSymbol, wasmType: WasmTypeDeclaration) {
wasmFragment.gcTypes.define(irClass, wasmStruct) wasmFragment.gcTypes.define(irClass, wasmType)
} }
override fun defineRTT(irClass: IrClassSymbol, wasmGlobal: WasmGlobal) { override fun defineRTT(irClass: IrClassSymbol, wasmGlobal: WasmGlobal) {
@@ -1251,9 +1251,7 @@ open class IrFileSerializer(
if (backendSpecificExplicitRoot(file)) { if (backendSpecificExplicitRoot(file)) {
for (declaration in file.declarations) { for (declaration in file.declarations) {
if (declaration is IrSymbolOwner) { proto.addExplicitlyExportedToCompiler(serializeIrSymbol(declaration.symbol))
proto.addExplicitlyExportedToCompiler(serializeIrSymbol(declaration.symbol))
}
} }
} else { } else {
file.acceptVoid( 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? { 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) return PsiTreeUtil.getParentOfType(this, T::class.java, strict, *stopAt)
} }
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.codeMetaInfo.renderConfigurations package org.jetbrains.kotlin.codeMetaInfo.renderConfigurations
import com.intellij.util.containers.ContainerUtil
import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFactory1 import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFactory1
import org.jetbrains.kotlin.codeMetaInfo.model.CodeMetaInfo import org.jetbrains.kotlin.codeMetaInfo.model.CodeMetaInfo
import org.jetbrains.kotlin.codeMetaInfo.model.DiagnosticCodeMetaInfo import org.jetbrains.kotlin.codeMetaInfo.model.DiagnosticCodeMetaInfo
@@ -39,8 +38,7 @@ open class DiagnosticCodeMetaInfoRenderConfiguration(
else -> DefaultErrorMessages.getRendererForDiagnostic(codeMetaInfo.diagnostic) else -> DefaultErrorMessages.getRendererForDiagnostic(codeMetaInfo.diagnostic)
} }
if (renderer is AbstractDiagnosticWithParametersRenderer) { if (renderer is AbstractDiagnosticWithParametersRenderer) {
val renderParameters = renderer.renderParameters(codeMetaInfo.diagnostic) renderer.renderParameters(codeMetaInfo.diagnostic).mapTo(params, Any::toString)
params.addAll(ContainerUtil.map(renderParameters) { it.toString() })
} }
if (renderSeverity) if (renderSeverity)
params.add("severity='${codeMetaInfo.diagnostic.severity}'") params.add("severity='${codeMetaInfo.diagnostic.severity}'")
@@ -75,9 +75,7 @@ object Conditions {
fun <T> not(c: Condition<T>): Condition<T> { fun <T> not(c: Condition<T>): Condition<T> {
if (c === alwaysTrue<Any>()) return alwaysFalse() if (c === alwaysTrue<Any>()) return alwaysFalse()
if (c === alwaysFalse<Any>()) return alwaysTrue() if (c === alwaysFalse<Any>()) return alwaysTrue()
return if (c is Not<*>) { return if (c is Not<*>) (c as Not<T>).c else Not(c)
(c as Not<T>).c as Condition<T>
} else Not(c)
} }
fun <T> and(c1: Condition<T>, c2: Condition<T>): Condition<T> { fun <T> and(c1: Condition<T>, c2: Condition<T>): Condition<T> {
@@ -44,7 +44,7 @@ object TargetPlatformParser {
return runIf(platformString == JS) { JsPlatforms.DefaultSimpleJsPlatform } 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 // TODO: support native platforms
return null return null
} }
@@ -86,13 +86,13 @@ class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testSe
private fun callBoxMethodAndCheckResult( private fun callBoxMethodAndCheckResult(
classLoader: URLClassLoader, classLoader: URLClassLoader,
clazz: Class<*>?, @Suppress("UNUSED_PARAMETER") clazz: Class<*>?,
method: Method, method: Method,
unexpectedBehaviour: Boolean unexpectedBehaviour: Boolean
) { ) {
val result = if (BOX_IN_SEPARATE_PROCESS_PORT != null) { val result = if (BOX_IN_SEPARATE_PROCESS_PORT != null) {
TODO() TODO()
// result = invokeBoxInSeparateProcess(classLoader, aClass) // result = invokeBoxInSeparateProcess(classLoader, clazz)
} else { } else {
val savedClassLoader = Thread.currentThread().contextClassLoader val savedClassLoader = Thread.currentThread().contextClassLoader
if (savedClassLoader !== classLoader) { if (savedClassLoader !== classLoader) {
@@ -30,7 +30,7 @@ class ClassicFrontend2IrConverter(
module: TestModule, module: TestModule,
inputArtifact: ClassicFrontendOutputArtifact inputArtifact: ClassicFrontendOutputArtifact
): IrBackendInput { ): IrBackendInput {
val (psiFiles, analysisResult, project, languageVersionSettings) = inputArtifact val (psiFiles, analysisResult, project, _) = inputArtifact
val configuration = testServices.compilerConfigurationProvider.getCompilerConfiguration(module) val configuration = testServices.compilerConfigurationProvider.getCompilerConfiguration(module)
@@ -73,6 +73,7 @@ class FirDiagnosticCodeMetaRenderConfiguration(
val diagnostic = codeMetaInfo.diagnostic val diagnostic = codeMetaInfo.diagnostic
@Suppress("UNCHECKED_CAST")
val renderer = FirDefaultErrorMessages.getRendererForDiagnostic(diagnostic) as FirDiagnosticRenderer<FirDiagnostic<*>> val renderer = FirDefaultErrorMessages.getRendererForDiagnostic(diagnostic) as FirDiagnosticRenderer<FirDiagnostic<*>>
params.add(renderer.render(diagnostic)) params.add(renderer.render(diagnostic))
@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.checkers package org.jetbrains.kotlin.checkers
import com.google.common.collect.Lists import com.google.common.collect.Lists
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiFile import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.ObsoleteTestInfrastructure import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.checkers.diagnostics.ActualDiagnostic 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 missing(data: DiagnosticData) = missing(data.name, data.startOffset, data.endOffset)
private fun asTextDiagnostic(diagnosticData: DiagnosticData, vararg params: String) = private fun asTextDiagnostic(diagnosticData: DiagnosticData, vararg params: String): String =
diagnosticData.name + "(" + StringUtil.join(params, "; ") + ")" params.joinToString(prefix = diagnosticData.name + "(", postfix = ")", separator = "; ")
private fun asDiagnosticRange(diagnosticData: DiagnosticData, vararg textDiagnostics: String): DiagnosedRange { private fun asDiagnosticRange(diagnosticData: DiagnosticData, vararg textDiagnostics: String): DiagnosedRange {
val range = DiagnosedRange(diagnosticData.startOffset) val range = DiagnosedRange(diagnosticData.startOffset)
@@ -205,7 +205,7 @@ abstract class AbstractFirDiagnosticsTest : AbstractFirBaseDiagnosticsTest() {
// Lambda argument is always (?) duplicated by function literal // Lambda argument is always (?) duplicated by function literal
// Block expression is always (?) duplicated by single block expression // Block expression is always (?) duplicated by single block expression
if (sourceElement.elementType == KtNodeTypes.LAMBDA_ARGUMENT || sourceElement.elementType == KtNodeTypes.BLOCK) return null 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 if (diagnosedRangesToDiagnosticNames[sourceElement.startOffset..sourceElement.endOffset]?.contains(name) != true) return null
val argumentText = argument() val argumentText = argument()
@@ -184,12 +184,10 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
@OptIn(ObsoleteDescriptorBasedAPI::class) @OptIn(ObsoleteDescriptorBasedAPI::class)
override fun visitDeclaration(declaration: IrDeclarationBase) { override fun visitDeclaration(declaration: IrDeclarationBase) {
if (declaration is IrSymbolOwner) { declaration.symbol.checkBinding("decl", declaration)
declaration.symbol.checkBinding("decl", declaration)
require(declaration.symbol.owner == declaration) { require(declaration.symbol.owner == declaration) {
"Symbol is not bound to declaration: ${declaration.render()}" "Symbol is not bound to declaration: ${declaration.render()}"
}
} }
val containingDeclarationDescriptor = declaration.descriptor.containingDeclaration val containingDeclarationDescriptor = declaration.descriptor.containingDeclaration
@@ -31,7 +31,7 @@ class SpecTestsConsistencyTest : TestCase() {
@com.intellij.testFramework.Parameterized.Parameters(name = "{0}") @com.intellij.testFramework.Parameterized.Parameters(name = "{0}")
@JvmStatic @JvmStatic
fun getTestFiles(klass: Class<*>): List<Array<String>> { fun getTestFiles(@Suppress("UNUSED_PARAMETER") klass: Class<*>): List<Array<String>> {
val testFiles = mutableListOf<Array<String>>() val testFiles = mutableListOf<Array<String>>()
TestArea.values().forEach { testArea -> TestArea.values().forEach { testArea ->
@@ -58,10 +58,10 @@ fun notLinkedSpecTestsPrint() {
} }
} }
fun main(args: Array<String>) { fun main() {
println("==================================================") println("==================================================")
linkedSpecTestsPrint() linkedSpecTestsPrint()
println("==================================================") println("==================================================")
notLinkedSpecTestsPrint() notLinkedSpecTestsPrint()
println("==================================================") println("==================================================")
} }
@@ -52,7 +52,7 @@ class DiagnosticTestTypeValidator(
private fun collectDiagnostics(files: List<BaseDiagnosticsTest.TestFile>) { private fun collectDiagnostics(files: List<BaseDiagnosticsTest.TestFile>) {
files.forEach { file -> files.forEach { file ->
file.actualDiagnostics.forEach { file.actualDiagnostics.forEach {
val diagnosticName = it.diagnostic.factory.name!! val diagnosticName = it.diagnostic.factory.name
diagnosticStats.run { put(diagnosticName, getOrDefault(diagnosticName, 0) + 1) } diagnosticStats.run { put(diagnosticName, getOrDefault(diagnosticName, 0) + 1) }
diagnostics.add(it.diagnostic) diagnostics.add(it.diagnostic)
} }
@@ -68,4 +68,4 @@ class DiagnosticTestTypeValidator(
val diagnostics = if (diagnosticStats.isNotEmpty()) "$diagnosticSeverityStats | $diagnosticStats" else "does not contain" val diagnostics = if (diagnosticStats.isNotEmpty()) "$diagnosticSeverityStats | $diagnosticStats" else "does not contain"
println("DIAGNOSTICS: $diagnostics") println("DIAGNOSTICS: $diagnostics")
} }
} }
@@ -146,6 +146,7 @@ public expect fun Throwable.printStackTrace(): Unit
* suppressed in order to deliver this exception. * suppressed in order to deliver this exception.
*/ */
@SinceKotlin("1.4") @SinceKotlin("1.4")
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
public expect fun Throwable.addSuppressed(exception: Throwable) 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. * - if this [Throwable] instance has disabled the suppression.
*/ */
@SinceKotlin("1.4") @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 * Adding and removing the annotation is binary incompatible change, since inline classes' methods and functions with inline classes
* in their signature are mangled. * in their signature are mangled.
*/ */
@Suppress("NEWER_VERSION_IN_SINCE_KOTLIN")
@Target(CLASS) @Target(CLASS)
@MustBeDocumented @MustBeDocumented
@SinceKotlin("1.5") @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 * 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) @Target(AnnotationTarget.CLASS)
@MustBeDocumented @MustBeDocumented
@OptionalExpectation @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 * Adding and removing the annotation is binary incompatible change, since inline classes' methods and functions with inline classes
* in their signature are mangled. * in their signature are mangled.
*/ */
@Suppress("NEWER_VERSION_IN_SINCE_KOTLIN")
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME) @Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented @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 * 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) @Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE) @Retention(AnnotationRetention.SOURCE)
@MustBeDocumented @MustBeDocumented
@@ -34,9 +34,9 @@ abstract class AbstractAndroidBytecodeShapeTest : AbstractBytecodeTextTest() {
addAndroidExtensionsRuntimeLibrary(myEnvironment) addAndroidExtensionsRuntimeLibrary(myEnvironment)
} }
override fun doTest(path: String) { override fun doTest(filePath: String) {
val fileName = path + getTestName(true) + ".kt" val fileName = filePath + getTestName(true) + ".kt"
createAndroidAPIEnvironment(path) createAndroidAPIEnvironment(filePath)
loadFileByFullPath(fileName) loadFileByFullPath(fileName)
val expected = readExpectedOccurrences(fileName) val expected = readExpectedOccurrences(fileName)
val actual = generateToText() val actual = generateToText()
@@ -8,7 +8,8 @@ package org.jetbrains.kotlin.importsDumper
import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtil
import com.intellij.testFramework.TestDataPath import com.intellij.testFramework.TestDataPath
import junit.framework.TestCase 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.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestCaseWithTmpdir import org.jetbrains.kotlin.test.TestCaseWithTmpdir
@@ -58,7 +59,8 @@ class ImportsDumperTest : TestCaseWithTmpdir() {
tmpDir.path, tmpDir.path,
"-Xplugin=${importsDumperJarInDist.path}", "-Xplugin=${importsDumperJarInDist.path}",
"-P", "-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 @Test
fun testParameterNames() { 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 user = roundEnv.getElementsAnnotatedWith(set.single()).single() as TypeElement
val nameField = user.enclosedElements.filterIsInstance<VariableElement>().single() val nameField = user.enclosedElements.filterIsInstance<VariableElement>().single()
assertEquals("John", nameField.constantValue) assertEquals("John", nameField.constantValue)
@@ -14,5 +14,7 @@ private const val BUNDLE = "messages.KotlinParcelizeBundle"
object KotlinParcelizeBundle : AbstractKotlinBundle(BUNDLE) { object KotlinParcelizeBundle : AbstractKotlinBundle(BUNDLE) {
@JvmStatic @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 org.junit.Assert
import java.io.File import java.io.File
import kotlin.script.experimental.annotations.KotlinScript 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.host.toScriptSource
import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration
import kotlin.script.experimental.jvmhost.createJvmScriptDefinitionFromTemplate import kotlin.script.experimental.jvmhost.createJvmScriptDefinitionFromTemplate
@@ -52,7 +55,7 @@ abstract class AbstractSamWithReceiverScriptNewDefTest : AbstractDiagnosticsTest
override fun analyzeAndCheck(testDataFile: File, files: List<TestFile>) { override fun analyzeAndCheck(testDataFile: File, files: List<TestFile>) {
val definition = createJvmScriptDefinitionFromTemplate<ScriptForSamWithReceiversNewDef>() val definition = createJvmScriptDefinitionFromTemplate<ScriptForSamWithReceiversNewDef>()
val scriptCompiler = ScriptJvmCompilerFromEnvironment(environment) val scriptCompiler = ScriptJvmCompilerFromEnvironment(environment)
val (scripts, regular) = files.partition { val scripts = files.filter {
it.ktFile?.virtualFile?.extension == definition.compilationConfiguration[ScriptCompilationConfiguration.fileExtension] it.ktFile?.virtualFile?.extension == definition.compilationConfiguration[ScriptCompilationConfiguration.fileExtension]
} }
super.analyzeAndCheck(testDataFile, files) super.analyzeAndCheck(testDataFile, files)
@@ -327,7 +327,7 @@ class JvmIdeServicesTest : TestCase() {
private data class CliCompilationResult(val exitCode: ExitCode, val outputJarPath: String) private data class CliCompilationResult(val exitCode: ExitCode, val outputJarPath: String)
private fun compileFile(inputKtFileName: String, outputJarName: String): CliCompilationResult { 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( val compilerArgs = arrayOf(
"$MODULE_PATH/testData/$inputKtFileName", "$MODULE_PATH/testData/$inputKtFileName",