Drop redundant Suppress("RemoveExplicitTypeArguments")

This commit is contained in:
Mikhail Glukhikh
2022-01-25 10:57:53 +03:00
committed by Space
parent 02d74fbd87
commit ad0d0ca47f
13 changed files with 18 additions and 35 deletions
@@ -507,8 +507,7 @@ internal class KtSymbolByFirBuilder private constructor(
val containingClass = getContainingClass(rootSession) ?: return null val containingClass = getContainingClass(rootSession) ?: return null
val originalDeclaration = originalForSubstitutionOverride ?: return null val originalDeclaration = originalForSubstitutionOverride ?: return null
@Suppress("RemoveExplicitTypeArguments") val allowedTypeParameters = buildSet {
val allowedTypeParameters = buildSet<ConeTypeParameterLookupTag> {
// declaration's own parameters // declaration's own parameters
originalDeclaration.typeParameters.mapTo(this) { it.symbol.toLookupTag() } originalDeclaration.typeParameters.mapTo(this) { it.symbol.toLookupTag() }
@@ -31,7 +31,7 @@ abstract class AbstractCollectDiagnosticsTest : AbstractHLApiSingleFileTest() {
analyseForTest(ktFile) { analyseForTest(ktFile) {
val diagnosticsInFile = val diagnosticsInFile =
ktFile.collectDiagnosticsForFile(KtDiagnosticCheckerFilter.EXTENDED_AND_COMMON_CHECKERS).map { it.getKey() }.sorted() ktFile.collectDiagnosticsForFile(KtDiagnosticCheckerFilter.EXTENDED_AND_COMMON_CHECKERS).map { it.getKey() }.sorted()
@Suppress("RemoveExplicitTypeArguments") val diagnosticsFromElements = buildList<Pair<KtElement, DiagnosticKey>> { val diagnosticsFromElements = buildList {
ktFile.accept(object : KtTreeVisitorVoid() { ktFile.accept(object : KtTreeVisitorVoid() {
override fun visitKtElement(element: KtElement) { override fun visitKtElement(element: KtElement) {
for (diagnostic in element.getDiagnostics(KtDiagnosticCheckerFilter.EXTENDED_AND_COMMON_CHECKERS)) { for (diagnostic in element.getDiagnostics(KtDiagnosticCheckerFilter.EXTENDED_AND_COMMON_CHECKERS)) {
@@ -58,8 +58,7 @@ object AbstractTypeMapper {
val argumentsCount = type.argumentsCount() val argumentsCount = type.argumentsCount()
val argumentsList = type.asArgumentList() val argumentsList = type.asArgumentList()
@Suppress("RemoveExplicitTypeArguments") // Workaround for KT-42175 val arguments = buildList {
val arguments = buildList<KotlinTypeMarker> {
for (i in 0 until (argumentsCount - 1)) { for (i in 0 until (argumentsCount - 1)) {
this += argumentsList[i].adjustedType() this += argumentsList[i].adjustedType()
} }
@@ -203,12 +203,11 @@ internal class MethodNodeExaminer(
for (index in insns.indices.reversed()) { for (index in insns.indices.reversed()) {
if (insns[index].opcode == Opcodes.ARETURN) continue if (insns[index].opcode == Opcodes.ARETURN) continue
@Suppress("RemoveExplicitTypeArguments")
val newResult = val newResult =
controlFlowGraph controlFlowGraph
.getSuccessorsIndices(index).plus(index) .getSuccessorsIndices(index).plus(index)
.map(reachableReturnsIndices::get) .map(reachableReturnsIndices::get)
.fold<Set<Int>?, Set<Int>?>(mutableSetOf<Int>()) { acc, successorsResult -> .fold<Set<Int>?, Set<Int>?>(mutableSetOf()) { acc, successorsResult ->
if (acc != null && successorsResult != null) acc + successorsResult else null if (acc != null && successorsResult != null) acc + successorsResult else null
} }
@@ -125,7 +125,6 @@ class FirStatusResolver(
return emptyList() return emptyList()
} }
@Suppress("RemoveExplicitTypeArguments") // Workaround for KT-42175
return buildList<FirCallableDeclaration> { return buildList<FirCallableDeclaration> {
val scope = containingClass.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = false) val scope = containingClass.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = false)
val symbol = function.symbol val symbol = function.symbol
@@ -36,16 +36,15 @@ fun <F : FirClassLikeDeclaration> F.runTypeResolvePhaseForLocalClass(
useSiteFile: FirFile, useSiteFile: FirFile,
containingDeclarations: List<FirDeclaration>, containingDeclarations: List<FirDeclaration>,
): F { ): F {
@Suppress("RemoveExplicitTypeArguments")
val transformer = FirTypeResolveTransformer( val transformer = FirTypeResolveTransformer(
session, session,
scopeSession, scopeSession,
currentScopeList, currentScopeList,
initialCurrentFile = useSiteFile, initialCurrentFile = useSiteFile,
classDeclarationsStack = containingDeclarations.filterIsInstanceTo<FirClass, ArrayDeque<FirClass>>(ArrayDeque()) classDeclarationsStack = containingDeclarations.filterIsInstanceTo(ArrayDeque())
) )
return this.transform<F, Nothing?>(transformer, null) return this.transform(transformer, null)
} }
open class FirTypeResolveTransformer( open class FirTypeResolveTransformer(
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.ir.util.resolveFakeOverride import org.jetbrains.kotlin.ir.util.resolveFakeOverride
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
@Suppress("RemoveExplicitTypeArguments")
internal val resolveInlineCallsPhase = makeIrModulePhase( internal val resolveInlineCallsPhase = makeIrModulePhase(
::ResolveInlineCalls, ::ResolveInlineCalls,
name = "ResolveInlineCalls", name = "ResolveInlineCalls",
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.config.ExplicitApiMode
import org.jetbrains.kotlin.config.JvmDefaultMode import org.jetbrains.kotlin.config.JvmDefaultMode
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
@Suppress("RemoveExplicitTypeArguments")
object LanguageSettingsDirectives : SimpleDirectivesContainer() { object LanguageSettingsDirectives : SimpleDirectivesContainer() {
val LANGUAGE by stringDirective( val LANGUAGE by stringDirective(
description = """ description = """
@@ -20,7 +19,6 @@ object LanguageSettingsDirectives : SimpleDirectivesContainer() {
""".trimIndent() """.trimIndent()
) )
@Suppress("RemoveExplicitTypeArguments")
val API_VERSION by valueDirective<ApiVersion>( val API_VERSION by valueDirective<ApiVersion>(
description = "Version of Kotlin API", description = "Version of Kotlin API",
parser = this::parseApiVersion parser = this::parseApiVersion
@@ -43,7 +41,7 @@ object LanguageSettingsDirectives : SimpleDirectivesContainer() {
description = "Allow using Result in return type position" description = "Allow using Result in return type position"
) )
val EXPLICIT_API_MODE by enumDirective<ExplicitApiMode>( val EXPLICIT_API_MODE by enumDirective(
"Configures explicit API mode (AnalysisFlags.explicitApiMode)", "Configures explicit API mode (AnalysisFlags.explicitApiMode)",
additionalParser = ExplicitApiMode.Companion::fromString additionalParser = ExplicitApiMode.Companion::fromString
) )
@@ -54,7 +52,7 @@ object LanguageSettingsDirectives : SimpleDirectivesContainer() {
// --------------------- Jvm Analysis Flags --------------------- // --------------------- Jvm Analysis Flags ---------------------
val JVM_DEFAULT_MODE by enumDirective<JvmDefaultMode>( val JVM_DEFAULT_MODE by enumDirective(
description = "Configures corresponding analysis flag (JvmAnalysisFlags.jvmDefaultMode)", description = "Configures corresponding analysis flag (JvmAnalysisFlags.jvmDefaultMode)",
additionalParser = JvmDefaultMode.Companion::fromStringOrNull additionalParser = JvmDefaultMode.Companion::fromStringOrNull
) )
@@ -11,14 +11,13 @@ import org.jetbrains.kotlin.test.services.configuration.JavaForeignAnnotationTyp
import org.jetbrains.kotlin.load.java.ReportLevel import org.jetbrains.kotlin.load.java.ReportLevel
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
@Suppress("RemoveExplicitTypeArguments")
object ForeignAnnotationsDirectives : SimpleDirectivesContainer() { object ForeignAnnotationsDirectives : SimpleDirectivesContainer() {
val JSR305_GLOBAL_REPORT by enumDirective<ReportLevel>( val JSR305_GLOBAL_REPORT by enumDirective(
description = "Global report level", description = "Global report level",
additionalParser = ReportLevel.Companion::findByDescription additionalParser = ReportLevel.Companion::findByDescription
) )
val JSR305_MIGRATION_REPORT by enumDirective<ReportLevel>( val JSR305_MIGRATION_REPORT by enumDirective(
description = "Migration report level", description = "Migration report level",
additionalParser = ReportLevel.Companion::findByDescription additionalParser = ReportLevel.Companion::findByDescription
) )
@@ -27,7 +26,7 @@ object ForeignAnnotationsDirectives : SimpleDirectivesContainer() {
description = "Report level for specific annotations" description = "Report level for specific annotations"
) )
val JSPECIFY_STATE by enumDirective<ReportLevel>( val JSPECIFY_STATE by enumDirective(
description = "Report level for jSpecify annotations", description = "Report level for jSpecify annotations",
additionalParser = ReportLevel.Companion::findByDescription additionalParser = ReportLevel.Companion::findByDescription
) )
@@ -12,8 +12,7 @@ import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
object JvmEnvironmentConfigurationDirectives : SimpleDirectivesContainer() { object JvmEnvironmentConfigurationDirectives : SimpleDirectivesContainer() {
@Suppress("RemoveExplicitTypeArguments") val JVM_TARGET by enumDirective(
val JVM_TARGET by enumDirective<JvmTarget>(
description = "Target bytecode version", description = "Target bytecode version",
additionalParser = JvmTarget.Companion::fromString additionalParser = JvmTarget.Companion::fromString
) )
@@ -50,14 +49,12 @@ object JvmEnvironmentConfigurationDirectives : SimpleDirectivesContainer() {
applicability = DirectiveApplicability.Global applicability = DirectiveApplicability.Global
) )
@Suppress("RemoveExplicitTypeArguments") val STRING_CONCAT by enumDirective(
val STRING_CONCAT by enumDirective<JvmStringConcat>(
description = "Configure mode of string concatenation", description = "Configure mode of string concatenation",
additionalParser = JvmStringConcat.Companion::fromString additionalParser = JvmStringConcat.Companion::fromString
) )
@Suppress("RemoveExplicitTypeArguments") val ASSERTIONS_MODE by enumDirective(
val ASSERTIONS_MODE by enumDirective<JVMAssertionsMode>(
description = "Configure jvm assertions mode", description = "Configure jvm assertions mode",
additionalParser = JVMAssertionsMode.Companion::fromString additionalParser = JVMAssertionsMode.Companion::fromString
) )
@@ -21,8 +21,7 @@ class ServiceLoaderLiteTestWithClassLoader : AbstractServiceLoaderLiteTest() {
inner class InnerComponent : Intf inner class InnerComponent : Intf
fun testClassloader1() { fun testClassloader1() {
@Suppress("RemoveExplicitTypeArguments") val entries = arrayOf(impls(Component1::class, Component2::class), clazz<Component1>(), clazz<Component2>())
val entries = arrayOf(impls<Intf>(Component1::class, Component2::class), clazz<Component1>(), clazz<Component2>())
classLoaderTest("test", *entries) { classLoader -> classLoaderTest("test", *entries) { classLoader ->
val impls = ServiceLoaderLite.loadImplementations<Intf>(classLoader) val impls = ServiceLoaderLite.loadImplementations<Intf>(classLoader)
@@ -62,8 +61,7 @@ class ServiceLoaderLiteTestWithClassLoader : AbstractServiceLoaderLiteTest() {
} }
fun testInterface() { fun testInterface() {
@Suppress("RemoveExplicitTypeArguments") classLoaderTest("test", impls(Intf::class), clazz<Intf>()) { classLoader ->
classLoaderTest("test", impls<Intf>(Intf::class), clazz<Intf>()) { classLoader ->
assertThrows<InstantiationException> { assertThrows<InstantiationException> {
ServiceLoaderLite.loadImplementations<Intf>(classLoader) ServiceLoaderLite.loadImplementations<Intf>(classLoader)
} }
@@ -29,9 +29,8 @@ val ScriptCompilationConfigurationKeys.ide
val IdeScriptCompilationConfigurationKeys.dependenciesSources by PropertiesCollection.key<List<ScriptDependency>>() val IdeScriptCompilationConfigurationKeys.dependenciesSources by PropertiesCollection.key<List<ScriptDependency>>()
@Suppress("RemoveExplicitTypeArguments")
val IdeScriptCompilationConfigurationKeys.acceptedLocations val IdeScriptCompilationConfigurationKeys.acceptedLocations
by PropertiesCollection.key<List<ScriptAcceptedLocation>>( by PropertiesCollection.key(
listOf( listOf(
ScriptAcceptedLocation.Sources, ScriptAcceptedLocation.Sources,
ScriptAcceptedLocation.Tests ScriptAcceptedLocation.Tests
@@ -13,9 +13,7 @@ internal data class NameAndSafeValue(val name: String, val safeValue: String)
internal object SafeEnvVars : Iterable<NameAndSafeValue> { internal object SafeEnvVars : Iterable<NameAndSafeValue> {
private val environment: List<NameAndSafeValue> by lazy { private val environment: List<NameAndSafeValue> by lazy {
// See KT-49925 buildList {
@Suppress("RemoveExplicitTypeArguments")
buildList<NameAndSafeValue> {
System.getenv().forEach { (name, value) -> System.getenv().forEach { (name, value) ->
val safeValue = if (isSafeEnvVar(name)) doEscape(value) else HIDDEN_VALUE val safeValue = if (isSafeEnvVar(name)) doEscape(value) else HIDDEN_VALUE
this += NameAndSafeValue(name, safeValue) this += NameAndSafeValue(name, safeValue)