diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt index dc66125a88a..f5bca65b046 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.jvm.AsmTypes +import org.jetbrains.kotlin.types.JetType import java.util.* public class AccessorForConstructorDescriptor( @@ -38,6 +39,8 @@ public class AccessorForConstructorDescriptor( override fun isPrimary(): Boolean = false + override fun getReturnType(): JetType = super.getReturnType()!! + init { initialize( DescriptorUtils.getReceiverParameterType(getExtensionReceiverParameter()), diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt index 4c23e5bb50f..8eea7c615dd 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt @@ -49,7 +49,7 @@ open class BranchedValue( open fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) { if (arg1 is CondJump) arg1.condJump(jumpLabel, v, jumpIfFalse) else arg1.put(operandType, v) arg2?.put(operandType, v) - v.visitJumpInsn(patchOpcode(if (jumpIfFalse) opcode else negatedOperations[opcode], v), jumpLabel); + v.visitJumpInsn(patchOpcode(if (jumpIfFalse) opcode else negatedOperations[opcode]!!, v), jumpLabel); } open fun loopJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt index ff0cc3ddc08..d5bad814797 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt @@ -284,7 +284,7 @@ class RawFileMapping(val name: String, val path: String) { if (rangeMappings.isNotEmpty() && isLastMapped && couldFoldInRange(lastMappedWithNewIndex, source)) { rangeMapping = rangeMappings.last() rangeMapping.range += source - lastMappedWithNewIndex - dest = lineMappings[lastMappedWithNewIndex] + source - lastMappedWithNewIndex + dest = lineMappings[lastMappedWithNewIndex]!! + source - lastMappedWithNewIndex } else { dest = currentIndex + 1 diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt index 0ff23c89494..7528cef9e4d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt @@ -139,7 +139,7 @@ public object LabelNormalizationMethodTransformer : MethodTransformer() { } private fun isRemoved(labelNode: LabelNode): Boolean = removedLabelNodes.contains(labelNode) - private fun getNew(oldLabelNode: LabelNode): LabelNode = newLabelNodes[oldLabelNode] + private fun getNew(oldLabelNode: LabelNode): LabelNode = newLabelNodes[oldLabelNode]!! } private fun InsnList.replaceNodeGetNext(oldNode: AbstractInsnNode, newNode: AbstractInsnNode): AbstractInsnNode? { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt index e1001342b5a..bd69862aa9b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt @@ -134,19 +134,19 @@ public class FixStackAnalyzer( val returnValue = pop() clearStack() val savedValues = savedStacks[beforeInlineMarker] - pushAll(savedValues) + pushAll(savedValues!!) push(returnValue) } else { val savedValues = savedStacks[beforeInlineMarker] - pushAll(savedValues) + pushAll(savedValues!!) } } private fun FixStackFrame.executeRestoreStackInTryCatch(insn: AbstractInsnNode) { val saveNode = context.saveStackMarkerForRestoreMarker[insn] val savedValues = savedStacks.getOrElse(saveNode) { - throw AssertionError("${indexOf(insn)}: Restore stack is unavailable for ${indexOf(saveNode)}") + throw AssertionError("${indexOf(insn)}: Restore stack is unavailable for ${indexOf(saveNode!!)}") } pushAll(savedValues) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt index 90e74c3d96c..c4831c322e4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt @@ -39,7 +39,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod } fun allocateVariablesForSaveStackMarker(saveStackMarker: AbstractInsnNode, savedStackValues: List): SavedStackDescriptor { - val numRestoreStackMarkers = context.restoreStackMarkersForSaveMarker[saveStackMarker].size() + val numRestoreStackMarkers = context.restoreStackMarkersForSaveMarker[saveStackMarker]!!.size() return allocateNewHandle(numRestoreStackMarkers, saveStackMarker, savedStackValues) } @@ -54,7 +54,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod fun getSavedStackDescriptorOrNull(restoreStackMarker: AbstractInsnNode): SavedStackDescriptor { val saveStackMarker = context.saveStackMarkerForRestoreMarker[restoreStackMarker] - return allocatedHandles[saveStackMarker].savedStackDescriptor + return allocatedHandles[saveStackMarker]!!.savedStackDescriptor } private fun getFirstUnusedLocalVariableIndex(): Int = @@ -64,7 +64,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod fun markRestoreStackMarkerEmitted(restoreStackMarker: AbstractInsnNode) { val saveStackMarker = context.saveStackMarkerForRestoreMarker[restoreStackMarker] - markEmitted(saveStackMarker) + markEmitted(saveStackMarker!!) } fun allocateVariablesForBeforeInlineMarker(beforeInlineMarker: AbstractInsnNode, savedStackValues: List): SavedStackDescriptor { @@ -73,16 +73,16 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod fun getBeforeInlineDescriptor(afterInlineMarker: AbstractInsnNode): SavedStackDescriptor { val beforeInlineMarker = context.openingInlineMethodMarker[afterInlineMarker] - return allocatedHandles[beforeInlineMarker].savedStackDescriptor + return allocatedHandles[beforeInlineMarker]!!.savedStackDescriptor } fun markAfterInlineMarkerEmitted(afterInlineMarker: AbstractInsnNode) { val beforeInlineMarker = context.openingInlineMethodMarker[afterInlineMarker] - markEmitted(beforeInlineMarker) + markEmitted(beforeInlineMarker!!) } private fun markEmitted(saveStackMarker: AbstractInsnNode) { - val allocatedHandle = allocatedHandles[saveStackMarker] + val allocatedHandle = allocatedHandles[saveStackMarker]!! allocatedHandle.markRestoreNodeEmitted() if (allocatedHandle.isFullyEmitted()) { allocatedHandles.remove(saveStackMarker) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index e3562a67f17..52164b8c799 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -94,7 +94,7 @@ public open class K2JVMCompiler : CLICompiler() { return INTERNAL_ERROR } catch (e: CliOptionProcessingException) { - messageSeverityCollector.report(CompilerMessageSeverity.ERROR, e.getMessage(), CompilerMessageLocation.NO_LOCATION) + messageSeverityCollector.report(CompilerMessageSeverity.ERROR, e.getMessage()!!, CompilerMessageLocation.NO_LOCATION) return INTERNAL_ERROR } catch (t: Throwable) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt index 94eb2fafe8f..63ffc596c59 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt @@ -61,7 +61,7 @@ public class JavaAnnotationCallChecker : CallChecker { if (it.getArgumentExpression() != null) { context.trace.report( diagnostic.on( - it.getArgumentExpression() + it.getArgumentExpression()!! ) ) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt index 0853a822abc..9f0c1a1838b 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt @@ -172,7 +172,7 @@ public class PublicFieldAnnotationChecker: DeclarationChecker { if (descriptor !is PropertyDescriptor) { report() } - else if (!bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor)) { + else if (!bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor)!!) { report() } } @@ -301,7 +301,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { val baseExpression = expression.getLeft() val baseExpressionType = baseExpression?.let{ c.trace.getType(it) } ?: return doIfNotNull( - DataFlowValueFactory.createDataFlowValue(baseExpression, baseExpressionType, c), + DataFlowValueFactory.createDataFlowValue(baseExpression!!, baseExpressionType, c), c ) { c.trace.report(Errors.USELESS_ELVIS.on(expression, baseExpressionType)) @@ -364,7 +364,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { } else { doIfNotNull(dataFlowValue, c) { - c.trace.report(Errors.UNNECESSARY_SAFE_CALL.on(c.call.getCallOperationNode().getPsi(), receiverArgument.getType())) + c.trace.report(Errors.UNNECESSARY_SAFE_CALL.on(c.call.getCallOperationNode()!!.getPsi(), receiverArgument.getType())) } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt index a57d3d38272..ecb07d02390 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt @@ -289,7 +289,7 @@ public object PositioningStrategies { public val VARIANCE_IN_PROJECTION: PositioningStrategy = object : PositioningStrategy() { override fun mark(element: JetTypeProjection): List { - return markNode(element.getProjectionNode()) + return markNode(element.getProjectionNode()!!) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/psi/impl/KDocLink.kt b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/psi/impl/KDocLink.kt index f936c51275c..e7d1182d95f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/psi/impl/KDocLink.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/psi/impl/KDocLink.kt @@ -43,6 +43,6 @@ public class KDocLink(node: ASTNode) : JetElementImpl(node) { return if (tag != null && tag.getSubjectLink() == this) tag else null } - override fun getReferences(): Array? = + override fun getReferences(): Array = ReferenceProvidersRegistry.getReferencesFromProviders(this) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetDoubleColonExpression.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetDoubleColonExpression.kt index 3a3b058918d..a540a86b24b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetDoubleColonExpression.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetDoubleColonExpression.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.lexer.JetTokens public abstract class JetDoubleColonExpression(node: ASTNode) : JetExpressionImpl(node) { public fun getTypeReference(): JetTypeReference? = findChildByType(JetNodeTypes.TYPE_REFERENCE) - public fun getDoubleColonTokenReference(): PsiElement = findChildByType(JetTokens.COLONCOLON) + public fun getDoubleColonTokenReference(): PsiElement = findChildByType(JetTokens.COLONCOLON)!! override fun accept(visitor: JetVisitor, data: D): R { return visitor.visitDoubleColonExpression(this, data) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt index a1b0f6dd383..7f005751faa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt @@ -75,5 +75,5 @@ public class JetObjectDeclaration : JetClassOrObject { public fun isObjectLiteral(): Boolean = getStub()?.isObjectLiteral() ?: (getParent() is JetObjectLiteralExpression) - public fun getObjectKeyword(): PsiElement = findChildByType(JetTokens.OBJECT_KEYWORD) + public fun getObjectKeyword(): PsiElement = findChildByType(JetTokens.OBJECT_KEYWORD)!! } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt index cb1c6790cd8..b2aa4f59d09 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt @@ -251,7 +251,7 @@ public class JetPsiFactory(private val project: Project) { } public fun createFunctionLiteralParameterList(text: String): JetParameterList { - return (createExpression("{ $text -> 0}") as JetFunctionLiteralExpression).getFunctionLiteral().getValueParameterList() + return (createExpression("{ $text -> 0}") as JetFunctionLiteralExpression).getFunctionLiteral().getValueParameterList()!! } public fun createEnumEntry(text: String): JetEnumEntry { @@ -284,7 +284,7 @@ public class JetPsiFactory(private val project: Project) { } public fun createPackageDirective(fqName: FqName): JetPackageDirective { - return createFile("package ${fqName.asString()}").getPackageDirective() + return createFile("package ${fqName.asString()}").getPackageDirective()!! } public fun createPackageDirectiveIfNeeded(fqName: FqName): JetPackageDirective? { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt index 83494aa585d..c6bb1f649f6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt @@ -39,7 +39,7 @@ public class KotlinStringLiteralTextEscaper(host: JetStringTemplateExpression): } when (child) { is JetLiteralStringTemplateEntry -> { - val textRange = rangeInsideHost.intersection(childRange).shiftRight(-childRange.getStartOffset()) + val textRange = rangeInsideHost.intersection(childRange)!!.shiftRight(-childRange.getStartOffset()) outChars.append(child.getText(), textRange.getStartOffset(), textRange.getEndOffset()) textRange.getLength().times { sourceOffsetsList.add(sourceOffset++) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt index 70730cc00f3..8dd690897fb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt @@ -144,9 +144,9 @@ public fun JetElement.getCalleeHighlightingRange(): TextRange { ) ?: return getTextRange() val startOffset = annotationEntry.getAtSymbol()?.getTextRange()?.getStartOffset() - ?: annotationEntry.getCalleeExpression().startOffset + ?: annotationEntry.getCalleeExpression()!!.startOffset - return TextRange(startOffset, annotationEntry.getCalleeExpression().endOffset) + return TextRange(startOffset, annotationEntry.getCalleeExpression()!!.endOffset) } // ---------- Block expression ------------------------------------------------------------------------------------------------------------- diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt index 4bdb281a73d..01f0e39475e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt @@ -210,7 +210,7 @@ public class LazyTopDownAnalyzer { } override fun visitAnonymousInitializer(initializer: JetClassInitializer) { - val classOrObject = PsiTreeUtil.getParentOfType(initializer, javaClass()) + val classOrObject = PsiTreeUtil.getParentOfType(initializer, javaClass())!! c.getAnonymousInitializers().put(initializer, lazyDeclarationResolver!!.resolveToDescriptor(classOrObject) as ClassDescriptorWithResolutionScopes) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index 573d33af5b6..55c3ea047b3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -226,7 +226,7 @@ public class TypeResolver( val receiverTypeRef = type.getReceiverTypeReference() val receiverType = if (receiverTypeRef == null) null else resolveType(c.noBareTypes(), receiverTypeRef) - val parameterTypes = type.getParameters().map { resolveType(c.noBareTypes(), it.getTypeReference()) } + val parameterTypes = type.getParameters().map { resolveType(c.noBareTypes(), it.getTypeReference()!!) } val returnTypeRef = type.getReturnTypeReference() val returnType = if (returnTypeRef != null) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt index 9e0d73ef638..2ac5e9e8a06 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt @@ -176,7 +176,7 @@ class VarianceChecker(private val trace: BindingTrace) { for (argumentBinding in getArgumentBindings()) { if (argumentBinding == null || argumentBinding.typeParameterDescriptor == null) continue - val projectionKind = getEffectiveProjectionKind(argumentBinding.typeParameterDescriptor, argumentBinding.typeProjection)!! + val projectionKind = getEffectiveProjectionKind(argumentBinding.typeParameterDescriptor!!, argumentBinding.typeProjection)!! val newPosition = when (projectionKind) { OUT -> position IN -> position.opposite() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index faaa381b422..03ac7c51fa4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -77,7 +77,7 @@ public class CallCompleter( resolvedCall.variableCall.getCall().getCalleeExpression() else resolvedCall.getCall().getCalleeExpression() - context.symbolUsageValidator.validateCall(resolvedCall.getResultingDescriptor(), context.trace, element) + context.symbolUsageValidator.validateCall(resolvedCall.getResultingDescriptor(), context.trace, element!!) } if (results.isSingleResult() && results.getResultingCall().getStatus().isSuccess()) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/CapturingInClosureChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/CapturingInClosureChecker.kt index 6611164be24..0abee398898 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/CapturingInClosureChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/CapturingInClosureChecker.kt @@ -74,7 +74,7 @@ class CapturingInClosureChecker : CallChecker { if (InlineUtil.isInlinedArgument(scopeDeclaration as JetFunction, context, false)) { val scopeContainerParent = scopeContainer.getContainingDeclaration() assert(scopeContainerParent != null) { "parent is null for " + scopeContainer } - return !isCapturedVariable(variableParent, scopeContainerParent) || isCapturedInInline(context, scopeContainerParent, variableParent) + return !isCapturedVariable(variableParent, scopeContainerParent!!) || isCapturedInInline(context, scopeContainerParent, variableParent) } return false } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index a5e4178acd9..0110b9b7b4d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -226,7 +226,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT if (argumentForParameter == null) return null if (isDivisionByZero(resultingDescriptorName.asString(), argumentForParameter.value)) { - val parentExpression: JetExpression = PsiTreeUtil.getParentOfType(receiverExpression, javaClass()) + val parentExpression: JetExpression = PsiTreeUtil.getParentOfType(receiverExpression, javaClass())!! trace.report(Errors.DIVISION_BY_ZERO.on(parentExpression)) return ErrorValue.create("Division by zero") } @@ -406,7 +406,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT } override fun visitClassLiteralExpression(expression: JetClassLiteralExpression, expectedType: JetType?): CompileTimeConstant<*>? { - val jetType = trace.getType(expression) + val jetType = trace.getType(expression)!! if (jetType.isError()) return null return KClassValue(jetType) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt index 00eb512b7f3..bbe826048b0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt @@ -97,6 +97,7 @@ public class LazyScriptClassMemberScope protected constructor( val returnType = scriptDescriptor.getScriptCodeDescriptor().getReturnType() assert(returnType != null) { "Return type not initialized for " + scriptDescriptor } + returnType!! propertyDescriptor.setType( returnType, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/DeprecatedSymbolValidator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/DeprecatedSymbolValidator.kt index 11cc047dfe3..b9f7a41ec3a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/DeprecatedSymbolValidator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/DeprecatedSymbolValidator.kt @@ -47,7 +47,7 @@ public class DeprecatedSymbolValidator : SymbolUsageValidator { override fun validateTypeUsage(targetDescriptor: ClassifierDescriptor, trace: BindingTrace, element: PsiElement) { // Do not check types in annotation entries to prevent cycles in resolve, rely on call message val annotationEntry = JetStubbedPsiUtil.getPsiOrStubParent(element, javaClass(), true) - if (annotationEntry != null && annotationEntry.getCalleeExpression().getConstructorReferenceExpression() == element) + if (annotationEntry != null && annotationEntry.getCalleeExpression()!!.getConstructorReferenceExpression() == element) return // Do not check types in calls to super constructor in extends list, rely on call message diff --git a/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt b/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt index fb5612e3bf0..4255d781a34 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt @@ -74,7 +74,7 @@ public class LockBasedLazyResolveStorageManager(private val storageManager: Stor storageManager.compute { trace.record(slice, key) } } - override fun get(slice: ReadOnlySlice, key: K): V = storageManager.compute { trace.get(slice, key) } + override fun get(slice: ReadOnlySlice, key: K): V? = storageManager.compute { trace.get(slice, key) } override fun getKeys(slice: WritableSlice): Collection = storageManager.compute { trace.getKeys(slice) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt index fbc931ea56b..dfa6f649dd9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt @@ -214,7 +214,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express // This is needed for ControlStructureTypingVisitor#visitReturnExpression() to properly type-check returned expressions context.trace.record(EXPECTED_RETURN_TYPE, functionLiteral, expectedType) val typeOfBodyExpression = // Type-check the body - components.expressionTypingServices.getBlockReturnedType(functionLiteral.getBodyExpression(), COERCION_TO_UNIT, newContext).type + components.expressionTypingServices.getBlockReturnedType(functionLiteral.getBodyExpression()!!, COERCION_TO_UNIT, newContext).type return declaredReturnType ?: computeReturnTypeBasedOnReturnExpressions(functionLiteral, context, typeOfBodyExpression) } diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightMethodForTraitFakeOverride.kt b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightMethodForTraitFakeOverride.kt index b48223d3724..3328415221b 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightMethodForTraitFakeOverride.kt +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightMethodForTraitFakeOverride.kt @@ -33,6 +33,6 @@ public class KotlinLightMethodForTraitFakeOverride( override fun getOrigin(): JetDeclaration = origin override fun copy(): PsiElement { - return KotlinLightMethodForTraitFakeOverride(getManager(), delegate, origin.copy() as JetDeclaration, getContainingClass()) + return KotlinLightMethodForTraitFakeOverride(getManager(), delegate, origin.copy() as JetDeclaration, getContainingClass()!!) } } diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt index 0f10bd149d4..0a23ec43013 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt @@ -64,22 +64,22 @@ public object AnnotationSerializer { override fun visitBooleanValue(value: BooleanValue, data: Unit) { setType(Type.BOOLEAN) - setIntValue(if (value.getValue()) 1 else 0) + setIntValue(if (value.getValue()!!) 1 else 0) } override fun visitByteValue(value: ByteValue, data: Unit) { setType(Type.BYTE) - setIntValue(value.getValue().toLong()) + setIntValue(value.getValue()!!.toLong()) } override fun visitCharValue(value: CharValue, data: Unit) { setType(Type.CHAR) - setIntValue(value.getValue().toLong()) + setIntValue(value.getValue()!!.toLong()) } override fun visitDoubleValue(value: DoubleValue, data: Unit) { setType(Type.DOUBLE) - setDoubleValue(value.getValue()) + setDoubleValue(value.getValue()!!) } override fun visitEnumValue(value: EnumValue, data: Unit) { @@ -95,12 +95,12 @@ public object AnnotationSerializer { override fun visitFloatValue(value: FloatValue, data: Unit) { setType(Type.FLOAT) - setFloatValue(value.getValue()) + setFloatValue(value.getValue()!!) } override fun visitIntValue(value: IntValue, data: Unit) { setType(Type.INT) - setIntValue(value.getValue().toLong()) + setIntValue(value.getValue()!!.toLong()) } override fun visitKClassValue(value: KClassValue?, data: Unit?) { @@ -110,7 +110,7 @@ public object AnnotationSerializer { override fun visitLongValue(value: LongValue, data: Unit) { setType(Type.LONG) - setIntValue(value.getValue()) + setIntValue(value.getValue()!!) } override fun visitNullValue(value: NullValue, data: Unit) { @@ -135,12 +135,12 @@ public object AnnotationSerializer { override fun visitShortValue(value: ShortValue, data: Unit) { setType(Type.SHORT) - setIntValue(value.getValue().toLong()) + setIntValue(value.getValue()!!.toLong()) } override fun visitStringValue(value: StringValue, data: Unit) { setType(Type.STRING) - setStringValue(nameTable.getStringIndex(value.getValue())) + setStringValue(nameTable.getStringIndex(value.getValue()!!)) } }, Unit) diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt b/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt index 015af25125c..15a5706bb2b 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt +++ b/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt @@ -152,7 +152,7 @@ class LazyOperationsLog( } o.javaClass.getSimpleName() == "LazyJavaClassTypeConstructor" -> { val javaClass = o.field("this\$0").field("jClass") - javaClass.getPsi().getName().appendQuoted() + javaClass.getPsi().getName()!!.appendQuoted() } o.javaClass.getSimpleName() == "DeserializedType" -> { val typeDeserializer = o.field("typeDeserializer") @@ -161,7 +161,7 @@ class LazyOperationsLog( val text = when (typeProto.getConstructor().getKind()) { ProtoBuf.Type.Constructor.Kind.CLASS -> context.nameResolver.getFqName(typeProto.getConstructor().getId()).asString() ProtoBuf.Type.Constructor.Kind.TYPE_PARAMETER -> { - val classifier = (o as JetType).getConstructor().getDeclarationDescriptor() + val classifier = (o as JetType).getConstructor().getDeclarationDescriptor()!! "" + classifier.getName() + " in " + DescriptorUtils.getFqName(classifier.getContainingDeclaration()) } else -> "???" diff --git a/compiler/tests/org/jetbrains/kotlin/cli/jvm/KotlinCliJavaFileManagerTest.kt b/compiler/tests/org/jetbrains/kotlin/cli/jvm/KotlinCliJavaFileManagerTest.kt index d7ccb8cc45a..32e7e827ba3 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/jvm/KotlinCliJavaFileManagerTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/cli/jvm/KotlinCliJavaFileManagerTest.kt @@ -143,6 +143,7 @@ public class KotlinCliJavaFileManagerTest : PsiTestCase() { val pkg = root.createChildDirectory(this, "foo") val dir = myPsiManager.findDirectory(pkg) TestCase.assertNotNull(dir) + dir!! dir.add(PsiFileFactory.getInstance(getProject()).createFileFromText(className + ".java", JavaFileType.INSTANCE, text)) val coreJavaFileManagerExt = KotlinCliJavaFileManagerImpl(myPsiManager) coreJavaFileManagerExt.initIndex(JvmDependenciesIndex(listOf(JavaRoot(root, JavaRoot.RootType.SOURCE)))) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/InlineTestUtil.kt b/compiler/tests/org/jetbrains/kotlin/codegen/InlineTestUtil.kt index a23c9e83f8d..7935d59e598 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/InlineTestUtil.kt +++ b/compiler/tests/org/jetbrains/kotlin/codegen/InlineTestUtil.kt @@ -194,9 +194,9 @@ public object InlineTestUtil { override fun getFileContents(): ByteArray = throw UnsupportedOperationException() override fun hashCode(): Int = throw UnsupportedOperationException() override fun equals(other: Any?): Boolean = throw UnsupportedOperationException() - override fun toString(): String? = throw UnsupportedOperationException() + override fun toString(): String = throw UnsupportedOperationException() } - }.getClassHeader() + }!!.getClassHeader() } private class InlineInfo(val inlineMethods: Set, val classHeaders: Map) diff --git a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt index 065e6623946..dd79a6dbe94 100644 --- a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt @@ -79,7 +79,7 @@ public abstract class AbstractDescriptorRendererTest : KotlinTestWithEnvironment is JetPrimaryConstructor -> { val jetClassOrObject: JetClassOrObject = declaringElement.getContainingClassOrObject() val classDescriptor = getDescriptor(jetClassOrObject, resolveSession) as ClassDescriptor - addCorrespondingParameterDescriptor(classDescriptor.getUnsubstitutedPrimaryConstructor(), parameter) + addCorrespondingParameterDescriptor(classDescriptor.getUnsubstitutedPrimaryConstructor()!!, parameter) } else -> super.visitParameter(parameter) } diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/calls/AbstractResolvedCallsTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/calls/AbstractResolvedCallsTest.kt index 86ed538e515..81b739de555 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/calls/AbstractResolvedCallsTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/calls/AbstractResolvedCallsTest.kt @@ -66,7 +66,7 @@ public abstract class AbstractResolvedCallsTest : JetLiteFixture() { open protected fun buildCachedCall( bindingContext: BindingContext, jetFile: JetFile, text: String ): Pair?> { - val element = jetFile.findElementAt(text.indexOf("")) + val element = jetFile.findElementAt(text.indexOf(""))!! val expression = element.getStrictParentOfType() val cachedCall = expression?.getParentResolvedCall(bindingContext, strict = false) diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt index d7fac45ef9f..78f8c707c04 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt @@ -106,7 +106,7 @@ public class CapturedTypeApproximationTest() : JetLiteFixture() { val testSubstitutions = createTestSubstitutions(typeParameters) for (testSubstitution in testSubstitutions) { val typeSubstitutor = createTestSubstitutor(testSubstitution) - val typeWithCapturedType = typeSubstitutor.substituteWithoutApproximation(TypeProjectionImpl(INVARIANT, type))!!.getType() + val typeWithCapturedType = typeSubstitutor.substituteWithoutApproximation(TypeProjectionImpl(INVARIANT, type!!))!!.getType() val (lower, upper) = approximateCapturedTypes(typeWithCapturedType) val substitution = approximateCapturedTypesIfNecessary(TypeProjectionImpl(INVARIANT, typeWithCapturedType)) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index 558ed9d3912..071e9567383 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -63,7 +63,7 @@ fun DeclarationDescriptor.getCapturedTypeParameters(): Collection { // todo type arguments (instead of type parameters) of the type of outer class must be considered; KT-6325 - val typeParameters = getContainedTypeParameters() + getConstructor().getDeclarationDescriptor().getCapturedTypeParameters() + val typeParameters = getContainedTypeParameters() + getConstructor().getDeclarationDescriptor()!!.getCapturedTypeParameters() return typeParameters.map { it.getTypeConstructor() }.toReadOnlyList() } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt index 7a92b70da47..cc2e0cf7223 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt @@ -170,7 +170,7 @@ public class MemberDeserializer(private val c: DeserializationContext) { } private fun valueParameters(callable: Callable, kind: AnnotatedCallableKind): List { - val containerOfCallable = c.containingDeclaration.getContainingDeclaration().asProtoContainer() + val containerOfCallable = c.containingDeclaration.getContainingDeclaration()!!.asProtoContainer() return callable.getValueParameterList().mapIndexed { i, proto -> ValueParameterDescriptorImpl( diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt index d514f844681..40680d232cd 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt @@ -102,7 +102,7 @@ public fun CallableDescriptor.substituteExtensionIfCallable( return if (substitutors.any()) listOf(this) else listOf() } else { - return substitutors.map { substitute(it) }.toList() + return substitutors.map { substitute(it)!! }.toList() } } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt index 2d93627af24..ad87d432aef 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt @@ -492,19 +492,19 @@ public abstract class ElementResolver protected constructor( ) : BodiesResolveContext { override fun getFiles(): Collection = setOf() - override fun getDeclaredClasses(): Map = mapOf() + override fun getDeclaredClasses(): MutableMap = hashMapOf() - override fun getAnonymousInitializers(): Map = mapOf() + override fun getAnonymousInitializers(): MutableMap = hashMapOf() - override fun getSecondaryConstructors(): Map = mapOf() + override fun getSecondaryConstructors(): MutableMap = hashMapOf() - override fun getProperties(): Map = mapOf() + override fun getProperties(): MutableMap = hashMapOf() - override fun getFunctions(): Map = mapOf() + override fun getFunctions(): MutableMap = hashMapOf() override fun getDeclaringScope(declaration: JetDeclaration): JetScope? = declaringScopes(declaration) - override fun getScripts(): Map = mapOf() + override fun getScripts(): MutableMap = hashMapOf() override fun getOuterDataFlowInfo(): DataFlowInfo = DataFlowInfo.EMPTY diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt index a4b20654904..f6db9e92272 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt @@ -108,7 +108,7 @@ private class ClassClsStubBuilder( val superTypeRefs = supertypeIds.filterNot { //TODO: filtering function types should go away KotlinBuiltIns.isNumberedFunctionClassFqName(it.asSingleFqName().toUnsafe()) - }.map { it.getShortClassName().ref() }.toTypedArray() + }.map { it.getShortClassName().ref()!! }.toTypedArray() return when (classKind) { ProtoBuf.Class.Kind.OBJECT, ProtoBuf.Class.Kind.CLASS_OBJECT -> { KotlinObjectStubImpl( diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinClsStubBuilder.kt index 963559d741a..a4118eb2b62 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinClsStubBuilder.kt @@ -49,7 +49,7 @@ public open class KotlinClsStubBuilder : ClsStubBuilder() { } fun doBuildFileStub(file: VirtualFile): PsiFileStub? { - val kotlinBinaryClass = KotlinBinaryClassCache.getKotlinBinaryClass(file) + val kotlinBinaryClass = KotlinBinaryClassCache.getKotlinBinaryClass(file)!! val header = kotlinBinaryClass.getClassHeader() val classId = kotlinBinaryClass.getClassId() val packageFqName = classId.getPackageFqName() diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt index 66ae2034b30..61cc3156c56 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt @@ -216,7 +216,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) { val typeConstraintListStub = KotlinPlaceHolderStubImpl(parent, JetStubElementTypes.TYPE_CONSTRAINT_LIST) for ((name, type) in protosForTypeConstraintList) { val typeConstraintStub = KotlinPlaceHolderStubImpl(typeConstraintListStub, JetStubElementTypes.TYPE_CONSTRAINT) - KotlinNameReferenceExpressionStubImpl(typeConstraintStub, name.ref()) + KotlinNameReferenceExpressionStubImpl(typeConstraintStub, name.ref()!!) createTypeReferenceStub(typeConstraintStub, type) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt index f35d64d8230..39716526e45 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt @@ -203,6 +203,6 @@ val ProtoBuf.Callable.annotatedCallableKind: AnnotatedCallableKind } } -fun Name.ref() = StringRef.fromString(this.asString()) +fun Name.ref() = StringRef.fromString(this.asString())!! -fun FqName.ref() = StringRef.fromString(this.asString()) +fun FqName.ref() = StringRef.fromString(this.asString())!! diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt index 191cd9b47c6..bd241a27d5d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt @@ -147,7 +147,7 @@ public fun buildDecompiledText( if (descriptor is CallableDescriptor) { //NOTE: assuming that only return types can be flexible - if (descriptor.getReturnType().isFlexible()) { + if (descriptor.getReturnType()!!.isFlexible()) { builder.append(" ").append(FLEXIBLE_TYPE_COMMENT) } } @@ -191,7 +191,7 @@ public fun buildDecompiledText( companionNeeded = false newlineExceptFirst() builder.append(subindent) - appendDescriptor(companionObject, subindent) + appendDescriptor(companionObject!!, subindent) } if (member is CallableMemberDescriptor && member.getKind() != CallableMemberDescriptor.Kind.DECLARATION diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt index 15961a47845..041030aff2c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt @@ -90,7 +90,7 @@ private object DeclarationKindDetector : JetVisitor( override fun visitProperty(d: JetProperty, _: Unit?) = detect(d, d.getValOrVarKeyword().getText()!!) override fun visitMultiDeclaration(d: JetMultiDeclaration, _: Unit?) = detect(d, d.getValOrVarKeyword()?.getText() ?: "val", - name = d.getEntries().map { it.getName() }.join(", ", "(", ")")) + name = d.getEntries().map { it.getName()!! }.join(", ", "(", ")")) override fun visitTypeParameter(d: JetTypeParameter, _: Unit?) = detect(d, "type parameter", newLineNeeded = false) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt index 69a14e754c9..d57575e72b9 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt @@ -58,7 +58,7 @@ public class KDocReference(element: KDocName): JetMultiReference(eleme override fun handleElementRename(newElementName: String?): PsiElement? { val textRange = getElement().getNameTextRange() - val newText = textRange.replace(getElement().getText(), newElementName) + val newText = textRange.replace(getElement().getText(), newElementName!!) val newLink = KDocElementFactory(getElement().getProject()).createNameFromText(newText) return getElement().replace(newLink) } @@ -181,5 +181,5 @@ private fun getOuterScope(descriptor: DeclarationDescriptorWithSource, resolutio return resolutionFacade.getFileTopLevelScope(containingFile) } } - return getResolutionScope(resolutionFacade, parent) + return getResolutionScope(resolutionFacade, parent!!) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt index 8bc74b494db..63016f0329f 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt @@ -72,7 +72,7 @@ class AllClassesCompletion(private val parameters: CompletionParameters, } private fun PsiClass.isSyntheticKotlinClass(): Boolean { - if (!getName().contains('$')) return false // optimization to not analyze annotations of all classes + if (!getName()!!.contains('$')) return false // optimization to not analyze annotations of all classes return getModifierList()?.findAnnotation(javaClass().getName()) != null } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt index ec998138fdc..2b0cec2a384 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt @@ -289,7 +289,7 @@ fun LookupElementFactory.createBackingFieldLookupElement( if (accessors.all { it.getBodyExpression() == null }) return null // makes no sense to access backing field - it's the same as accessing property directly val bindingContext = resolutionFacade.analyze(declaration) - if (!bindingContext[BindingContext.BACKING_FIELD_REQUIRED, property]) return null + if (!bindingContext[BindingContext.BACKING_FIELD_REQUIRED, property]!!) return null val lookupElement = createLookupElement(property, true) return object : LookupElementDecorator(lookupElement) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt index a033e8b712b..98984a5cde9 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt @@ -64,7 +64,7 @@ class KDocNameCompletionSession(parameters: CompletionParameters, val position = parameters.getPosition().getParentOfType(false) ?: return val declaration = position.getContainingDoc().getOwner() ?: return val kdocLink = position.getStrictParentOfType()!! - val declarationDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration] + val declarationDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]!! if (kdocLink.getTagIfSubject()?.knownTag == KDocKnownTag.PARAM) { addParamCompletions(position, declarationDescriptor) } else { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 9526c72b015..62e7260e9dd 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -104,7 +104,7 @@ public class LookupElementFactory( val lookupObject = object : DeclarationLookupObjectImpl(null, psiClass, resolutionFacade) { override fun getIcon(flags: Int) = psiClass.getIcon(flags) } - var element = LookupElementBuilder.create(lookupObject, psiClass.getName()) + var element = LookupElementBuilder.create(lookupObject, psiClass.getName()!!) .withInsertHandler(KotlinClassInsertHandler) val typeParams = psiClass.getTypeParameters() @@ -123,7 +123,7 @@ public class LookupElementFactory( itemText = containerName.substringAfterLast('.') + "." + itemText containerName = containerName.substringBeforeLast('.', FqName.ROOT.toString()) } - element = element.withPresentableText(itemText) + element = element.withPresentableText(itemText!!) } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt index 9efd2dcdf8f..4fb750dbe0c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt @@ -134,7 +134,7 @@ class ParameterNameAndTypeCompletion( } private fun addSuggestionsForJavaClass(psiClass: PsiClass, userPrefix: String, prefixMatcher: PrefixMatcher) { - addSuggestions(psiClass.getName(), userPrefix, prefixMatcher, JavaClassType(psiClass)) + addSuggestions(psiClass.getName()!!, userPrefix, prefixMatcher, JavaClassType(psiClass)) } private fun addSuggestions(className: String, userPrefix: String, prefixMatcher: PrefixMatcher, type: Type) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt index c4cc8f98f86..7fdcf59652d 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt @@ -39,7 +39,7 @@ object CastReceiverInsertHandler : KotlinCallableInsertHandler() { val project = context.getProject() val thisObj = if (descriptor.getExtensionReceiverParameter() != null) descriptor.getExtensionReceiverParameter() else descriptor.getDispatchReceiverParameter() - val fqName = IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(thisObj.getType().getConstructor().getDeclarationDescriptor()) + val fqName = IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(thisObj!!.getType().getConstructor().getDeclarationDescriptor()!!) val parentCast = JetPsiFactory(project).createExpression("(expr as $fqName)") as JetParenthesizedExpression val cast = parentCast.getExpression() as JetBinaryExpressionWithTypeRHS @@ -51,7 +51,7 @@ object CastReceiverInsertHandler : KotlinCallableInsertHandler() { val expr = receiver.replace(parentCast) as JetParenthesizedExpression - ShortenReferences.DEFAULT.process((expr.getExpression() as JetBinaryExpressionWithTypeRHS).getRight()) + ShortenReferences.DEFAULT.process((expr.getExpression() as JetBinaryExpressionWithTypeRHS).getRight()!!) } } } \ No newline at end of file diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassInsertHandler.kt index 7d71886227f..8a942149637 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassInsertHandler.kt @@ -50,7 +50,7 @@ object KotlinClassInsertHandler : BaseDeclarationInsertHandler() { // first try to resolve short name for faster handling val token = file.findElementAt(startOffset) - val nameRef = token.getParent() as? JetNameReferenceExpression + val nameRef = token!!.getParent() as? JetNameReferenceExpression if (nameRef != null) { val bindingContext = nameRef.getResolutionFacade().analyze(nameRef, BodyResolveMode.PARTIAL) val target = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, nameRef] diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt index 50bf4e5f953..d923fb28642 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt @@ -391,7 +391,7 @@ class SmartCompletion( null } - val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType) + val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType)!! val iterableDetector = IterableTypesDetector(project, moduleDescriptor, scope) return buildResultByTypeFilter(expressionWithType, receiver, Tail.RPARENTH) { iterableDetector.isIterable(it, loopVarType) } @@ -403,7 +403,7 @@ class SmartCompletion( if (operationToken != JetTokens.IN_KEYWORD && operationToken != JetTokens.NOT_IN || expressionWithType != binaryExpression.getRight()) return null val leftOperandType = binaryExpression.getLeft()?.let { bindingContext.getType(it) } ?: return null - val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType) + val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType)!! val detector = TypesWithContainsDetector(scope, leftOperandType, project, moduleDescriptor) return buildResultByTypeFilter(expressionWithType, receiver, null) { detector.hasContains(it) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt index 985c2a7ba34..671f6a9386c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt @@ -56,7 +56,7 @@ class TypesWithContainsDetector( } private fun isGoodContainsFunction(function: FunctionDescriptor, freeTypeParams: Collection): Boolean { - if (!TypeUtils.equalTypes(function.getReturnType(), booleanType)) return false + if (!TypeUtils.equalTypes(function.getReturnType()!!, booleanType)) return false val parameter = function.getValueParameters().singleOrNull() ?: return false val parameterType = HeuristicSignatures.correctedParameterType(function, parameter, moduleDescriptor, project) ?: parameter.getType() val fuzzyParameterType = FuzzyType(parameterType, function.getTypeParameters() + freeTypeParams) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt index cb1c7208726..4fd39209eaf 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt @@ -270,7 +270,7 @@ fun LookupElementFactory.createLookupElement( element = element.keepOldArgumentListOnTab() } - if (descriptor is ValueParameterDescriptor && bindingContext[BindingContext.AUTO_CREATED_IT, descriptor]) { + if (descriptor is ValueParameterDescriptor && bindingContext[BindingContext.AUTO_CREATED_IT, descriptor]!!) { element = element.assignSmartCompletionPriority(SmartCompletionItemPriority.IT) } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt index 9a39a6ba284..ffee1ebd989 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt @@ -38,7 +38,7 @@ fun DeclarationDescriptorWithVisibility.isVisible( val receiver = element.getReceiverExpression() val type = receiver?.let { bindingContext.getType(it) } - val explicitReceiver = type?.let { ExpressionReceiver(receiver, it) } + val explicitReceiver = type?.let { ExpressionReceiver(receiver!!, it) } if (explicitReceiver != null) { val normalizeReceiver = ExpressionTypingUtils.normalizeReceiverValueForVisibility(explicitReceiver, bindingContext) diff --git a/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt b/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt index ad52b721093..7ceb7d9087d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt @@ -37,8 +37,8 @@ public class ExtraSteppingFilter : engine.ExtraSteppingFilter { } val debugProcess = context.getDebugProcess() - val positionManager = JetPositionManager(debugProcess) - val location = context.getFrameProxy().location() + val positionManager = JetPositionManager(debugProcess!!) + val location = context.getFrameProxy()!!.location() return runReadAction { shouldFilter(positionManager, location) } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt index 9808c6faa10..be7f8237291 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt @@ -34,7 +34,7 @@ public abstract class ConfigureKotlinInProjectAction : AnAction() { if (project == null) return if (ConfigureKotlinInProjectUtils.isProjectConfigured(project)) { - Messages.showInfoMessage("All modules with kotlin files are configured", e.getPresentation().getText()) + Messages.showInfoMessage("All modules with kotlin files are configured", e.getPresentation().getText()!!) return } @@ -42,9 +42,9 @@ public abstract class ConfigureKotlinInProjectAction : AnAction() { when { configurators.size() == 1 -> configurators.first().configure(project) - configurators.isEmpty() -> Messages.showErrorDialog("There aren't configurators available", e.getPresentation().getText()) + configurators.isEmpty() -> Messages.showErrorDialog("There aren't configurators available", e.getPresentation().getText()!!) else -> { - Messages.showErrorDialog("More than one configurator is available", e.getPresentation().getText()) + Messages.showErrorDialog("More than one configurator is available", e.getPresentation().getText()!!) ConfigureKotlinInProjectUtils.showConfigureKotlinNotificationIfNeeded(project) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt index 3780b3a5574..8b6e6c37441 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt @@ -303,7 +303,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor { - val result = file.getChildren().filter { it is JetClassOrObject }.map { (it as JetClassOrObject).getName() } + val result = file.getChildren().filter { it is JetClassOrObject }.map { (it as JetClassOrObject).getName()!! } val packagePartFqName = PackagePartClassUtils.getPackagePartFqName(file) return result.union(arrayListOf(packagePartFqName.shortName().asString())) } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt index 410af8f4aae..f79fe006813 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt @@ -107,7 +107,7 @@ public class JetPositionManager(private val myDebugProcess: DebugProcess) : Mult if (lineNumber >= 0) { val lambdaOrFunIfInside = getLambdaOrFunIfInside(location, psiFile as JetFile, lineNumber) if (lambdaOrFunIfInside != null) { - return SourcePosition.createFromElement(lambdaOrFunIfInside.getBodyExpression()) + return SourcePosition.createFromElement(lambdaOrFunIfInside.getBodyExpression()!!) } return SourcePosition.createFromLine(psiFile, lineNumber) } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt index 2e27c137231..39ed62caaab 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt @@ -104,7 +104,7 @@ class KotlinEditorTextProvider : EditorTextProvider { fun PsiElement.isCall() = this is JetCallExpression || this is JetOperationExpression || this is JetArrayAccessExpression if (newExpression.isCall() || - newExpression is JetQualifiedExpression && newExpression.getSelectorExpression().isCall()) { + newExpression is JetQualifiedExpression && newExpression.getSelectorExpression()!!.isCall()) { return null } } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt index a57469c6ca5..fe79d14622a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt @@ -69,7 +69,7 @@ private fun findAdditionalExpressions(position: SourcePosition): Set() + val elt = file.findElementAt(caretOffset - 1)!!.getStrictParentOfType() if (elt != null) { reformat(elt) } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt index 54dea8f5d87..0bc7c3a4e51 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt @@ -58,7 +58,7 @@ class DelegatingFindMemberUsagesHandler( return kotlinHandler.getPrimaryElements() } - override fun getSecondaryElements(): Array? { + override fun getSecondaryElements(): Array { return kotlinHandler.getSecondaryElements() } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt index 96044154f13..8905dd83ef4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt @@ -119,7 +119,7 @@ public class KotlinFindClassUsagesHandler( var stringsToSearch: Collection object: JavaFindUsagesHandler(psiClass, JavaFindUsagesHandlerFactory.getInstance(element.getProject())) { init { - stringsToSearch = getStringsToSearch(psiClass) + stringsToSearch = getStringsToSearch(psiClass)!! } } return stringsToSearch diff --git a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt index e417457cf5d..79f7724abf4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt @@ -30,7 +30,7 @@ public class KotlinTemplatesFactory : ProjectTemplatesFactory() { override fun getGroups() = arrayOf(KOTLIN_GROUP_NAME) override fun getGroupIcon(group: String) = JetIcons.SMALL_LOGO - override fun createTemplates(group: String, context: WizardContext?) = + override fun createTemplates(group: String?, context: WizardContext?) = arrayOf( BuilderBasedTemplate(KotlinModuleBuilder(TargetPlatform.JVM, "Kotlin - JVM", "Kotlin module for JVM target")), BuilderBasedTemplate(KotlinModuleBuilder(TargetPlatform.JS, "Kotlin - JavaScript", "Kotlin module for JavaScript target")) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt index 8f6283189ab..57a72dd8c97 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt @@ -188,7 +188,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { private fun isConventionalName(namedDeclaration: JetNamedDeclaration): Boolean { val name = namedDeclaration.getNameAsName() - return name.getOperationSymbolsToSearch().isNotEmpty() || name == OperatorConventions.INVOKE + return name!!.getOperationSymbolsToSearch().isNotEmpty() || name == OperatorConventions.INVOKE } private fun hasNonTrivialUsages(declaration: JetNamedDeclaration): Boolean { @@ -200,7 +200,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { for (name in listOf(declaration.getName()) + declaration.getAccessorNames() + declaration.getClassNameForCompanionObject().singletonOrEmptyList()) { assert(name != null) { "Name is null for " + declaration.getElementTextWithContext() } - when (psiSearchHelper.isCheapEnoughToSearch(name, useScope, null, null)) { + when (psiSearchHelper.isCheapEnoughToSearch(name!!, useScope, null, null)) { ZERO_OCCURRENCES -> {} // go on, check other names FEW_OCCURRENCES -> zeroOccurrences = false TOO_MANY_OCCURRENCES -> return true // searching usages is too expensive; behave like it is used diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt index 08334bcac61..3f3b11d2e3c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt @@ -94,7 +94,7 @@ public class DeprecatedCallableAddReplaceWithIntention : JetSelfTargetingRangeIn }.toString() var argument = psiFactory.createArgument(psiFactory.createExpression(argumentText)) - argument = annotationEntry.getValueArgumentList().addArgument(argument) + argument = annotationEntry.getValueArgumentList()!!.addArgument(argument) argument = ShortenReferences.DEFAULT.process(argument) as JetValueArgument PsiDocumentManager.getInstance(argument.getProject()).doPostponedOperationsAndUnblockDocument(editor.getDocument()) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt index ec785497546..8c430d1e63a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt @@ -50,7 +50,7 @@ public class IterateExpressionIntention : JetSelfTargetingIntention.isAvailable(project, editor, file)) && (anySuggestionFound ?: !suggestions.isEmpty()) - override fun invoke(project: Project, editor: Editor?, file: JetFile?) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { CommandProcessor.getInstance().runUndoTransparentAction { createAction(project, editor!!).execute() } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntryDelimiterSyntaxFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntryDelimiterSyntaxFix.kt index 0e8d8fc63b1..db0d842e11a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntryDelimiterSyntaxFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntryDelimiterSyntaxFix.kt @@ -38,7 +38,7 @@ class DeprecatedEnumEntryDelimiterSyntaxFix(element: JetEnumEntry): JetIntention override fun getText(): String = "Insert lacking comma(s) / semicolon(s)" - override fun invoke(project: Project, editor: Editor?, file: JetFile?) = insertLackingCommaSemicolon(element) + override fun invoke(project: Project, editor: Editor?, file: JetFile) = insertLackingCommaSemicolon(element) override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean = super.isAvailable(project, editor, file) && DeclarationsChecker.enumEntryUsesDeprecatedOrNoDelimiter(element) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntrySuperConstructorSyntaxFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntrySuperConstructorSyntaxFix.kt index 6ac30ab803c..b7d52f8d906 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntrySuperConstructorSyntaxFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntrySuperConstructorSyntaxFix.kt @@ -41,7 +41,7 @@ class DeprecatedEnumEntrySuperConstructorSyntaxFix(element: JetEnumEntry): JetIn override fun getText(): String = "Change to short enum entry super constructor" - override fun invoke(project: Project, editor: Editor?, file: JetFile?) = changeConstructorToShort(element) + override fun invoke(project: Project, editor: Editor?, file: JetFile) = changeConstructorToShort(element) override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean = super.isAvailable(project, editor, file) && DeclarationsChecker.enumEntryUsesDeprecatedSuperConstructor(element) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedLambdaSyntaxFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedLambdaSyntaxFix.kt index 8f9592649f3..75da5826ca5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedLambdaSyntaxFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedLambdaSyntaxFix.kt @@ -110,6 +110,7 @@ private class LambdaToFunctionExpression( assert(functionLiteralType != null && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(functionLiteralType)) { "Broken function type for expression: ${functionLiteralExpression.getText()}, at: ${DiagnosticUtils.atLocation(functionLiteralExpression)}" } + functionLiteralType!! receiverType = KotlinBuiltIns.getReceiverType(functionLiteralType)?.let { IdeDescriptorRenderers.SOURCE_CODE.renderType(it) } returnType = KotlinBuiltIns.getReturnTypeFromFunctionType(functionLiteralType).let { if (KotlinBuiltIns.isUnit(it)) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt index fd9edd37e45..23f76759d79 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt @@ -112,7 +112,7 @@ public abstract class DeprecatedSymbolUsageFixBase( if (pattern.isEmpty()) return null val importValues = replaceWithValue.argumentValue("imports"/*TODO: kotlin.ReplaceWith::imports.name*/) as? List<*> ?: return null if (importValues.any { it !is StringValue }) return null - val imports = importValues.map { (it as StringValue).getValue() } + val imports = importValues.map { (it as StringValue).getValue()!! } // should not be available for descriptors with optional parameters if we cannot fetch default values for them (currently for library with no sources) if (descriptor is CallableDescriptor && @@ -681,7 +681,7 @@ public abstract class DeprecatedSymbolUsageFixBase( var explicitType: JetType? = null if (valueType != null && !ErrorUtils.containsErrorType(valueType)) { val valueTypeWithoutExpectedType = value.analyzeInContext( - resolutionScope, + resolutionScope!!, dataFlowInfo = bindingContext.getDataFlowInfo(expressionToBeReplaced) ).getType(value) if (valueTypeWithoutExpectedType == null || ErrorUtils.containsErrorType(valueTypeWithoutExpectedType)) { @@ -690,7 +690,7 @@ public abstract class DeprecatedSymbolUsageFixBase( } val name = suggestName { name -> - resolutionScope.getLocalVariable(Name.identifier(name)) == null && !isNameUsed(name) + resolutionScope!!.getLocalVariable(Name.identifier(name)) == null && !isNameUsed(name) } var declaration = psiFactory.createDeclarationByPattern("val $0 = $1", name, value) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedTraitSyntaxFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedTraitSyntaxFix.kt index 8ae58d0594c..96371716e0e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedTraitSyntaxFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedTraitSyntaxFix.kt @@ -31,7 +31,7 @@ public class DeprecatedTraitSyntaxFix(element: PsiElement): JetIntentionAction

( predicate = { it.getNode().findChildByType(JetTokens.TRAIT_KEYWORD) != null }, - taskProcessor = { replaceWithInterfaceKeyword(it.getNode().findChildByType(JetTokens.TRAIT_KEYWORD).getPsi())}, + taskProcessor = { replaceWithInterfaceKeyword(it.getNode().findChildByType(JetTokens.TRAIT_KEYWORD)!!.getPsi())}, name = "Replace 'trait' with 'interface' in whole project" ) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExlCallFixes.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExlCallFixes.kt index b94d10f4ab7..ad5ff7f157d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExlCallFixes.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExlCallFixes.kt @@ -50,7 +50,7 @@ public class RemoveExclExclCallFix(val psiElement: PsiElement) : ExclExclCallFix if (!FileModificationService.getInstance().prepareFileForWrite(file)) return val postfixExpression = getExclExclPostfixExpression() ?: return - val expression = JetPsiFactory(project).createExpression(postfixExpression.getBaseExpression().getText()) + val expression = JetPsiFactory(project).createExpression(postfixExpression.getBaseExpression()!!.getText()) postfixExpression.replace(expression) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt index 8525091469d..e0b8b995007 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt @@ -41,7 +41,7 @@ public class InsertDelegationCallQuickfix(val isThis: Boolean, element: JetSecon private val keywordToUse = if (isThis) "this" else "super" - override fun invoke(project: Project, editor: Editor?, file: JetFile?) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { val newDelegationCall = element.replaceImplicitDelegationCallWithExplicit(isThis) val resolvedCall = newDelegationCall.getResolvedCall(newDelegationCall.analyze()) @@ -55,7 +55,7 @@ public class InsertDelegationCallQuickfix(val isThis: Boolean, element: JetSecon editor?.moveCaret(leftParOffset + 1) } - override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?): Boolean { + override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean { return super.isAvailable(project, editor, file) && element.hasImplicitDelegationCall() } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/MigrateAnnotationMethodCallFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/MigrateAnnotationMethodCallFix.kt index 40838b7a53f..c0e4f5dfe0d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/MigrateAnnotationMethodCallFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/MigrateAnnotationMethodCallFix.kt @@ -35,7 +35,7 @@ public class MigrateAnnotationMethodCallFix( override fun getText() = "Replace method call with property access" override fun getFamilyName() = getText() - override fun invoke(project: Project, editor: Editor?, file: JetFile?) = replaceWithSimpleCall(element) + override fun invoke(project: Project, editor: Editor?, file: JetFile) = replaceWithSimpleCall(element) companion object : JetSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic) = diagnostic.createIntentionForFirstParentOfType(::MigrateAnnotationMethodCallFix) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt index a9803eb9693..adcf66ebf8e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt @@ -30,7 +30,7 @@ public class MissingConstructorKeywordFix(element: JetPrimaryConstructor) : JetI override fun getFamilyName(): String = getText() override fun getText(): String = "Add 'constructor' keyword" - override fun invoke(project: Project, editor: Editor?, file: JetFile?) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { element.addConstructorKeyword() } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt index 47598fb4195..488285da8ad 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType import org.jetbrains.kotlin.resolve.BindingContext -public class ReplaceObsoleteLabelSyntaxFix(element: JetAnnotationEntry?) : JetIntentionAction(element), CleanupFix { +public class ReplaceObsoleteLabelSyntaxFix(element: JetAnnotationEntry) : JetIntentionAction(element), CleanupFix { override fun getFamilyName(): String = "Update obsolete label syntax" override fun getText(): String = "Replace with label ${element.getCalleeExpression()?.getText() ?: ""}@" @@ -65,7 +65,7 @@ public class ReplaceObsoleteLabelSyntaxFix(element: JetAnnotationEntry?) : JetIn val baseExpression = (getParent() as? JetAnnotatedExpression)?.getBaseExpression() ?: return false - val nameExpression = getCalleeExpression().getConstructorReferenceExpression() ?: return false + val nameExpression = getCalleeExpression()?.getConstructorReferenceExpression() ?: return false val labelName = nameExpression.getReferencedName() return baseExpression.anyDescendantOfType { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt index 3594cc4a370..9b3abd6a43b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt @@ -182,7 +182,7 @@ object ReplaceWithAnnotationAnalyzer { RedeclarationHandler.DO_NOTHING) is LocalVariableDescriptor -> { val declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor) as JetDeclaration - declaration.analyze()[BindingContext.RESOLUTION_SCOPE, declaration] + declaration.analyze()[BindingContext.RESOLUTION_SCOPE, declaration]!! } //TODO? diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt index 97b71773d8a..70b12ca477a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt @@ -297,7 +297,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { .subtract(substitutionMap.keySet()) fakeFunction = createFakeFunctionDescriptor(scope, typeArgumentsForFakeFunction.size()) collectSubstitutionsForCallableTypeParameters(fakeFunction, typeArgumentsForFakeFunction, substitutionMap) - mandatoryTypeParametersAsCandidates = receiverTypeCandidate.singletonOrEmptyList() + typeArgumentsForFakeFunction.map { TypeCandidate(substitutionMap[it], scope) } + mandatoryTypeParametersAsCandidates = receiverTypeCandidate.singletonOrEmptyList() + typeArgumentsForFakeFunction.map { TypeCandidate(substitutionMap[it]!!, scope) } } else { fakeFunction = null @@ -949,7 +949,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { } is JetProperty -> { if (!declaration.hasInitializer() && containingElement is JetBlockExpression) { - val defaultValueType = typeCandidates[callableInfo.returnTypeInfo].firstOrNull()?.theType + val defaultValueType = typeCandidates[callableInfo.returnTypeInfo]!!.firstOrNull()?.theType ?: KotlinBuiltIns.getInstance().getAnyType() val defaultValue = CodeInsightUtils.defaultInitializer(defaultValueType) ?: "null" val initializer = declaration.setInitializer(JetPsiFactory(declaration).createExpression(defaultValue))!! @@ -975,7 +975,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { val caretModel = containingFileEditor.getCaretModel() caretModel.moveToOffset(jetFileToEdit.getNode().getStartOffset()) - val declaration = declarationPointer.getElement() + val declaration = declarationPointer.getElement()!! val builder = TemplateBuilderImpl(jetFileToEdit) if (declaration is JetProperty) { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt index 6005a4456e2..2dcbe735809 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt @@ -120,11 +120,11 @@ public abstract class CreateCallableFromUsageFixBase( } } - override fun invoke(project: Project, editor: Editor?, file: JetFile?) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { val callableInfo = callableInfos.first() val callableBuilder = - CallableBuilderConfiguration(callableInfos, element as JetElement, file!!, editor!!, isExtension).createBuilder() + CallableBuilderConfiguration(callableInfos, element as JetElement, file, editor!!, isExtension).createBuilder() fun runBuilder(placement: CallablePlacement) { callableBuilder.placement = placement diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt index fb77409dad9..2949a68f189 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt @@ -80,7 +80,7 @@ public class CreateClassFromUsageFix( return true } - override fun invoke(project: Project, editor: Editor, file: JetFile) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { fun createFileByPackage(psiPackage: PsiPackage): JetFile? { val directories = psiPackage.getDirectories().filter { it.canRefactor() } assert (directories.isNotEmpty()) { "Package '${psiPackage.getQualifiedName()}' must be refactorable" } @@ -103,7 +103,7 @@ public class CreateClassFromUsageFix( val filePath = "${targetDirectory.getVirtualFile().getPath()}/$fileName" CodeInsightUtils.showErrorHint( targetDirectory.getProject(), - editor, + editor!!, "File $filePath already exists but does not correspond to Kotlin file", "Create file", null diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateLocalVariableActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateLocalVariableActionFactory.kt index 6f2e08a1d8a..b714b19697c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateLocalVariableActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateLocalVariableActionFactory.kt @@ -50,7 +50,7 @@ object CreateLocalVariableActionFactory: JetSingleIntentionActionFactory() { return object: CreateFromUsageFixBase(refExpr) { override fun getText(): String = JetBundle.message("create.local.variable.from.usage", propertyName) - override fun invoke(project: Project, editor: Editor, file: JetFile) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { val assignment = refExpr.getAssignmentByLHS() val varExpected = assignment != null var originalElement = assignment ?: refExpr diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt index ceecb9c301d..9111b5bf729 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt @@ -37,7 +37,7 @@ public class CreateParameterFromUsageFix( return JetBundle.message("create.parameter.from.usage", parameterInfo.getName()) } - override fun invoke(project: Project, editor: Editor?, file: JetFile?) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { val config = object : JetChangeSignatureConfiguration { override fun configure(originalDescriptor: JetMethodDescriptor, bindingContext: BindingContext): JetMethodDescriptor { return originalDescriptor.modify { it.addParameter(parameterInfo) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt index 9cc6f918034..4aa9fd89aa3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt @@ -212,7 +212,7 @@ public class JetChangeInfo( public fun renderReturnType(inheritedCallable: JetCallableDefinitionUsage): String { val typeSubstitutor = inheritedCallable.getOrCreateTypeSubstitutor() ?: return newReturnTypeText val currentBaseFunction = inheritedCallable.getBaseFunction().getCurrentCallableDescriptor() ?: return newReturnTypeText - return currentBaseFunction.getReturnType().renderTypeWithSubstitution(typeSubstitutor, newReturnTypeText, false) + return currentBaseFunction.getReturnType()!!.renderTypeWithSubstitution(typeSubstitutor, newReturnTypeText, false) } public fun primaryMethodUpdated() { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt index d92efb82d2e..ea42b360901 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt @@ -171,7 +171,7 @@ public class JetChangeSignature(project: Project, val params = (preview.getParameterList().getParameters() zip ktChangeInfo.getNewParameters()).map { val (param, paramInfo) = it // Keep original default value for proper update of Kotlin usages - KotlinAwareJavaParameterInfoImpl(paramInfo.getOldIndex(), param.getName(), param.getType(), paramInfo.defaultValueForCall) + KotlinAwareJavaParameterInfoImpl(paramInfo.getOldIndex(), param.getName()!!, param.getType(), paramInfo.defaultValueForCall) }.toTypedArray() return preview to JavaChangeInfoImpl(visibility, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt index 8f4eada231b..0f0b43c0309 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt @@ -99,7 +99,7 @@ public class JetChangeSignatureData( descriptorsForSignatureChange.map { val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(baseDeclaration.getProject(), it) assert(declaration != null) { "No declaration found for " + baseDescriptor } - JetCallableDefinitionUsage(declaration, it, null, null) + JetCallableDefinitionUsage(declaration!!, it, null, null) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt index 7f79fa4e481..6027764c88b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt @@ -85,7 +85,7 @@ public abstract class AbstractKotlinInplaceIntroducer( override fun updateTitle(declaration: D?) = updateTitle(declaration, null) - override fun saveSettings(declaration: D?) { + override fun saveSettings(declaration: D) { } } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt index eba4e33f276..ae9185b1ce1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt @@ -309,7 +309,7 @@ val ControlFlow.possibleReturnTypes: List returnType.isAnnotatedNotNull(), returnType.isAnnotatedNullable() -> listOf(approximateFlexibleTypes(returnType)) else -> - returnType.getCapability(javaClass()).let { listOf(it.upperBound, it.lowerBound) } + returnType.getCapability(javaClass()).let { listOf(it!!.upperBound, it.lowerBound) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt index 59612298acf..49106b2830d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt @@ -520,7 +520,7 @@ private class MutableParameter( private val defaultType: JetType by Delegates.lazy { writable = false - TypeUtils.intersect(JetTypeChecker.DEFAULT, defaultTypes) + TypeUtils.intersect(JetTypeChecker.DEFAULT, defaultTypes)!! } private val parameterTypeCandidates: List by Delegates.lazy { @@ -530,7 +530,7 @@ private class MutableParameter( val typeList = if (defaultType.isNullabilityFlexible()) { val bounds = defaultType.getCapability(javaClass()) - if (typePredicate(bounds.upperBound)) arrayListOf(bounds.upperBound, bounds.lowerBound) else arrayListOf(bounds.lowerBound) + if (typePredicate(bounds!!.upperBound)) arrayListOf(bounds.upperBound, bounds.lowerBound) else arrayListOf(bounds.lowerBound) } else arrayListOf(defaultType) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt index 8c05f0a9ad4..245e8137df1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt @@ -275,7 +275,7 @@ private fun makeCall( val inlinableCall = controlFlow.outputValues.size() <= 1 val unboxingExpressions = if (inlinableCall) { - controlFlow.outputValueBoxer.getUnboxingExpressions(callText) + controlFlow.outputValueBoxer.getUnboxingExpressions(callText!!) } else { val varNameValidator = NewDeclarationNameValidator(block, anchorInBlock, NewDeclarationNameValidator.Target.VARIABLES) @@ -293,7 +293,7 @@ private fun makeCall( } if (controlFlow.outputValues.isEmpty()) { - anchor.replace(psiFactory.createExpression(callText)) + anchor.replace(psiFactory.createExpression(callText!!)) return } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt index dda2333174d..001c0b030bc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt @@ -135,7 +135,7 @@ public class KotlinInplaceParameterIntroducer( val parameterText = if (parameter == addedParameter){ val parameterName = currentName ?: parameter.getName() val parameterType = currentType ?: parameter.getTypeReference()!!.getText() - descriptor = descriptor.copy(newParameterName = parameterName, newParameterTypeText = parameterType) + descriptor = descriptor.copy(newParameterName = parameterName!!, newParameterTypeText = parameterType) val modifier = if (valVar != JetValVar.None) "${valVar.name} " else "" val defaultValue = if (withDefaultValue) " = ${newArgumentValue.getText()}" else "" @@ -250,7 +250,7 @@ public class KotlinInplaceParameterIntroducer( return descriptor.copy( originalRange = originalRange, occurrencesToReplace = if (replaceAll) getOccurrences().map { it.toRange() } else originalRange.singletonList(), - newArgumentValue = getExpr() + newArgumentValue = getExpr()!! ) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt index 190a7cc24b3..718ae8afbf4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt @@ -210,7 +210,7 @@ public open class KotlinIntroduceParameterHandler( open fun invoke(project: Project, editor: Editor, expression: JetExpression, targetParent: JetNamedDeclaration) { val context = expression.analyze() - val expressionType = context.getType(expression) + val expressionType = context.getType(expression)!! if (expressionType.isUnit() || expressionType.isNothing()) { val message = JetRefactoringBundle.message( "cannot.introduce.parameter.of.0.type", diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt index 6340a695db6..36041e20f18 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt @@ -406,7 +406,7 @@ private fun copyModifierListItems(from: PsiModifierList, to: PsiModifierList, wi } } for (annotation in from.getAnnotations()) { - to.addAnnotation(annotation.getQualifiedName()) + to.addAnnotation(annotation.getQualifiedName()!!) } } @@ -426,7 +426,7 @@ private fun copyTypeParameters( ChangeSignatureUtil.synchronizeList( targetTypeParamList, newTypeParams, - { it.getTypeParameters().toList() }, + { it!!.getTypeParameters().toList() }, BooleanArray(newTypeParams.size()) ) } @@ -456,8 +456,8 @@ public fun createJavaMethod(template: PsiMethod, targetClass: PsiClass): PsiMeth val targetParamList = method.getParameterList() val newParams = template.getParameterList().getParameters().map { - val param = factory.createParameter(it.getName(), it.getType()) - copyModifierListItems(it.getModifierList(), param.getModifierList()) + val param = factory.createParameter(it.getName()!!, it.getType()) + copyModifierListItems(it.getModifierList()!!, param.getModifierList()!!) param } ChangeSignatureUtil.synchronizeList( @@ -468,7 +468,7 @@ public fun createJavaMethod(template: PsiMethod, targetClass: PsiClass): PsiMeth ) if (template.getModifierList().hasModifierProperty(PsiModifier.ABSTRACT) || targetClass.isInterface()) { - method.getBody().delete() + method.getBody()!!.delete() } else if (!template.isConstructor()) { CreateFromUsageUtils.setupMethodBody(method) @@ -482,9 +482,9 @@ fun createJavaField(property: JetProperty, targetClass: PsiClass): PsiField { ?: throw AssertionError("Can't generate light method: ${property.getElementTextWithContext()}") val factory = PsiElementFactory.SERVICE.getInstance(template.getProject()) - val field = targetClass.add(factory.createField(property.getName(), template.getReturnType())) as PsiField + val field = targetClass.add(factory.createField(property.getName()!!, template.getReturnType()!!)) as PsiField - with(field.getModifierList()) { + with(field.getModifierList()!!) { val templateModifiers = template.getModifierList() setModifierProperty(VisibilityUtil.getVisibilityModifier(templateModifiers), true) if (!property.isVar() || targetClass.isInterface()) { @@ -500,11 +500,12 @@ fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember { val kind = (klass.resolveToDescriptor() as ClassDescriptor).getKind() val factory = PsiElementFactory.SERVICE.getInstance(klass.getProject()) + val className = klass.getName()!! val javaClassToAdd = when (kind) { - ClassKind.CLASS -> factory.createClass(klass.getName()) - ClassKind.INTERFACE -> factory.createInterface(klass.getName()) - ClassKind.ANNOTATION_CLASS -> factory.createAnnotationType(klass.getName()) - ClassKind.ENUM_CLASS -> factory.createEnum(klass.getName()) + ClassKind.CLASS -> factory.createClass(className) + ClassKind.INTERFACE -> factory.createInterface(className) + ClassKind.ANNOTATION_CLASS -> factory.createAnnotationType(className) + ClassKind.ENUM_CLASS -> factory.createEnum(className) else -> throw AssertionError("Unexpected class kind: ${klass.getElementTextWithContext()}") } val javaClass = targetClass.add(javaClassToAdd) as PsiClass @@ -512,9 +513,9 @@ fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember { val template = LightClassUtil.getPsiClass(klass) ?: throw AssertionError("Can't generate light class: ${klass.getElementTextWithContext()}") - copyModifierListItems(template.getModifierList(), javaClass.getModifierList()) + copyModifierListItems(template.getModifierList()!!, javaClass.getModifierList()!!) if (template.isInterface()) { - javaClass.getModifierList().setModifierProperty(PsiModifier.ABSTRACT, false) + javaClass.getModifierList()!!.setModifierProperty(PsiModifier.ABSTRACT, false) } copyTypeParameters(template, javaClass) { klass, typeParameterList -> @@ -542,7 +543,7 @@ fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember { if (method.isConstructor() && !(hasParams || needSuperCall)) continue with(createJavaMethod(method, javaClass)) { if (isConstructor() && needSuperCall) { - getBody().add(factory.createStatementFromText("super();", this)) + getBody()!!.add(factory.createStatementFromText("super();", this)) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt index 4192974b79b..38527955601 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt @@ -103,7 +103,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor( private val kotlinToLightElements = elementsToMove.keysToMap { it.toLightElements() } private val conflicts = MultiMap() - override fun createUsageViewDescriptor(usages: Array?): UsageViewDescriptor { + override fun createUsageViewDescriptor(usages: Array): UsageViewDescriptor { return MoveMultipleElementsViewDescriptor( elementsToMove.toTypedArray(), MoveClassesOrPackagesUtil.getPackageName(options.moveTarget.packageWrapper) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveFilesOrDirectoriesDialogWithKotlinOptions.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveFilesOrDirectoriesDialogWithKotlinOptions.kt index 2f57dcb2e67..5a15178861c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveFilesOrDirectoriesDialogWithKotlinOptions.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveFilesOrDirectoriesDialogWithKotlinOptions.kt @@ -53,7 +53,7 @@ public class MoveFilesOrDirectoriesDialogWithKotlinOptions( gbc.fill = GridBagConstraints.NONE gbc.anchor = GridBagConstraints.WEST gbc.insets = Insets(UIUtil.LARGE_VGAP, 0, 0, UIUtil.DEFAULT_HGAP) - panel.add(JLabel(), gbc) + panel!!.add(JLabel(), gbc) cbUpdatePackageDirective = NonFocusableCheckBox() gbc.gridx = 1 diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt index 509713d0e48..029ac09a417 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt @@ -311,7 +311,7 @@ public fun moveFilesOrDirectories( } elementsToMove.forEach { - MoveFilesOrDirectoriesUtil.checkMove(it, selectedDir) + MoveFilesOrDirectoriesUtil.checkMove(it, selectedDir!!) if (it is JetFile && it.isInJavaSourceRoot()) { it.updatePackageDirective = updatePackageDirective } diff --git a/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt b/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt index c890df62468..3143de9ebe7 100644 --- a/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt @@ -44,7 +44,7 @@ public abstract class AbstractDataFlowValueRenderingTest: JetLightCodeInsightFix fixture.configureByFile(fileName) val jetFile = fixture.getFile() as JetFile - val element = jetFile.findElementAt(fixture.getCaretOffset()) + val element = jetFile.findElementAt(fixture.getCaretOffset())!! val expression = element.getStrictParentOfType()!! val info = expression.analyze().getDataFlowInfo(expression) diff --git a/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt b/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt index 42e0f72de96..1c9ac78d62f 100644 --- a/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt +++ b/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt @@ -50,7 +50,7 @@ public abstract class AbstractAddImportTest : AbstractImportsTest() { else -> { val success = ImportInsertHelper.getInstance(getProject()).importDescriptor(file, descriptors.single()) != ImportInsertHelper.ImportDescriptorResult.FAIL if (!success) { - val document = PsiDocumentManager.getInstance(getProject()).getDocument(file) + val document = PsiDocumentManager.getInstance(getProject()).getDocument(file)!! document.replaceString(0, document.getTextLength(), "Failed to add import") PsiDocumentManager.getInstance(getProject()).commitAllDocuments() } diff --git a/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt b/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt index 63aeddfd2d5..80044d17d57 100644 --- a/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt @@ -57,6 +57,7 @@ class LightClassesClasspathSortingTest : KotlinCodeInsightTestCase() { val psiClass = JavaPsiFacade.getInstance(getProject()).findClass(fqName, ResolveScopeManager.getElementResolveScope(getFile())) assertNotNull(psiClass, "Can't find class for $fqName") + psiClass!! assert(psiClass is KotlinLightClassForExplicitDeclaration || psiClass is KotlinLightClassForPackage, "Should be an explicit light class, but was $fqName ${psiClass.javaClass}") assert(psiClass !is KotlinLightClassForDecompiledDeclaration, diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt index 60b1ca1e2b8..16d6b9c2c24 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt @@ -99,7 +99,7 @@ private fun JavaCodeInsightTestFixture.configureByCodeFragment(filePath: String) file.putCopyableUserData(JetCodeFragment.RUNTIME_TYPE_EVALUATOR, { val codeFragment = JetPsiFactory(getProject()).createBlockCodeFragment("val xxx: $typeStr" , PsiTreeUtil.getParentOfType(elementAt, javaClass())) val context = codeFragment.analyzeFully() - val typeReference: JetTypeReference = PsiTreeUtil.getChildOfType(codeFragment.getContentElement().getFirstChild(), javaClass()) + val typeReference: JetTypeReference = PsiTreeUtil.getChildOfType(codeFragment.getContentElement().getFirstChild(), javaClass())!! context[BindingContext.TYPE, typeReference] }) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt index 2a3dc421c34..74e736fc930 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt @@ -277,7 +277,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB private fun createContextElement(context: SuspendContextImpl): PsiElement { val contextElement = ContextUtil.getContextElement(debuggerContext) - Assert.assertTrue("KotlinCodeFragmentFactory should be accepted for context element otherwise default evaluator will be called. ContextElement = ${contextElement.getText()}", + Assert.assertTrue("KotlinCodeFragmentFactory should be accepted for context element otherwise default evaluator will be called. ContextElement = ${contextElement?.getText() ?: "null"}", KotlinCodeFragmentFactory().isContextAccepted(contextElement)) if (contextElement != null) { @@ -290,9 +290,9 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB assert(labelParts.size() == 2) { "Wrong format for DEBUG_LABEL directive: // DEBUG_LABEL: {localVariableName} = {labelText}"} val localVariableName = labelParts[0].trim() val labelName = labelParts[1].trim() - val localVariable = context.getFrameProxy().visibleVariableByName(localVariableName) + val localVariable = context.getFrameProxy()!!.visibleVariableByName(localVariableName) assert(localVariable != null) { "Couldn't find localVariable for label: name = $localVariableName" } - val localVariableValue = context.getFrameProxy().getValue(localVariable) as? ObjectReference + val localVariableValue = context.getFrameProxy()!!.getValue(localVariable) as? ObjectReference assert(localVariableValue != null) { "Local variable $localVariableName should be an ObjectReference" } markupMap.put(localVariableValue, ValueMarkup(labelName, null, labelName)) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt index 5c981201fe7..55b099baf48 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt @@ -42,7 +42,7 @@ public class CodeFragmentCompletionInLibraryTest : AbstractJvmBasicCompletionTes override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry?) { super.configureModule(module, model, contentEntry) - val library = model.getModuleLibraryTable().getLibraryByName(JdkAndMockLibraryProjectDescriptor.LIBRARY_NAME) + val library = model.getModuleLibraryTable().getLibraryByName(JdkAndMockLibraryProjectDescriptor.LIBRARY_NAME)!! val modifiableModel = library.getModifiableModel() modifiableModel.addRoot(findLibrarySourceDir(), OrderRootType.SOURCES) @@ -75,7 +75,7 @@ public class CodeFragmentCompletionInLibraryTest : AbstractJvmBasicCompletionTes } private fun setupFixtureByCodeFragment(fragmentText: String) { - val sourceFile = findLibrarySourceDir().findChild("customLibrary.kt") + val sourceFile = findLibrarySourceDir().findChild("customLibrary.kt")!! val jetFile = PsiManager.getInstance(getProject()).findFile(sourceFile) as JetFile val fooFunctionFromLibrary = jetFile.getDeclarations().first() as JetFunction val codeFragment = JetPsiFactory(fooFunctionFromLibrary).createExpressionCodeFragment( diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt index 936df14f82b..b4b1d85e043 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt @@ -55,7 +55,7 @@ public class NavigateFromLibrarySourcesTest: LightCodeInsightFixtureTestCase() { val lightClass = LightClassUtil.getPsiClass(navigationElement as JetClassOrObject) assertTrue(lightClass is KotlinLightClassForDecompiledDeclaration, "Light classes for decompiled declaration should be provided for library source") - assertEquals("Foo", lightClass.getName()) + assertEquals("Foo", lightClass!!.getName()) } private fun checkNavigationFromLibrarySource(referenceText: String, targetFqName: String) { diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt index 41d89651a87..89273d5637d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt @@ -55,7 +55,7 @@ public abstract class AbstractClsStubBuilderTest : LightCodeInsightFixtureTestCa private fun getClassFileToDecompile(sourcePath: String): VirtualFile { val outDir = JetTestUtils.tmpDir("libForStubTest-" + sourcePath) MockLibraryUtil.compileKotlin(sourcePath, outDir) - val root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(outDir) + val root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(outDir)!! return root.findClassFileByName(lastSegment(sourcePath)) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubForWrongAbiVersionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubForWrongAbiVersionTest.kt index da40fdbf4f1..f10dc385560 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubForWrongAbiVersionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubForWrongAbiVersionTest.kt @@ -29,7 +29,7 @@ class ClsStubBuilderForWrongAbiVersionTest : AbstractClsStubBuilderTest() { fun testClass() = testStubsForFileWithWrongAbiVersion("ClassWithWrongAbiVersion") private fun testStubsForFileWithWrongAbiVersion(className: String) { - val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!) + val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!)!! val result = root.findClassFileByName(className) testClsStubsForFile(result, null) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt index 7c4bf7fd93f..a13d69e56aa 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt @@ -47,7 +47,7 @@ public class DecompiledTextForWrongAbiVersionTest : AbstractInternalCompiledClas fun testPackageFacadeWithWrongAbiVersion() = doTest("WrongPackage") fun doTest(name: String) { - val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!) + val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!)!! checkFileWithWrongAbiVersion(root.findClassFileByName(name)) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/filters/JetExceptionFilterTest.kt b/idea/tests/org/jetbrains/kotlin/idea/filters/JetExceptionFilterTest.kt index 69f5885a0bd..da9edf459f0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/filters/JetExceptionFilterTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/filters/JetExceptionFilterTest.kt @@ -87,21 +87,26 @@ public class JetExceptionFilterTest : MultiFileTestCase() { VfsUtilCore.findRelativeFile(relativePath, rootDir); } TestCase.assertNotNull(expectedFile) + expectedFile!! val line = createStackTraceElementLine(linePrefix, relativePath, className(expectedFile), lineNumber) val result = filter.applyFilter(line, 0) TestCase.assertNotNull(result) + result!! val info = result.getFirstHyperlinkInfo() TestCase.assertNotNull(info) info as FileHyperlinkInfo val descriptor = info.getDescriptor() TestCase.assertNotNull(descriptor) + descriptor!! TestCase.assertEquals(expectedFile, descriptor.getFile()) val document = FileDocumentManager.getInstance().getDocument(expectedFile) TestCase.assertNotNull(document) + document!! + val expectedOffset = document.getLineStartOffset(lineNumber - 1) TestCase.assertEquals(expectedOffset, descriptor.getOffset()) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt b/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt index 33daa939643..df96bdc109d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt @@ -33,7 +33,7 @@ public class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() { myFixture.configureByFile(getTestName(false) + ".kt") val declaration = (myFixture.getFile() as JetFile).getDeclarations()[0] val descriptor = declaration.resolveToDescriptor() as ClassDescriptor - val constructorDescriptor = descriptor.getUnsubstitutedPrimaryConstructor() + val constructorDescriptor = descriptor.getUnsubstitutedPrimaryConstructor()!! val doc = KDocFinder.findKDoc(constructorDescriptor) Assert.assertEquals("Doc for constructor of class C.", doc!!.getContent()) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/JetNameSuggesterTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/JetNameSuggesterTest.kt index af58246171e..b393f3bf470 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/JetNameSuggesterTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/JetNameSuggesterTest.kt @@ -68,8 +68,8 @@ public class JetNameSuggesterTest : LightCodeInsightFixtureTestCase() { val expectedResultText = JetTestUtils.getLastCommentInFile(file) try { JetRefactoringUtil.selectExpression(myFixture.getEditor(), file, object : JetRefactoringUtil.SelectExpressionCallback { - override fun run(expression: JetExpression) { - val names = KotlinNameSuggester.suggestNamesByExpressionAndType(expression, expression.analyze(BodyResolveMode.PARTIAL), { true }, "value").sort() + override fun run(expression: JetExpression?) { + val names = KotlinNameSuggester.suggestNamesByExpressionAndType(expression!!, expression.analyze(BodyResolveMode.PARTIAL), { true }, "value").sort() val result = StringUtil.join(names, "\n").trim() assertEquals(expectedResultText, result) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt index 58fb76b35b7..722ca5c1351 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt @@ -77,7 +77,7 @@ public abstract class AbstractPartialBodyResolveTest : JetLightCodeInsightFixtur } else { val offset = editor.getCaretModel().getOffset() - val element = file.findElementAt(offset) + val element = file.findElementAt(offset)!! element.getNonStrictParentOfType() ?: error("No JetSimpleNameExpression at caret") } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt index 5b3a131f422..e476666d487 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt @@ -328,7 +328,7 @@ class Converter private constructor( isVal && modifiers.isPrivate) val propertyType = typeToDeclare ?: typeConverter.convertVariableType(field) - addUsageProcessing(FieldToPropertyProcessing(field, correction?.name ?: field.getName(), propertyType.isNullable)) + addUsageProcessing(FieldToPropertyProcessing(field, correction?.name ?: field.getName()!!, propertyType.isNullable)) return Property(name, annotations, diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt index b6e03bb816c..8dfd6d108b2 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt @@ -317,6 +317,6 @@ class ForConverter( val declarationStatement = this as? PsiDeclarationStatement ?: return listOf() return declarationStatement.getDeclaredElements() .filterIsInstance() - .map { it.getName() } + .map { it.getName()!! } } } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt index dde1798069d..334151d7356 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt @@ -64,7 +64,7 @@ class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKi if (accessorKind == AccessorKind.GETTER) { if (arguments.size() != 0) return null // incorrect call propertyNameExpr = callExpr.replace(propertyNameExpr) as JetSimpleNameExpression - return listOf(propertyNameExpr.getReference()) + return listOf(propertyNameExpr.getReference()!!) } else { val value = arguments.singleOrNull()?.getArgumentExpression() ?: return null @@ -76,12 +76,12 @@ class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKi callExpr.replace(propertyNameExpr) assignment.getLeft()!!.replace(qualifiedExpression) assignment = qualifiedExpression.replace(assignment) as JetBinaryExpression - return listOf((assignment.getLeft() as JetQualifiedExpression).getSelectorExpression()!!.getReference()) + return listOf((assignment.getLeft() as JetQualifiedExpression).getSelectorExpression()!!.getReference()!!) } else { assignment.getLeft()!!.replace(propertyNameExpr) assignment = callExpr.replace(assignment) as JetBinaryExpression - return listOf(assignment.getLeft()!!.getReference()) + return listOf(assignment.getLeft()!!.getReference()!!) } } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt index 4f968b900c8..58f916b192f 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt @@ -124,7 +124,7 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v binary = setCall.getArgumentList().getExpressions().single() as PsiBinaryExpression getCall = binary.getLOperand() as PsiMethodCallExpression - return listOf(getCall.getMethodExpression().getReference(), setCall.getMethodExpression().getReference()) + return listOf(getCall.getMethodExpression().getReference()!!, setCall.getMethodExpression().getReference()!!) } private fun generateGetterCall(qualifier: PsiExpression?): PsiMethodCallExpression { diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt index d124bc48c23..21494e7a9bd 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt @@ -36,7 +36,7 @@ public class MethodIntoObjectProcessing(private val method: PsiMethod, private v else { var qualifiedExpr = factory.createExpressionFromText(objectName + "." + refExpr.getText(), null) as PsiReferenceExpression qualifiedExpr = refExpr.replace(qualifiedExpr) as PsiReferenceExpression - return listOf(qualifiedExpr.getReference()) + return listOf(qualifiedExpr.getReference()!!) } } } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt index 768f5e6c916..3b5c151e758 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt @@ -30,7 +30,7 @@ class ToObjectWithOnlyMethodsProcessing(private val psiClass: PsiClass) : UsageP val factory = PsiElementFactory.SERVICE.getInstance(psiClass.getProject()) var qualifiedExpr = factory.createExpressionFromText(refExpr.getText() + "." + JvmAbi.INSTANCE_FIELD, null) as PsiReferenceExpression qualifiedExpr = refExpr.replace(qualifiedExpr) as PsiReferenceExpression - return listOf(qualifiedExpr.getReference()) + return listOf(qualifiedExpr.getReference()!!) } } diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt index 7e04e7c4052..2fb84a3378a 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt @@ -150,14 +150,14 @@ public class IncrementalCacheImpl(targetDataRoot: File) : StorageOwner, Incremen val decision = when { header.isCompatiblePackageFacadeKind() -> getRecompilationDecision( - protoChanged = protoMap.put(className, BitEncoding.decodeBytes(header.annotationData)), + protoChanged = protoMap.put(className, BitEncoding.decodeBytes(header.annotationData!!)), constantsChanged = false, inlinesChanged = false ) header.isCompatibleClassKind() -> when (header.classKind!!) { JvmAnnotationNames.KotlinClass.Kind.CLASS -> getRecompilationDecision( - protoChanged = protoMap.put(className, BitEncoding.decodeBytes(header.annotationData)), + protoChanged = protoMap.put(className, BitEncoding.decodeBytes(header.annotationData!!)), constantsChanged = constantsMap.process(className, fileBytes), inlinesChanged = inlineFunctionsMap.process(className, fileBytes) ) diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt index 6ae59235b9c..5da8374ea31 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt @@ -292,7 +292,7 @@ public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() { val mapping = project.dataManager.getSourceToOutputMap(target) mapping.getSources().forEach { - val outputs = mapping.getOutputs(it).sort() + val outputs = mapping.getOutputs(it)!!.sort() if (outputs.isNotEmpty()) { result.println("source $it -> " + outputs) } diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt index 2a43145c6a8..546833050de 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt @@ -31,7 +31,7 @@ object RenderFirstLineOfElementText : Renderer { abstract class JsCallDataRenderer : Renderer { protected abstract fun format(data: JsCallDataWithCode): String - override fun render(data: JsCallData?): String = + override fun render(data: JsCallData): String = when (data) { is JsCallDataWithCode -> format(data) is JsCallData -> data.message diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt index 4ae6038fbb8..d0e413a66fd 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt @@ -123,8 +123,8 @@ public class FunctionReader(private val context: TranslationContext) { val moduleNameLiteral = context.program().getStringLiteral(moduleName) val moduleReference = context.namer().getModuleReference(moduleNameLiteral) - val replacements = hashMapOf(moduleRootVariable[moduleName] to moduleReference, - moduleKotlinVariable[moduleName] to Namer.KOTLIN_OBJECT_REF) + val replacements = hashMapOf(moduleRootVariable[moduleName]!! to moduleReference, + moduleKotlinVariable[moduleName]!! to Namer.KOTLIN_OBJECT_REF) replaceExternalNames(function, replacements) return function } diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeUnusedLocalFunctionDeclarations.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeUnusedLocalFunctionDeclarations.kt index 1fa6bf708b4..ffffb4618e8 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeUnusedLocalFunctionDeclarations.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeUnusedLocalFunctionDeclarations.kt @@ -51,7 +51,7 @@ private class UnusedInstanceCollector : JsVisitorWithContextImpl() { val name = x.getName()!! val statementContext = getLastStatementLevelContext() val currentStatement = statementContext.getCurrentNode() - tracker.addCandidateForRemoval(name, currentStatement) + tracker.addCandidateForRemoval(name, currentStatement!!) val references = collectReferencesInside(x) references.filterNotNull() @@ -60,8 +60,8 @@ private class UnusedInstanceCollector : JsVisitorWithContextImpl() { return false } - override fun visit(x: JsNameRef?, ctx: JsContext<*>?): Boolean { - val name = x?.getName() + override fun visit(x: JsNameRef, ctx: JsContext<*>): Boolean { + val name = x.getName() if (name != null) { tracker.markReachable(name) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt index decdb1a8980..7560e306f60 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt @@ -56,7 +56,7 @@ fun VariableAccessInfo.getAccessFunctionName(): String { val descriptor = variableDescriptor if (descriptor is PropertyDescriptor && descriptor.isExtension) { val propertyAccessorDescriptor = if (isGetAccess()) descriptor.getGetter() else descriptor.getSetter() - return context.getNameForDescriptor(propertyAccessorDescriptor).getIdent() + return context.getNameForDescriptor(propertyAccessorDescriptor!!).getIdent() } else { return Namer.getNameForAccessor(variableName.getIdent()!!, isGetAccess(), false) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt index 63efd4a7e9a..78fc93659fc 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt @@ -179,7 +179,7 @@ object InvokeIntrinsic : FunctionCallCase { } override fun FunctionCallInfo.dispatchReceiver(): JsExpression { - return JsInvocation(dispatchReceiver, argumentsInfo.translateArguments) + return JsInvocation(dispatchReceiver!!, argumentsInfo.translateArguments) } /** @@ -242,7 +242,7 @@ object DynamicInvokeAndBracketAccessCallCase : FunctionCallCase { val callType = resolvedCall.getCall().getCallType() return when (callType) { Call.CallType.INVOKE -> - JsInvocation(dispatchReceiver, arguments) + JsInvocation(dispatchReceiver!!, arguments) Call.CallType.ARRAY_GET_METHOD -> JsArrayAccess(dispatchReceiver, arguments[0]) Call.CallType.ARRAY_SET_METHOD -> diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt index 35932a4f309..dc22d6a8c7a 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt @@ -204,6 +204,7 @@ public class CallArgumentTranslator private constructor( val argumentExpression = valueArguments.get(0).getArgumentExpression() assert(argumentExpression != null) + argumentExpression!! val jsExpression = Translation.translateAsExpression(argumentExpression, context) result.add(jsExpression) @@ -250,6 +251,7 @@ public class CallArgumentTranslator private constructor( for (argument in arguments) { val argumentExpression = argument.getArgumentExpression() assert(argumentExpression != null) + argumentExpression!! val argContext = context.innerBlock() val argExpression = Translation.translateAsExpression(argumentExpression, argContext) list.add(argExpression) diff --git a/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt b/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt index 97070f63ebe..729fb91036f 100644 --- a/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt +++ b/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt @@ -111,7 +111,7 @@ class NoInternalVisibilityInStdLibTest { } After fun tearDown() { - Disposer.dispose(disposable) + Disposer.dispose(disposable!!) disposable = null } diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt index d0259e509f3..666b0c43e21 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt @@ -62,7 +62,7 @@ public abstract class AndroidResourceManager(val project: Project) { .map { psiManager.findFile(it) } .filterNotNull() .groupBy { it.getName().substringBeforeLast('.') } - .mapValues { it.getValue().sortBy { it.getParent().getName().length() } } + .mapValues { it.getValue().sortBy { it.getParent()!!.getName().length() } } } companion object { diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt index 88dc05ef219..139163e9770 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt @@ -193,7 +193,7 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) { for (res in resources) { if (resourceMap.contains(res.id)) { - val existing = resourceMap[res.id] + val existing = resourceMap[res.id]!! if (!res.sameClass(existing)) { resourcesToExclude.add(res.id) diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidXmlHandler.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidXmlHandler.kt index fce7c656a79..c057ff00f57 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidXmlHandler.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidXmlHandler.kt @@ -35,7 +35,7 @@ class AndroidXmlHandler(private val elementCallback: (String, String) -> Unit) : val attributesMap = attributes.toMap() val idAttribute = attributesMap[AndroidConst.ID_ATTRIBUTE_NO_NAMESPACE] val widgetType = attributesMap[AndroidConst.CLASS_ATTRIBUTE_NO_NAMESPACE] ?: localName - val name = idAttribute?.let { idToName(idAttribute) } + val name = idAttribute?.let { idToName(idAttribute!!) } if (name != null) elementCallback(name, widgetType) } diff --git a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt index a9ba2ba774b..59d1f21c1d6 100644 --- a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt +++ b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt @@ -64,7 +64,7 @@ public class AndroidPsiTreeChangePreprocessor : PsiTreeChangePreprocessor, Simpl val info = androidModuleInfo ?: return listOf() val fileManager = VirtualFileManager.getInstance() - return info.resDirectories.map { fileManager.findFileByUrl("file://" + it) } + return info.resDirectories.map { fileManager.findFileByUrl("file://" + it)!! } } private fun PsiFile.isLayoutXmlFile(): Boolean { diff --git a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt index a60c00b3b36..0df89ffb2bc 100644 --- a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt +++ b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt @@ -147,7 +147,7 @@ public class AndroidRenameProcessor : RenamePsiElementProcessor() { newName: String, allRenames: MutableMap ) { - val oldName = field.getName() + val oldName = field.getName()!! val processor = ServiceManager.getService(field.getProject(), javaClass()) renameSyntheticProperties(allRenames, newName, oldName, processor) }