remove usages of static type assertions from the compiler

This commit is contained in:
Dmitry Jemerov
2015-10-08 12:49:17 +02:00
parent 1523d5bcbf
commit f5aaf65ca9
6 changed files with 18 additions and 16 deletions
@@ -16,17 +16,16 @@
package org.jetbrains.kotlin.cfg
import org.jetbrains.kotlin.psi.JetElement
import com.intellij.openapi.util.TextRange
import java.util.HashSet
import org.jetbrains.kotlin.psi.JetPsiUtil
import com.intellij.psi.PsiComment
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.PsiWhiteSpace
import java.util.ArrayList
import org.jetbrains.kotlin.lexer.JetTokens
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.PsiComment
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.JetElement
import org.jetbrains.kotlin.psi.JetPsiUtil
import java.util.*
interface UnreachableCode {
val elements: Set<JetElement>
@@ -99,7 +98,7 @@ class UnreachableCodeImpl(
private fun List<PsiElement>.mergeAdjacentTextRanges(): List<TextRange> {
val result = ArrayList<TextRange>()
val lastRange = fold(null: TextRange?) {
val lastRange = fold(null as TextRange?) {
currentTextRange, element ->
val elementRange = element.getTextRange()!!
@@ -17,16 +17,16 @@
package org.jetbrains.kotlin.psi
import com.intellij.lang.ASTNode
import org.jetbrains.kotlin.parsing.JetExpressionParsing
import com.intellij.psi.PsiElement
import com.intellij.psi.impl.source.tree.TreeElement
import org.jetbrains.kotlin.lexer.JetSingleValueToken
import org.jetbrains.kotlin.lexer.JetToken
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.parsing.JetExpressionParsing
import org.jetbrains.kotlin.types.expressions.OperatorConventions
public class JetOperationReferenceExpression(node: ASTNode) : JetSimpleNameExpressionImpl(node) {
override fun getReferencedNameElement() = (findChildByType(JetExpressionParsing.ALL_OPERATIONS): PsiElement?) ?: this
override fun getReferencedNameElement() = findChildByType<PsiElement?>(JetExpressionParsing.ALL_OPERATIONS) ?: this
fun getNameForConventionalOperation(unaryOperations: Boolean = true, binaryOperations: Boolean = true): Name? {
val operator = (firstChild as? TreeElement)?.elementType as? JetToken ?: return null
@@ -21,7 +21,9 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.KotlinLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.Call
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.doNotAnalyze
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isConventionCall
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isOrOverridesSynthesized
@@ -484,7 +486,7 @@ public class TaskPrioritizer(
private fun isSynthesized(candidate: ResolutionCandidate<D>): Boolean {
val descriptor = candidate.getDescriptor()
return descriptor is CallableMemberDescriptor && isOrOverridesSynthesized(descriptor : CallableMemberDescriptor)
return descriptor is CallableMemberDescriptor && isOrOverridesSynthesized(descriptor)
}
fun hasImplicitDynamicReceiver(candidate: ResolutionCandidate<D>): Boolean {
@@ -104,7 +104,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
dynamicType,
createTypeParameters(propertyDescriptor, call),
createDynamicDispatchReceiverParameter(propertyDescriptor),
null: JetType?
null as JetType?
)
val getter = DescriptorFactory.createDefaultGetter(propertyDescriptor, Annotations.EMPTY)
@@ -282,7 +282,8 @@ object DynamicOperatorCallCase : FunctionCallCase() {
}
is JetPostfixExpression -> {
// TODO drop hack with ":JsExpression" when KT-5569 will be fixed
JsPostfixOperation(OperatorTable.getUnaryOperator(operationToken), dispatchReceiver): JsExpression
@Suppress("USELESS_CAST")
(JsPostfixOperation(OperatorTable.getUnaryOperator(operationToken), dispatchReceiver) as JsExpression)
}
else -> unsupported("Unsupported callElement type: ${callElement.javaClass}, callElement: $callElement, callInfo: $this")
}
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.JetDelegationSpecifier
import org.jetbrains.kotlin.psi.JetDelegatorByExpressionSpecifier
import org.jetbrains.kotlin.resolve.DescriptorUtils
import java.util.HashMap
import java.util.*
public class DelegationTranslator(
private val classDeclaration: JetClassOrObject,
@@ -116,13 +116,13 @@ public class DelegationTranslator(
val delegateRefName = context().getScopeForDescriptor(getterDescriptor).declareName(delegateName)
val delegateRef = JsNameRef(delegateRefName, JsLiteral.THIS)
val returnExpression = if (DescriptorUtils.isExtension(descriptor)) {
val returnExpression: JsExpression = if (DescriptorUtils.isExtension(descriptor)) { // TODO remove explicit type specification after resolving KT-5569
val getterName = context().getNameForDescriptor(getterDescriptor)
val receiver = Namer.getReceiverParameterName()
JsInvocation(JsNameRef(getterName, delegateRef), JsNameRef(receiver))
}
else {
JsNameRef(propertyName, delegateRef): JsExpression // TODO remove explicit type specification after resolving KT-5569
JsNameRef(propertyName, delegateRef)
}
val jsFunction = simpleReturnFunction(context().getScopeForDescriptor(getterDescriptor.getContainingDeclaration()), returnExpression)