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