Skip to content

Commit

Permalink
Fix compile warnings #1
Browse files Browse the repository at this point in the history
  • Loading branch information
dimonchik0036 committed Apr 16, 2019
1 parent a65f50b commit 1f7f201
Show file tree
Hide file tree
Showing 283 changed files with 864 additions and 722 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ open class IncrementalJvmCache(
constantsMap.process(kotlinClass, changesCollector)
inlineFunctionsMap.process(kotlinClass, changesCollector)
}
else -> error("Illegal state")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ open class FrameMapBase<T : Any> {
val descriptors = Lists.newArrayList<Trinity<T, Int, Int>>()

for (descriptor0 in myVarIndex.keys()) {
val descriptor = descriptor0 as T
@Suppress("UNCHECKED_CAST") val descriptor = descriptor0 as T
val varIndex = myVarIndex.get(descriptor)
val varSize = myVarSizes.get(descriptor)
descriptors.add(Trinity.create(descriptor, varIndex, varSize))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ internal fun performRefinedTypeAnalysis(methodNode: MethodNode, thisName: String
override fun use(frame: VarExpectedTypeFrame, insn: AbstractInsnNode) {
val (expectedType, sources) = expectedTypeAndSourcesByInsnIndex[insn.index()] ?: return

sources.flatMap(SourceValue::insns).forEach {
insn ->
if (insn.isIntLoad()) {
frame.updateExpectedType((insn as VarInsnNode).`var`, expectedType)
sources.flatMap(SourceValue::insns).forEach { insnNode ->
if (insnNode.isIntLoad()) {
frame.updateExpectedType((insnNode as VarInsnNode).`var`, expectedType)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
}
}

@Suppress("UNREACHABLE_CODE")
private fun canSkipStackSpillingOnInline(methodNode: MethodNode): Boolean {
// Temporary disable this optimization until
// TODO: Temporary disable this optimization until
// https://issuetracker.google.com/issues/68796377 is fixed
// or until d8 substitute dex
return false

// Stack spilling before inline function 'f' call is required if:
// - 'f' is a suspend function
// - 'f' has try-catch blocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class LocalVarRemapper(private val params: Parameters, private val additionalShi
}

fun visitVarInsn(opcode: Int, `var`: Int, mv: InstructionAdapter) {
var opcode = opcode
@Suppress("NAME_SHADOWING") var opcode = opcode
val remapInfo = remap(`var`)
val value = remapInfo.value
if (value is StackValue.Local) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class InFloatingPointRangeLiteralExpressionGenerator(
// goto jumpLabel
// exitLabel:

frameMap.useTmpVar(operandType) { argVar ->
frameMap.useTmpVar(operandType) { _ ->
val exitLabel = Label()
genJumpIfFalse(v, exitLabel)
v.goTo(jumpLabel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ class GenerationState private constructor(
?.let { destination -> SignatureDumpingBuilderFactory(it, File(destination)) } ?: it
}
)
.wrapWith(ClassBuilderInterceptorExtension.getInstances(project)) { builderFactory, extension ->
extension.interceptClassBuilderFactory(builderFactory, bindingContext, diagnostics)
.wrapWith(ClassBuilderInterceptorExtension.getInstances(project)) { classBuilderFactory, extension ->
extension.interceptClassBuilderFactory(classBuilderFactory, bindingContext, diagnostics)
}

this.factory = ClassFileFactory(this, interceptedBuilderFactory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class LanguageSettingsParser : AbstractInternalArgumentParser<ManualLanguageFeat
return null
}

val colon = tail.getOrNull(0) ?: return reportAndReturnNull("Incorrect internal argument syntax, missing colon: $wholeArgument")
tail.getOrNull(0) ?: return reportAndReturnNull("Incorrect internal argument syntax, missing colon: $wholeArgument")

val modificator = tail.getOrNull(1)
val languageFeatureState = when (modificator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fun setIdeaIoUseFallback() {

properties.setProperty("idea.io.use.nio2", java.lang.Boolean.TRUE.toString())

if (!(SystemInfo.isJavaVersionAtLeast("1.7") && "1.7.0-ea" != SystemInfo.JAVA_VERSION)) {
if (!(SystemInfo.isJavaVersionAtLeast(1, 7, 0) && "1.7.0-ea" != SystemInfo.JAVA_VERSION)) {
properties.setProperty("idea.io.use.fallback", java.lang.Boolean.TRUE.toString())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ open class AggregatedReplStageState<T1, T2>(val state1: IReplStageState<T1>, val
override val history: IReplStageHistory<Pair<T1, T2>> = AggregatedReplStateHistory(state1.history, state2.history, lock)

override fun <StateT : IReplStageState<*>> asState(target: Class<out StateT>): StateT =
when {
target.isAssignableFrom(state1::class.java) -> state1 as StateT
target.isAssignableFrom(state2::class.java) -> state2 as StateT
else -> super.asState(target)
}
@Suppress("UNCHECKED_CAST")
when {
target.isAssignableFrom(state1::class.java) -> state1 as StateT
target.isAssignableFrom(state2::class.java) -> state2 as StateT
else -> super.asState(target)
}

override fun getNextLineNo() = state1.getNextLineNo()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ interface IReplStageState<T> {

fun getNextLineNo(): Int = history.peek()?.id?.no?.let { it + 1 } ?: REPL_CODE_LINE_FIRST_NO // TODO: it should be more robust downstream (e.g. use atomic)

@Suppress("UNCHECKED_CAST")
fun <StateT : IReplStageState<*>> asState(target: Class<out StateT>): StateT =
if (target.isAssignableFrom(this::class.java)) this as StateT
else throw IllegalArgumentException("$this is not an expected instance of IReplStageState")
if (target.isAssignableFrom(this::class.java)) this as StateT
else throw IllegalArgumentException("$this is not an expected instance of IReplStageState")
}


Expand Down
18 changes: 9 additions & 9 deletions compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,24 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
return exec(errStream, Services.EMPTY, MessageRenderer.PLAIN_FULL_PATHS, args)
}

public override fun execImpl(baseMessageCollector: MessageCollector, services: Services, arguments: A): ExitCode {
public override fun execImpl(messageCollector: MessageCollector, services: Services, arguments: A): ExitCode {
val performanceManager = performanceManager
if (arguments.reportPerf || arguments.dumpPerf != null) {
performanceManager.enableCollectingPerformanceStatistics()
}

val configuration = CompilerConfiguration()

val messageCollector = GroupingMessageCollector(baseMessageCollector, arguments.allWarningsAsErrors).also {
val collector = GroupingMessageCollector(messageCollector, arguments.allWarningsAsErrors).also {
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, it)
}

configuration.put(CLIConfigurationKeys.PERF_MANAGER, performanceManager)
try {
setupCommonArguments(configuration, arguments)
setupPlatformSpecificArgumentsAndServices(configuration, arguments, services)
val paths = computeKotlinPaths(messageCollector, arguments)
if (messageCollector.hasErrors()) {
val paths = computeKotlinPaths(collector, arguments)
if (collector.hasErrors()) {
return ExitCode.COMPILATION_ERROR
}

Expand All @@ -93,14 +93,14 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
performanceManager.dumpPerformanceReport(File(arguments.dumpPerf!!))
}

return if (messageCollector.hasErrors()) COMPILATION_ERROR else code
return if (collector.hasErrors()) COMPILATION_ERROR else code
} catch (e: CompilationCanceledException) {
messageCollector.report(INFO, "Compilation was canceled", null)
collector.report(INFO, "Compilation was canceled", null)
return ExitCode.OK
} catch (e: RuntimeException) {
val cause = e.cause
if (cause is CompilationCanceledException) {
messageCollector.report(INFO, "Compilation was canceled", null)
collector.report(INFO, "Compilation was canceled", null)
return ExitCode.OK
} else {
throw e
Expand All @@ -111,10 +111,10 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
} catch (e: AnalysisResult.CompilationErrorException) {
return COMPILATION_ERROR
} catch (t: Throwable) {
MessageCollectorUtil.reportException(messageCollector, t)
MessageCollectorUtil.reportException(collector, t)
return INTERNAL_ERROR
} finally {
messageCollector.flush()
collector.flush()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ class DummyProfiler : Profiler {
override fun getCounters(): Map<Any?, PerfCounters> = mapOf(null to SimplePerfCounters())
override fun getTotalCounters(): PerfCounters = SimplePerfCounters()

override final inline fun <R> withMeasure(obj: Any?, body: () -> R): R = body()
@Suppress("OVERRIDE_BY_INLINE")
override inline fun <R> withMeasure(obj: Any?, body: () -> R): R = body()
}


Expand All @@ -149,17 +150,20 @@ abstract class TotalProfiler : Profiler {


class WallTotalProfiler : TotalProfiler() {
override final inline fun <R> withMeasure(obj: Any?, body: () -> R): R = withMeasureWallTime(total, body)
@Suppress("OVERRIDE_BY_INLINE")
override inline fun <R> withMeasure(obj: Any?, body: () -> R): R = withMeasureWallTime(total, body)
}


class WallAndThreadTotalProfiler : TotalProfiler() {
override final inline fun <R> withMeasure(obj: Any?, body: () -> R): R = withMeasureWallAndThreadTimes(total, threadMXBean, body)
@Suppress("OVERRIDE_BY_INLINE")
override inline fun <R> withMeasure(obj: Any?, body: () -> R): R = withMeasureWallAndThreadTimes(total, threadMXBean, body)
}


class WallAndThreadAndMemoryTotalProfiler(val withGC: Boolean) : TotalProfiler() {
override final inline fun <R> withMeasure(obj: Any?, body: () -> R): R = withMeasureWallAndThreadTimesAndMemory(total, withGC, threadMXBean, body)
@Suppress("OVERRIDE_BY_INLINE")
override inline fun <R> withMeasure(obj: Any?, body: () -> R): R = withMeasureWallAndThreadTimesAndMemory(total, withGC, threadMXBean, body)
}


Expand All @@ -169,6 +173,7 @@ class WallAndThreadByClassProfiler() : TotalProfiler() {

override fun getCounters(): Map<Any?, PerfCounters> = counters

override final inline fun <R> withMeasure(obj: Any?, body: () -> R): R =
withMeasureWallAndThreadTimes(counters.getOrPut(obj?.javaClass?.name, { SimplePerfCountersWithTotal(total) }), threadMXBean, body)
@Suppress("OVERRIDE_BY_INLINE")
override inline fun <R> withMeasure(obj: Any?, body: () -> R): R =
withMeasureWallAndThreadTimes(counters.getOrPut(obj?.javaClass?.name, { SimplePerfCountersWithTotal(total) }), threadMXBean, body)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import java.net.URLClassLoader
import java.text.SimpleDateFormat
import java.util.*
import java.util.jar.Manifest
import java.util.logging.*
import java.util.logging.Level
import java.util.logging.LogManager
import java.util.logging.Logger
import kotlin.concurrent.schedule

val DAEMON_PERIODIC_CHECK_INTERVAL_MS = 1000L
Expand Down Expand Up @@ -140,26 +142,26 @@ object KotlinCompileDaemon {
}
// timer with a daemon thread, meaning it should not prevent JVM to exit normally
val timer = Timer(true)
val compilerService = CompileServiceImpl(registry = registry,
compiler = compilerSelector,
compilerId = compilerId,
daemonOptions = daemonOptions,
daemonJVMOptions = daemonJVMOptions,
port = port,
timer = timer,
onShutdown = {
if (daemonOptions.forceShutdownTimeoutMilliseconds != COMPILE_DAEMON_TIMEOUT_INFINITE_MS) {
// running a watcher thread that ensures that if the daemon is not exited normally (may be due to RMI leftovers), it's forced to exit
timer.schedule(daemonOptions.forceShutdownTimeoutMilliseconds) {
cancel()
log.info("force JVM shutdown")
System.exit(0)
}
}
else {
timer.cancel()
}
})
val compilerService = CompileServiceImpl(
registry = registry,
compiler = compilerSelector,
compilerId = compilerId,
daemonOptions = daemonOptions,
daemonJVMOptions = daemonJVMOptions,
port = port,
timer = timer
) {
if (daemonOptions.forceShutdownTimeoutMilliseconds != COMPILE_DAEMON_TIMEOUT_INFINITE_MS) {
// running a watcher thread that ensures that if the daemon is not exited normally (may be due to RMI leftovers), it's forced to exit
timer.schedule(daemonOptions.forceShutdownTimeoutMilliseconds) {
cancel()
log.info("force JVM shutdown")
System.exit(0)
}
} else {
timer.cancel()
}
}

println(COMPILE_DAEMON_IS_READY_MESSAGE)
log.info("daemon is listening on port: $port")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
fun loadFunction(proto: ProtoBuf.Function): FirNamedFunction {
val flags = if (proto.hasFlags()) proto.flags else loadOldFlags(proto.oldFlags)

val receiverAnnotations =
@Suppress("UNUSED_VARIABLE") val receiverAnnotations =
// TODO: support annotations
Annotations.EMPTY

val versionRequirementTable =
@Suppress("UNUSED_VARIABLE") val versionRequirementTable =
// TODO: Support case for KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME
c.versionRequirementTable

Expand Down Expand Up @@ -203,7 +203,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
private fun valueParameters(
valueParameters: List<ProtoBuf.ValueParameter>
): List<FirValueParameter> {
return valueParameters.mapIndexed { i, proto ->
return valueParameters.map { proto ->
val flags = if (proto.hasFlags()) proto.flags else 0
FirValueParameterImpl(
c.session, null, c.nameResolver.getName(proto.name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fun <T : ConeKotlinType> T.withNullability(nullability: ConeNullability): T {
return this
}

@Suppress("UNCHECKED_CAST")
return when (this) {
is ConeClassErrorType -> this
is ConeClassTypeImpl -> ConeClassTypeImpl(lookupTag, typeArguments, nullability.isNullable) as T
Expand All @@ -114,6 +115,7 @@ fun <T : ConeKotlinType> T.withArguments(arguments: Array<ConeKotlinTypeProjecti
return this
}

@Suppress("UNCHECKED_CAST")
return when (this) {
is ConeClassErrorType -> this
is ConeClassTypeImpl -> ConeClassTypeImpl(lookupTag, arguments, nullability.isNullable) as T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl

fun ConeKotlinType.scope(useSiteSession: FirSession): FirScope? {
@Suppress("DUPLICATE_LABEL_IN_WHEN")
return when (this) {
is ConeKotlinErrorType -> null
is ConeClassErrorType -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class ScopeTowerLevel(
extensionReceiver: ReceiverValueWithPossibleTypes?,
processor: TowerScopeLevel.TowerScopeLevelProcessor<T>
): ProcessorAction {
@Suppress("UNCHECKED_CAST")
return when (token) {

TowerScopeLevel.Token.Properties -> scope.processPropertiesByName(name) { processor.consumeCandidate(it as T, null) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FirQualifierResolverImpl(val session: FirSession) : FirQualifierResolver {

val fqName = ClassId(
prefix.packageFqName,
parts.drop(1).fold(prefix.relativeClassName) { prefix, suffix -> prefix.child(suffix.name) },
parts.drop(1).fold(prefix.relativeClassName) { fqName, suffix -> fqName.child(suffix.name) },
false
)
return symbolProvider.getClassLikeSymbolByFqName(fqName)
Expand Down
Loading

0 comments on commit 1f7f201

Please sign in to comment.