Code cleanup: get rid of unnecessary !! / as, fake warning comments and issues

This commit is contained in:
Mikhail Glukhikh
2015-12-14 12:21:03 +03:00
parent 4ffd60cf52
commit 233e8e58e8
12 changed files with 14 additions and 7 deletions
@@ -103,6 +103,7 @@ public class WriteValueInstruction(
public val rValue: PseudoValue
) : AccessValueInstruction(assignment, lexicalScope, target, receiverValues) {
override val inputValues: List<PseudoValue>
// as is necessary: see KT-10384
get() = (receiverValues.keySet() as Collection<PseudoValue>) + rValue
override fun accept(visitor: InstructionVisitor) {
@@ -60,6 +60,8 @@ public class CallInstruction private constructor(
override val receiverValues: Map<PseudoValue, ReceiverValue>,
public val arguments: Map<PseudoValue, ValueParameterDescriptor>
) : OperationInstruction(element, lexicalScope, (receiverValues.keySet() as Collection<PseudoValue>) + arguments.keySet()), InstructionWithReceivers {
// as is necessary above: see KT-10384
public constructor (
element: KtElement,
lexicalScope: LexicalScope,
@@ -33,6 +33,7 @@ public fun PsiElement.getKotlinFqName(): FqName? {
return when (element) {
is PsiPackage -> FqName(element.getQualifiedName())
is PsiClass -> element.getQualifiedName()?.let { FqName(it) }
// as is necessary because of unresolved ambiguity: KT-3996
is PsiMember -> (element as PsiMember).getName()?.let { name ->
val prefix = element.getContainingClass()?.getQualifiedName()
FqName(if (prefix != null) "$prefix.$name" else name)
@@ -315,7 +315,7 @@ public object KotlinNameSuggester {
private fun MutableCollection<String>.addName(name: String?, validator: (String) -> Boolean) {
if (name == null) return
val correctedName = when {
isIdentifier(name) -> name!!
isIdentifier(name) -> name
name == "class" -> "clazz"
else -> return
}
@@ -57,6 +57,7 @@ public class KotlinElementDescriptionProvider : ElementDescriptionProvider {
if (targetElement !is PsiNamedElement || targetElement !is KtElement) return null
// as is necessary because of ambiguity: see KT-3996
val name = (targetElement as PsiNamedElement).getName()
return when(location) {
@@ -132,6 +132,7 @@ public class ConvertFunctionToPropertyIntention : SelfTargetingIntention<KtNamed
if (callable is PsiMethod) {
callable.getContainingClass()
?.findMethodsByName(getterName, true)
// as is necessary here: see KT-10386
?.firstOrNull { it.getParameterList().getParametersCount() == 0 && it.namedUnwrappedElement as PsiElement? !in callables }
?.let { reportDeclarationConflict(conflicts, it) { "$it already exists" } }
}
@@ -110,6 +110,7 @@ public class ConvertPropertyToFunctionIntention : SelfTargetingIntention<KtPrope
else if (callable is PsiMethod) {
callable.getContainingClass()
?.findMethodsByName(propertyName, true)
// as is necessary here: see KT-10386
?.firstOrNull { it.getParameterList().getParametersCount() == 0 && it.namedUnwrappedElement as PsiElement? !in callables }
?.let { reportDeclarationConflict(conflicts, it) { "$it already exists" } }
}
@@ -72,7 +72,7 @@ public object SuperClassNotInitialized : KotlinIntentionActionsFactory() {
val substitutedConstructors = constructors
.filter { it.getValueParameters().isNotEmpty() }
.map { it.substitute(substitutor) as ConstructorDescriptor }
.map { it.substitute(substitutor) }
if (substitutedConstructors.isNotEmpty()) {
val parameterTypes: List<List<KotlinType>> = substitutedConstructors.map {
@@ -149,7 +149,7 @@ public abstract class AbstractOverrideImplementTest : KotlinLightCodeInsightFixt
if (candidateToOverride == null) {
throw IllegalStateException("no chooserObjects to override with name $memberToOverride found")
}
candidateToOverride!!
candidateToOverride
}
performGenerateCommand(classOrObject, listOf(singleToOverride))
@@ -202,7 +202,7 @@ public object KotlinCompilerRunner {
K2JS_COMPILER -> CompileService.TargetPlatform.JS
else -> throw IllegalArgumentException("Unknown compiler type $compilerClassName")
}
val res = KotlinCompilerClient.incrementalCompile(connection.daemon!!, connection.sessionId, targetPlatform, argsArray, services, compilerOut, daemonOut)
val res = KotlinCompilerClient.incrementalCompile(connection.daemon, connection.sessionId, targetPlatform, argsArray, services, compilerOut, daemonOut)
processCompilerOutput(messageCollector, collector, compilerOut, res.toString())
BufferedReader(StringReader(daemonOut.toString())).forEachLine {
+2 -2
View File
@@ -7,7 +7,7 @@ import kotlin.dom.*
* Creates a new element which can be configured via a function
*/
fun Document.createElement(name: String, init: Element.() -> Unit): Element {
val elem = this.createElement(name)!!
val elem = this.createElement(name)
elem.init()
return elem
}
@@ -16,7 +16,7 @@ fun Document.createElement(name: String, init: Element.() -> Unit): Element {
* Creates a new element to an element which has an owner Document which can be configured via a function
*/
fun Element.createElement(name: String, doc: Document? = null, init: Element.() -> Unit): Element {
val elem = ownerDocument(doc).createElement(name)!!
val elem = ownerDocument(doc).createElement(name)
elem.init()
return elem
}
@@ -110,7 +110,7 @@ public operator fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get(key
*/
@Suppress("NOTHING_TO_INLINE")
@Deprecated("Map and key have incompatible types. Upcast key to Any? if you're sure.", ReplaceWith("get(key as Any?)"))
public inline fun <K, V> Map<K, V>.getRaw(key: Any?): V? = get(key as Any?)
public inline fun <K, V> Map<K, V>.getRaw(key: Any?): V? = get(key)
/**
* Returns `true` if the map contains the specified [key].