Cleanup: fix some compiler warnings (mostly deprecations, javaClass)

This commit is contained in:
Mikhail Glukhikh
2017-02-21 17:38:43 +03:00
parent d0cc1635db
commit b121bf8802
445 changed files with 773 additions and 949 deletions
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.kotlin.utils.singletonOrEmptyList
interface SpecificityComparisonCallbacks {
fun isNonSubtypeNotLessSpecific(specific: KotlinType, general: KotlinType): Boolean
@@ -62,7 +61,7 @@ class FlatSignature<out T> private constructor(
return FlatSignature(origin,
descriptor.typeParameters,
valueParameterTypes =
extensionReceiverType.singletonOrEmptyList() + parameterTypes,
listOfNotNull(extensionReceiverType) + parameterTypes,
hasExtensionReceiver = extensionReceiverType != null,
hasVarargs = descriptor.valueParameters.any { it.varargElementType != null },
numDefaults = numDefaults,
@@ -24,14 +24,13 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
import org.jetbrains.kotlin.resolve.scopes.receivers.DetailedReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
import org.jetbrains.kotlin.utils.addToStdlib.check
class KnownResultProcessor<out C>(
val result: Collection<C>
): ScopeTowerProcessor<C> {
override fun process(data: TowerData)
= if (data == TowerData.Empty) listOfNotNull(result.check { it.isNotEmpty() }) else emptyList()
= if (data == TowerData.Empty) listOfNotNull(result.takeIf { it.isNotEmpty() }) else emptyList()
}
class CompositeScopeTowerProcessor<out C>(
@@ -46,7 +45,7 @@ internal abstract class AbstractSimpleScopeTowerProcessor<D : CallableDescriptor
protected abstract fun simpleProcess(data: TowerData): Collection<C>
override fun process(data: TowerData): List<Collection<C>> = listOfNotNull(simpleProcess(data).check { it.isNotEmpty() })
override fun process(data: TowerData): List<Collection<C>> = listOfNotNull(simpleProcess(data).takeIf { it.isNotEmpty() })
}
private typealias CandidatesCollector<D> =
@@ -173,7 +172,7 @@ private fun <D : CallableDescriptor, C: Candidate<D>> createSimpleProcessor(
}
else {
assert(explicitReceiver == null) {
"Illegal explicit receiver: $explicitReceiver(${explicitReceiver!!.javaClass.simpleName})"
"Illegal explicit receiver: $explicitReceiver(${explicitReceiver!!::class.java.simpleName})"
}
return NoExplicitReceiverScopeTowerProcessor(context, collectCandidates)
}
@@ -42,8 +42,6 @@ import org.jetbrains.kotlin.types.isDynamic
import org.jetbrains.kotlin.types.typeUtil.getImmediateSuperclassNotAny
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.addIfNotNull
import org.jetbrains.kotlin.utils.singletonOrEmptyList
import org.jetbrains.kotlin.utils.toReadOnlyList
import java.util.*
internal abstract class AbstractScopeTowerLevel(
@@ -148,7 +146,7 @@ internal class MemberScopeTowerLevel(
override fun getFunctions(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?): Collection<CandidateWithBoundDispatchReceiver<FunctionDescriptor>> {
return collectMembers {
getContributedFunctions(name, location) + it.getInnerConstructors(name, location) +
syntheticScopes.collectSyntheticMemberFunctions(it.singletonOrEmptyList(), name, location)
syntheticScopes.collectSyntheticMemberFunctions(listOfNotNull(it), name, location)
}
}
}
@@ -278,7 +276,7 @@ private fun ResolutionScope.getContributedFunctionsAndConstructors(
syntheticConstructorsProvider.getSyntheticConstructors(classifier, location).filterTo(result) { it.dispatchReceiverParameter == null }
}
return result.toReadOnlyList()
return result.toList()
}
private fun ClassifierDescriptor.getCallableConstructors(): Collection<FunctionDescriptor> =
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.resolve.scopes.ImportingScope
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
import org.jetbrains.kotlin.resolve.scopes.utils.parentsWithSelf
import org.jetbrains.kotlin.utils.addToStdlib.check
import java.util.*
interface Candidate<out D : CallableDescriptor> {
@@ -235,11 +234,11 @@ class TowerResolver {
override fun getSuccessfulCandidates(): Collection<C>? = getResolved()
fun getResolved() = currentCandidates.check { currentLevel == ResolutionCandidateApplicability.RESOLVED }
fun getResolved() = currentCandidates.takeIf { currentLevel == ResolutionCandidateApplicability.RESOLVED }
fun getResolvedLowPriority() = currentCandidates.check { currentLevel == ResolutionCandidateApplicability.RESOLVED_LOW_PRIORITY }
fun getResolvedLowPriority() = currentCandidates.takeIf { currentLevel == ResolutionCandidateApplicability.RESOLVED_LOW_PRIORITY }
fun getErrors() = currentCandidates.check {
fun getErrors() = currentCandidates.takeIf {
currentLevel == null || currentLevel!! > ResolutionCandidateApplicability.RESOLVED_LOW_PRIORITY
}
@@ -49,7 +49,7 @@ class LexicalChainedScope @JvmOverloads constructor(
override fun toString(): String = kind.toString()
override fun printStructure(p: Printer) {
p.println(javaClass.simpleName, ": ", kind, "; for descriptor: ", ownerDescriptor.name,
p.println(this::class.java.simpleName, ": ", kind, "; for descriptor: ", ownerDescriptor.name,
" with implicitReceiver: ", implicitReceiver?.value ?: "NONE", " {")
p.pushIndent()
@@ -36,7 +36,7 @@ class LexicalScopeImpl @JvmOverloads constructor(
override fun toString(): String = kind.toString()
override fun printStructure(p: Printer) {
p.println(javaClass.simpleName, ": ", kind, "; for descriptor: ", ownerDescriptor.name,
p.println(this::class.java.simpleName, ": ", kind, "; for descriptor: ", ownerDescriptor.name,
" with implicitReceiver: ", implicitReceiver?.value ?: "NONE", " {")
p.pushIndent()
@@ -88,7 +88,7 @@ class LexicalWritableScope(
override fun toString(): String = kind.toString()
override fun printStructure(p: Printer) {
p.println(javaClass.simpleName, ": ", kind, "; for descriptor: ", ownerDescriptor.name,
p.println(this::class.java.simpleName, ": ", kind, "; for descriptor: ", ownerDescriptor.name,
" with implicitReceiver: ", implicitReceiver?.value ?: "NONE", " {")
p.pushIndent()
@@ -116,10 +116,10 @@ private class MemberScopeToImportingScopeAdapter(override val parent: ImportingS
override fun hashCode() = memberScope.hashCode()
override fun toString() = "${javaClass.simpleName} for $memberScope"
override fun toString() = "${this::class.java.simpleName} for $memberScope"
override fun printStructure(p: Printer) {
p.println(javaClass.simpleName)
p.println(this::class.java.simpleName)
p.pushIndent()
memberScope.printScopeStructure(p.withholdIndentOnce())