Eliminate a set of warnings, mostly nullability ones

This commit is contained in:
Mikhail Glukhikh
2017-08-15 11:05:56 +03:00
committed by Mikhail Glukhikh
parent 82fc221470
commit 3623f581b8
52 changed files with 49 additions and 74 deletions
@@ -63,10 +63,8 @@ class GenericReplCompilingEvaluator(val compiler: ReplCompiler,
is ReplEvalResult.ValueResult,
is ReplEvalResult.UnitResult ->
result
else -> throw IllegalStateException("Unknown evaluator result type $compiled")
}
}
else -> throw IllegalStateException("Unknown compiler result type $compiled")
}
}
}
@@ -325,7 +325,7 @@ object KotlinCompilerClient {
if (err != null) {
reportingTargets.report(DaemonReportCategory.INFO,
(if (attempts >= DAEMON_CONNECT_CYCLE_ATTEMPTS || !autostart) "no more retries on: " else "retrying($attempts) on: ")
+ err?.toString())
+ err.toString())
}
if (attempts++ > DAEMON_CONNECT_CYCLE_ATTEMPTS || !autostart) {
@@ -51,8 +51,7 @@ class ExternalFunChecker : SimpleDeclarationChecker {
if (DescriptorUtils.isInterface(descriptor.containingDeclaration)) {
diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_IN_INTERFACE.on(declaration))
}
else if (descriptor is CallableMemberDescriptor &&
descriptor.modality == Modality.ABSTRACT) {
else if (descriptor.modality == Modality.ABSTRACT) {
if (declaration is KtPropertyAccessor) {
diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT.on(declaration.property))
}
@@ -163,7 +163,7 @@ abstract class KtCodeFragment(
}
fun getContextContainingFile(): KtFile? {
return (getOriginalContext() as? KtElement)?.containingKtFile
return getOriginalContext()?.containingKtFile
}
fun getOriginalContext(): KtElement? {
@@ -40,7 +40,7 @@ class KtEnumEntrySuperclassReferenceExpression :
get() = calcReferencedElement()!!
private fun calcReferencedElement(): KtClass? {
val owner = this.getStrictParentOfType<KtEnumEntry>() as? KtEnumEntry
val owner = this.getStrictParentOfType<KtEnumEntry>()
return owner?.parent?.parent as? KtClass
}
@@ -65,7 +65,7 @@ object ConstModifierChecker : SimpleDeclarationChecker {
return Errors.CONST_VAL_WITH_DELEGATE.on(declaration.delegate!!).nonApplicable()
}
if (descriptor is PropertyDescriptor && !descriptor.getter!!.isDefault) {
if (!descriptor.getter!!.isDefault) {
return Errors.CONST_VAL_WITH_GETTER.on(declaration.getter!!).nonApplicable()
}
@@ -90,6 +90,7 @@ object LabelResolver {
if (parent is KtValueArgument) {
// f ({}) or f(p = {}) or f (fun () {})
// NB: parent of KtElement is really nullable!!!
val argList = parent.parent ?: return null
val call = argList.parent
if (call is KtCallExpression) {
@@ -272,7 +272,6 @@ class IncrementalJvmCompilerRunner(
// there is no point in updating annotation file since all files will be compiled anyway
kaptAnnotationsFileUpdater = null
}
else -> throw IllegalStateException("Unknown CompilationMode ${compilationMode::class.java}")
}
val currentBuildInfo = BuildInfo(startTS = System.currentTimeMillis())
@@ -195,7 +195,7 @@ private fun Scope.createTemporaryVariable(symbol: IrVariableSymbol, initializer:
}
private fun getDefaultParameterExpressionBody(irFunction: IrFunction, valueParameter: ValueParameterDescriptor):IrExpressionBody {
return irFunction.getDefault(valueParameter) as? IrExpressionBody ?: TODO("FIXME!!!")
return irFunction.getDefault(valueParameter) ?: TODO("FIXME!!!")
}
private fun maskParameterDescriptor(function: IrFunction, number: Int) =
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.codegen.AsmUtil.comparisonOperandType
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
import org.jetbrains.kotlin.codegen.OwnerKind
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
@@ -68,10 +67,10 @@ class IrCompareTo : IntrinsicMethod() {
val rightType = argTypes[1]
val parameterType = comparisonOperandType(leftType, rightType)
val newSignature = context.state.typeMapper.mapSignatureSkipGeneric(compareCall.descriptor as FunctionDescriptor, OwnerKind.IMPLEMENTATION)
val newSignature = context.state.typeMapper.mapSignatureSkipGeneric(compareCall.descriptor, OwnerKind.IMPLEMENTATION)
return object : IrIntrinsicFunction(compareCall, newSignature, context, listOf(parameterType, parameterType)) {
override fun invoke(v: InstructionAdapter, codegen: ExpressionCodegen, data: BlockInfo): StackValue {
val isPrimitiveIntrinsic = codegen.intrinsics.intrinsics.getIntrinsic(compareCall.descriptor as FunctionDescriptor) != null
val isPrimitiveIntrinsic = codegen.intrinsics.intrinsics.getIntrinsic(compareCall.descriptor) != null
val operationType: Type
val leftValue: StackValue
val rightValue: StackValue
@@ -81,7 +81,7 @@ class ContextAnnotator(val state: GenerationState) : ClassLowerWithContext() {
override fun lowerBefore(irClass: IrClass, data: IrClassContext) {
val descriptor = irClass.descriptor
val newContext: CodegenContext<*> = if (descriptor is FileClassDescriptor || descriptor !is ClassDescriptor) {
val newContext: CodegenContext<*> = if (descriptor is FileClassDescriptor) {
StubCodegenContext(descriptor, data.parent?.codegenContext, data)
}
else {
@@ -59,6 +59,6 @@ class IrFieldImpl(
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
initializer = initializer?.transform(transformer, data) as? IrExpressionBody
initializer = initializer?.transform(transformer, data)
}
}
@@ -114,7 +114,7 @@ class KtLightMethodImpl private constructor(
if (calculatingReturnType.get() == true) {
return KotlinJavaPsiFacade.getInstance(project).emptyModifierList
}
return super.getModifierList()!!
return super.getModifierList()
}
override fun getParameterList() = paramsList
@@ -235,7 +235,7 @@ fun KtLightMethod.isTraitFakeOverride(): Boolean {
}
val parentOfMethodOrigin = PsiTreeUtil.getParentOfType(methodOrigin, KtClassOrObject::class.java)
val thisClassDeclaration = (this.containingClass as KtLightClass).kotlinOrigin
val thisClassDeclaration = this.containingClass.kotlinOrigin
// Method was generated from declaration in some other trait
return (parentOfMethodOrigin != null && thisClassDeclaration !== parentOfMethodOrigin && KtPsiUtil.isTrait(parentOfMethodOrigin))
@@ -670,7 +670,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
fun testDaemonReplLocalEvalNoParams() {
withDaemon { daemon ->
val repl = KotlinRemoteReplCompilerClient(daemon!!, null, CompileService.TargetPlatform.JVM,
val repl = KotlinRemoteReplCompilerClient(daemon, null, CompileService.TargetPlatform.JVM,
emptyArray(),
TestMessageCollector(),
classpathFromClassloader(),
@@ -685,7 +685,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() {
fun testDaemonReplLocalEvalStandardTemplate() {
withDaemon { daemon ->
val repl = KotlinRemoteReplCompilerClient(daemon!!, null, CompileService.TargetPlatform.JVM, emptyArray(),
val repl = KotlinRemoteReplCompilerClient(daemon, null, CompileService.TargetPlatform.JVM, emptyArray(),
TestMessageCollector(),
classpathFromClassloader(),
"kotlin.script.templates.standard.ScriptTemplateWithArgs")