Cleanup: fix some compiler warnings (mostly deprecations, javaClass)
This commit is contained in:
@@ -25,10 +25,9 @@ import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
|
||||
val KotlinType.nameIfStandardType: Name?
|
||||
get() = constructor.declarationDescriptor?.check(KotlinBuiltIns::isBuiltIn)?.name
|
||||
get() = constructor.declarationDescriptor?.takeIf(KotlinBuiltIns::isBuiltIn)?.name
|
||||
|
||||
fun KotlinType.getJetTypeFqName(printTypeArguments: Boolean): String {
|
||||
val declaration = requireNotNull(constructor.declarationDescriptor)
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.resolve.checkers.SimpleDeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.*
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
||||
|
||||
object JsExternalChecker : SimpleDeclarationChecker {
|
||||
val DEFINED_EXTERNALLY_PROPERTY_NAMES = setOf(FqNameUnsafe("kotlin.js.noImpl"), FqNameUnsafe("kotlin.js.definedExternally"))
|
||||
@@ -79,7 +78,7 @@ object JsExternalChecker : SimpleDeclarationChecker {
|
||||
}
|
||||
|
||||
if (descriptor is ClassDescriptor && descriptor.kind != ClassKind.ANNOTATION_CLASS) {
|
||||
val superClasses = (descriptor.getSuperClassNotAny().singletonOrEmptyList() + descriptor.getSuperInterfaces()).toMutableSet()
|
||||
val superClasses = (listOfNotNull(descriptor.getSuperClassNotAny()) + descriptor.getSuperInterfaces()).toMutableSet()
|
||||
if (descriptor.kind == ClassKind.ENUM_CLASS || descriptor.kind == ClassKind.ENUM_ENTRY) {
|
||||
superClasses.removeAll { it.fqNameUnsafe == KotlinBuiltIns.FQ_NAMES._enum }
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ class WhileConditionFolding(val body: JsBlock) {
|
||||
// applying this rule repeatedly we get while (A && (B || C)), which is correct
|
||||
|
||||
is JsIf -> {
|
||||
val then = statement.thenStatement!!
|
||||
val then = statement.thenStatement
|
||||
if (statement.elseStatement == null) {
|
||||
val nextCondition = extractCondition(then, label)
|
||||
val result: JsExpression? = when (nextCondition) {
|
||||
|
||||
@@ -46,7 +46,7 @@ fun removeDefaultInitializers(arguments: List<JsExpression>, parameters: List<Js
|
||||
name != null && name in toRemove ->
|
||||
listOf<JsStatement>()
|
||||
name != null && name in toExpand ->
|
||||
flattenStatement((it as JsIf).thenStatement!!)
|
||||
flattenStatement((it as JsIf).thenStatement)
|
||||
else ->
|
||||
listOf(it)
|
||||
}
|
||||
@@ -91,7 +91,7 @@ private fun isNameInitialized(
|
||||
name: JsName,
|
||||
initializer: JsStatement
|
||||
): Boolean {
|
||||
val thenStmt = (initializer as JsIf).thenStatement!!
|
||||
val thenStmt = (initializer as JsIf).thenStatement
|
||||
val lastThenStmt = flattenStatement(thenStmt).last()
|
||||
|
||||
val expr = (lastThenStmt as? JsExpressionStatement)?.expression
|
||||
|
||||
@@ -42,7 +42,7 @@ class MultiModuleOrderTest : BasicBoxTest("$TEST_DATA_DIR_PATH/multiModuleOrder/
|
||||
val mainJsFile = File(parentDir, "$name-main_v5.js").path
|
||||
val libJsFile = File(parentDir, "$name-lib_v5.js").path
|
||||
try {
|
||||
RhinoUtils.runRhinoTest(listOf(mainJsFile, libJsFile), RhinoResultChecker { context, scope ->
|
||||
RhinoUtils.runRhinoTest(listOf(mainJsFile, libJsFile), RhinoResultChecker { _, _ ->
|
||||
// don't check anything, expect exception from function
|
||||
})
|
||||
}
|
||||
|
||||
+1
-1
@@ -310,7 +310,7 @@ object DynamicOperatorCallCase : FunctionCallCase() {
|
||||
@Suppress("USELESS_CAST")
|
||||
(JsPostfixOperation(OperatorTable.getUnaryOperator(operationToken), dispatchReceiver) as JsExpression)
|
||||
}
|
||||
else -> unsupported("Unsupported callElement type: ${callElement.javaClass}, callElement: $callElement, callInfo: $this")
|
||||
else -> unsupported("Unsupported callElement type: ${callElement::class.java}, callElement: $callElement, callInfo: $this")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,8 +201,8 @@ private fun ReceiverParameterDescriptor.getNameForCapturedReceiver(): String {
|
||||
val containingDeclaration = this.containingDeclaration
|
||||
|
||||
assert(containingDeclaration is MemberDescriptor) {
|
||||
"Unsupported descriptor type: ${containingDeclaration.javaClass}, " +
|
||||
"receiverDescriptor = $this, " +"containingDeclaration = $containingDeclaration"
|
||||
"Unsupported descriptor type: ${containingDeclaration::class.java}, " +
|
||||
"receiverDescriptor = $this, " + "containingDeclaration = $containingDeclaration"
|
||||
}
|
||||
|
||||
if (DescriptorUtils.isCompanionObject(containingDeclaration)) {
|
||||
|
||||
+1
-1
@@ -255,7 +255,7 @@ private class PropertyTranslator(
|
||||
is PropertySetterDescriptor, is LocalVariableAccessorDescriptor.Setter ->
|
||||
"setter"
|
||||
else ->
|
||||
throw IllegalArgumentException("Unknown accessor type ${accessorDescriptor.javaClass}")
|
||||
throw IllegalArgumentException("Unknown accessor type ${accessorDescriptor::class.java}")
|
||||
}
|
||||
|
||||
val name = accessorDescriptor.name.asString()
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.jetbrains.kotlin.psi.KtForExpression
|
||||
import org.jetbrains.kotlin.psi.KtWhileExpressionBase
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
||||
|
||||
fun createWhile(doWhile: Boolean, expression: KtWhileExpressionBase, context: TranslationContext): JsNode {
|
||||
val conditionExpression = expression.condition ?:
|
||||
@@ -121,7 +120,7 @@ fun translateForExpression(expression: KtForExpression, context: TranslationCont
|
||||
destructuringParameter, parameterName, itemValue, context.innerBlock(block))
|
||||
}
|
||||
block.statements += currentVarInit
|
||||
block.statements += if (realBody is JsBlock) realBody.statements else realBody.singletonOrEmptyList()
|
||||
block.statements += if (realBody is JsBlock) realBody.statements else listOfNotNull(realBody)
|
||||
|
||||
return block
|
||||
}
|
||||
|
||||
+1
-2
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.js.translate.context.TranslationContext
|
||||
import org.jetbrains.kotlin.js.translate.reference.ReferenceTranslator
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
||||
|
||||
class RangeToIntrinsic(function: FunctionDescriptor) : FunctionIntrinsicWithReceiverComputed() {
|
||||
val rangeTypeDescriptor = function.returnType!!.constructor.declarationDescriptor as ClassDescriptor
|
||||
@@ -37,6 +36,6 @@ class RangeToIntrinsic(function: FunctionDescriptor) : FunctionIntrinsicWithRece
|
||||
}
|
||||
val finalClass = (existingClasses.firstOrNull() as? ClassDescriptor) ?: rangeTypeDescriptor
|
||||
val constructor = ReferenceTranslator.translateAsTypeReference(finalClass, context)
|
||||
return JsNew(constructor, receiver.singletonOrEmptyList() + arguments)
|
||||
return JsNew(constructor, listOfNotNull(receiver) + arguments)
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ fun JsExpression.toInvocationWith(
|
||||
// `A(a, b, c)` -> `A(a, b, c, $this)`
|
||||
return JsInvocation(qualifier, leadingExtraArgs + padArguments(arguments) + thisExpr)
|
||||
}
|
||||
else -> throw IllegalStateException("Unexpected node type: " + javaClass)
|
||||
else -> throw IllegalStateException("Unexpected node type: " + this::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user