Stop using deprecated APIs

This commit is contained in:
Ilya Ryzhenkov
2014-12-02 15:41:22 +03:00
parent 2b8ffeda28
commit be717f48f8
45 changed files with 111 additions and 112 deletions
@@ -109,7 +109,7 @@ private fun <Function : FunctionHandle> findConcreteSuperDeclaration(function: F
result.removeAll(toRemove) result.removeAll(toRemove)
val concreteRelevantDeclarations = result.filter { !it.isAbstract } val concreteRelevantDeclarations = result.filter { !it.isAbstract }
if (concreteRelevantDeclarations.size != 1) { if (concreteRelevantDeclarations.size() != 1) {
error("Concrete fake override $function should have exactly one concrete super-declaration: $concreteRelevantDeclarations") error("Concrete fake override $function should have exactly one concrete super-declaration: $concreteRelevantDeclarations")
} }
@@ -62,7 +62,7 @@ public object CodegenUtilKt {
(listOf(it) + DescriptorUtils.getAllOverriddenDescriptors(it)).map { it.getOriginal() }.contains(overriddenDescriptor.getOriginal()) (listOf(it) + DescriptorUtils.getAllOverriddenDescriptors(it)).map { it.getOriginal() }.contains(overriddenDescriptor.getOriginal())
} }
} }
assert(actualDelegates.size <= 1) { "Meny delegates found for $delegatingMember: $actualDelegates" } assert(actualDelegates.size() <= 1) { "Meny delegates found for $delegatingMember: $actualDelegates" }
actualDelegates.firstOrNull() actualDelegates.firstOrNull()
} }
+1 -1
View File
@@ -24,7 +24,7 @@ public trait OutputFileCollection {
} }
public class SimpleOutputFileCollection(private val outputFiles: List<OutputFile>) : OutputFileCollection { public class SimpleOutputFileCollection(private val outputFiles: List<OutputFile>) : OutputFileCollection {
override fun get(relativePath: String): OutputFile? = outputFiles.find { it.relativePath == relativePath } override fun get(relativePath: String): OutputFile? = outputFiles.firstOrNull { it.relativePath == relativePath }
override fun asList(): List<OutputFile> = outputFiles override fun asList(): List<OutputFile> = outputFiles
} }
@@ -183,7 +183,7 @@ class CollectionStubMethodGenerator(
private fun Collection<JetType>.findMostSpecificTypeForClass(klass: ClassDescriptor): JetType { private fun Collection<JetType>.findMostSpecificTypeForClass(klass: ClassDescriptor): JetType {
val types = this.filter { it.getConstructor().getDeclarationDescriptor() == klass } val types = this.filter { it.getConstructor().getDeclarationDescriptor() == klass }
if (types.isEmpty()) error("No supertype of $klass in $this") if (types.isEmpty()) error("No supertype of $klass in $this")
if (types.size == 1) return types.first() if (types.size() == 1) return types.first()
// Find the first type in the list such that it's a subtype of every other type in that list // Find the first type in the list such that it's a subtype of every other type in that list
return types.first { type -> return types.first { type ->
types.all { other -> JetTypeChecker.DEFAULT.isSubtypeOf(type, other) } types.all { other -> JetTypeChecker.DEFAULT.isSubtypeOf(type, other) }
@@ -76,7 +76,7 @@ public abstract class SignatureCollectingClassBuilderFactory(
override fun done() { override fun done() {
var hasDuplicateSignatures = false var hasDuplicateSignatures = false
for ((signature, elementsAndDescriptors) in signatures.entrySet()!!) { for ((signature, elementsAndDescriptors) in signatures.entrySet()!!) {
if (elementsAndDescriptors.size == 1) continue // no clash if (elementsAndDescriptors.size() == 1) continue // no clash
handleClashingSignatures(ConflictingJvmDeclarationsData( handleClashingSignatures(ConflictingJvmDeclarationsData(
classInternalName, classInternalName,
classCreatedFor, classCreatedFor,
@@ -120,7 +120,7 @@ private class StoredStackValuesDescriptor(
alreadyStoredValuesCount: Int alreadyStoredValuesCount: Int
) { ) {
val nextFreeVarIndex : Int get() = firstVariableIndex + storedStackSize val nextFreeVarIndex : Int get() = firstVariableIndex + storedStackSize
val storedValuesCount: Int get() = values.size val storedValuesCount: Int get() = values.size()
val isStored: Boolean get() = storedValuesCount > 0 val isStored: Boolean get() = storedValuesCount > 0
val totalValuesCountOnStackBeforeInline = alreadyStoredValuesCount + storedValuesCount val totalValuesCountOnStackBeforeInline = alreadyStoredValuesCount + storedValuesCount
} }
@@ -59,7 +59,7 @@ class UnreachableCodeImpl(
acceptChildren(object : PsiElementVisitor() { acceptChildren(object : PsiElementVisitor() {
override fun visitElement(element: PsiElement) { override fun visitElement(element: PsiElement) {
val isReachable = element is JetElement && reachableElements.contains(element) && !element.hasChildrenInSet(unreachableElements) val isReachable = element is JetElement && reachableElements.contains(element) && !element.hasChildrenInSet(unreachableElements)
if (isReachable || element.getChildren().size == 0) { if (isReachable || element.getChildren().size() == 0) {
children.add(element) children.add(element)
} }
else { else {
@@ -59,14 +59,14 @@ public object AllTypes : TypePredicate {
// todo: simplify computed type predicate when possible // todo: simplify computed type predicate when possible
public fun and(predicates: Collection<TypePredicate>): TypePredicate = public fun and(predicates: Collection<TypePredicate>): TypePredicate =
when (predicates.size) { when (predicates.size()) {
0 -> AllTypes 0 -> AllTypes
1 -> predicates.first() 1 -> predicates.first()
else -> ForAllTypes(predicates.toList()) else -> ForAllTypes(predicates.toList())
} }
public fun or(predicates: Collection<TypePredicate>): TypePredicate? = public fun or(predicates: Collection<TypePredicate>): TypePredicate? =
when (predicates.size) { when (predicates.size()) {
0 -> null 0 -> null
1 -> predicates.first() 1 -> predicates.first()
else -> ForSomeType(predicates.toList()) else -> ForSomeType(predicates.toList())
@@ -68,7 +68,7 @@ public class ReadValueInstruction private (
} }
override fun toString(): String { override fun toString(): String {
val inVal = if (receiverValues.empty) "" else "|${receiverValues.keySet().joinToString()}" val inVal = if (receiverValues.isEmpty()) "" else "|${receiverValues.keySet().joinToString()}"
return "r(${render(element)}$inVal) -> $outputValue" return "r(${render(element)}$inVal) -> $outputValue"
} }
@@ -41,7 +41,7 @@ public abstract class OperationInstruction protected(
protected fun renderInstruction(name: String, desc: String): String = protected fun renderInstruction(name: String, desc: String): String =
"$name($desc" + "$name($desc" +
(if (inputValues.notEmpty) "|${inputValues.joinToString(", ")})" else ")") + (if (inputValues.isNotEmpty()) "|${inputValues.joinToString(", ")})" else ")") +
(if (resultValue != null) " -> $resultValue" else "") (if (resultValue != null) " -> $resultValue" else "")
protected fun setResult(value: PseudoValue?): OperationInstruction { protected fun setResult(value: PseudoValue?): OperationInstruction {
@@ -366,7 +366,7 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
// array() // array()
if (CompileTimeConstantUtils.isArrayMethodCall(call)) { if (CompileTimeConstantUtils.isArrayMethodCall(call)) {
val varargType = resultingDescriptor.getValueParameters().first?.getVarargElementType()!! val varargType = resultingDescriptor.getValueParameters().first().getVarargElementType()!!
val arguments = call.getValueArguments().values().flatMap { resolveArguments(it.getArguments(), varargType) } val arguments = call.getValueArguments().values().flatMap { resolveArguments(it.getArguments(), varargType) }
return ArrayValue(arguments, resultingDescriptor.getReturnType()!!, true, arguments.any() { it.usesVariableAsConstant() }) return ArrayValue(arguments, resultingDescriptor.getReturnType()!!, true, arguments.any() { it.usesVariableAsConstant() })
@@ -427,7 +427,7 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
if (argumentCompileTimeType == null) return null if (argumentCompileTimeType == null) return null
val arguments = argument.getArguments() val arguments = argument.getArguments()
if (arguments.size != 1) return null if (arguments.size() != 1) return null
val argumentExpression = arguments.first().getArgumentExpression() val argumentExpression = arguments.first().getArgumentExpression()
if (argumentExpression == null) return null if (argumentExpression == null) return null
@@ -61,7 +61,7 @@ object PrecedingDocCommentsBinder : WhitespacesAndCommentsBinder {
if (tokens[idx] == JetTokens.DOC_COMMENT) return idx if (tokens[idx] == JetTokens.DOC_COMMENT) return idx
} }
return tokens.size return tokens.size()
} }
} }
@@ -61,7 +61,7 @@ import org.jetbrains.jet.lang.psi.JetDynamicType
// invoke this instead of getText() when you need debug text to identify some place in PSI without storing the element itself // invoke this instead of getText() when you need debug text to identify some place in PSI without storing the element itself
// this is need to avoid unnecessary file parses // this is need to avoid unnecessary file parses
// this defaults to get text if the element is not stubbed // this defaults to get text if the element is not stubbed
public fun JetElement.getDebugText(): String? { public fun JetElement.getDebugText(): String {
if (this !is JetElementImplStub<*> || this.getStub() == null) { if (this !is JetElementImplStub<*> || this.getStub() == null) {
return getText() return getText()
} }
@@ -329,12 +329,12 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
fun renderChildren(element: JetElementImplStub<*>, separator: String, prefix: String = "", postfix: String = ""): String? { fun renderChildren(element: JetElementImplStub<*>, separator: String, prefix: String = "", postfix: String = ""): String? {
val childrenTexts = element.getStub()?.getChildrenStubs()?.map { (it?.getPsi() as? JetElement)?.getDebugText() } val childrenTexts = element.getStub()?.getChildrenStubs()?.map { (it?.getPsi() as? JetElement)?.getDebugText() }
return childrenTexts?.filterNotNull()?.makeString(separator, prefix, postfix) ?: element.getText() return childrenTexts?.filterNotNull()?.join(separator, prefix, postfix) ?: element.getText()
} }
fun render(element: JetElementImplStub<*>, vararg relevantChildren: JetElement?): String? { fun render(element: JetElementImplStub<*>, vararg relevantChildren: JetElement?): String? {
if (element.getStub() == null) return element.getText() if (element.getStub() == null) return element.getText()
return relevantChildren.filterNotNull().map { it.getDebugText() }.makeString("", "", "") return relevantChildren.filterNotNull().map { it.getDebugText() }.join("", "", "")
} }
} }
@@ -92,7 +92,7 @@ public abstract class JetCodeFragment(
} }
override fun importsToString(): String { override fun importsToString(): String {
return myImports.joinToString(IMPORT_SEPARATOR) return myImports.join(IMPORT_SEPARATOR)
} }
override fun addImportsFromString(imports: String?) { override fun addImportsFromString(imports: String?) {
@@ -102,7 +102,7 @@ public abstract class JetCodeFragment(
} }
public fun importsAsImportList(): JetImportList? { public fun importsAsImportList(): JetImportList? {
return JetPsiFactory(this).createFile(myImports.joinToString("\n")).getImportList() return JetPsiFactory(this).createFile(myImports.join("\n")).getImportList()
} }
override fun setVisibilityChecker(checker: JavaCodeFragment.VisibilityChecker?) { } override fun setVisibilityChecker(checker: JavaCodeFragment.VisibilityChecker?) { }
@@ -129,7 +129,7 @@ public abstract class JetCodeFragment(
return containingFile.getImportList()?.getImports() return containingFile.getImportList()?.getImports()
?.map { it.getText() } ?.map { it.getText() }
?.joinToString(JetCodeFragment.IMPORT_SEPARATOR) ?: "" ?.join(JetCodeFragment.IMPORT_SEPARATOR) ?: ""
} }
} }
} }
@@ -219,7 +219,7 @@ public class JetPsiFactory(private val project: Project) {
} }
public fun createAnonymousInitializer(): JetClassInitializer { public fun createAnonymousInitializer(): JetClassInitializer {
return createClass("class A { {} }").getAnonymousInitializers().first!! return createClass("class A { {} }").getAnonymousInitializers().first()
} }
public fun createEmptyClassBody(): JetClassBody { public fun createEmptyClassBody(): JetClassBody {
@@ -35,7 +35,7 @@ public open class KotlinStubBaseImpl<T : JetElementImplStub<*>>(parent: StubElem
if (propertiesValues.isEmpty()) { if (propertiesValues.isEmpty()) {
return "" return ""
} }
return propertiesValues.makeString(separator = ", ", prefix = "[", postfix = "]") return propertiesValues.join(separator = ", ", prefix = "[", postfix = "]")
} }
private fun renderPropertyValues(stubInterface: Class<out Any?>): List<String> { private fun renderPropertyValues(stubInterface: Class<out Any?>): List<String> {
@@ -30,7 +30,7 @@ public class CompositeBindingContext private (
class object { class object {
public fun create(delegates: List<BindingContext>): BindingContext { public fun create(delegates: List<BindingContext>): BindingContext {
if (delegates.isEmpty()) return BindingContext.EMPTY if (delegates.isEmpty()) return BindingContext.EMPTY
if (delegates.size == 1) return delegates.first() if (delegates.size() == 1) return delegates.first()
return CompositeBindingContext(delegates) return CompositeBindingContext(delegates)
} }
} }
@@ -52,7 +52,7 @@ public class ResolutionTaskHolder<D : CallableDescriptor, F : D>(
if (internalTasks == null) { if (internalTasks == null) {
val tasks = ArrayList<ResolutionTask<D, F>>() val tasks = ArrayList<ResolutionTask<D, F>>()
for (priority in (0..priorityProvider.getMaxPriority()).reversed()) { for (priority in (0..priorityProvider.getMaxPriority()).reversed()) {
for (candidateIndex in 0..candidatesList.size - 1) { for (candidateIndex in candidatesList.indices) {
val lazyCandidates = { val lazyCandidates = {
candidatesList[candidateIndex]().filter { priorityProvider.getPriority(it) == priority }.toReadOnlyList() candidatesList[candidateIndex]().filter { priorityProvider.getPriority(it) == priority }.toReadOnlyList()
} }
@@ -211,7 +211,7 @@ public open class LazyClassMemberScope(resolveSession: ResolveSession,
val valueParameterDescriptors = primaryConstructor.getValueParameters() val valueParameterDescriptors = primaryConstructor.getValueParameters()
val primaryConstructorParameters = classInfo.getPrimaryConstructorParameters() val primaryConstructorParameters = classInfo.getPrimaryConstructorParameters()
assert(valueParameterDescriptors.size() == primaryConstructorParameters.size()) { assert(valueParameterDescriptors.size() == primaryConstructorParameters.size()) {
"From descriptor: ${valueParameterDescriptors.size} but from PSI: ${primaryConstructorParameters.size}" "From descriptor: ${valueParameterDescriptors.size()} but from PSI: ${primaryConstructorParameters.size()}"
} }
for (valueParameterDescriptor in valueParameterDescriptors) { for (valueParameterDescriptor in valueParameterDescriptors) {
@@ -104,7 +104,7 @@ class FilteredJvmDiagnostics(val jvmDiagnostics: Diagnostics, val otherDiagnosti
it.data().signature.name it.data().signature.name
}.forEach { }.forEach {
val diagnostics = it.getValue() val diagnostics = it.getValue()
if (diagnostics.size <= 1) { if (diagnostics.size() <= 1) {
filtered.addAll(diagnostics) filtered.addAll(diagnostics)
} }
else { else {
@@ -53,7 +53,7 @@ public class LazyJavaClassMemberScope(
internal val constructors = c.storageManager.createLazyValue { internal val constructors = c.storageManager.createLazyValue {
val constructors = jClass.getConstructors() val constructors = jClass.getConstructors()
val result = ArrayList<JavaConstructorDescriptor>(constructors.size) val result = ArrayList<JavaConstructorDescriptor>(constructors.size())
for (constructor in constructors) { for (constructor in constructors) {
val descriptor = resolveConstructor(constructor) val descriptor = resolveConstructor(constructor)
result.add(descriptor) result.add(descriptor)
@@ -207,7 +207,7 @@ class LazyJavaTypeResolver(
return javaType.getTypeArguments().withIndices().map { return javaType.getTypeArguments().withIndices().map {
javaTypeParameter -> javaTypeParameter ->
val (i, t) = javaTypeParameter val (i, t) = javaTypeParameter
val parameter = if (i >= typeParameters.size) val parameter = if (i >= typeParameters.size())
ErrorUtils.createErrorTypeParameter(i, "#$i for ${typeConstructor}") ErrorUtils.createErrorTypeParameter(i, "#$i for ${typeConstructor}")
else typeParameters[i] else typeParameters[i]
transformToTypeProjection(t, howTheProjectionIsUsed.toAttributes(), parameter) transformToTypeProjection(t, howTheProjectionIsUsed.toAttributes(), parameter)
@@ -34,7 +34,7 @@ private fun findInnerClass(classDescriptor: ClassDescriptor, name: Name): ClassD
public fun ModuleDescriptor.findClassAcrossModuleDependencies(classId: ClassId): ClassDescriptor? { public fun ModuleDescriptor.findClassAcrossModuleDependencies(classId: ClassId): ClassDescriptor? {
val packageViewDescriptor = getPackage(classId.getPackageFqName()) ?: return null val packageViewDescriptor = getPackage(classId.getPackageFqName()) ?: return null
val segments = classId.getRelativeClassName().pathSegments() val segments = classId.getRelativeClassName().pathSegments()
val topLevelClass = packageViewDescriptor.getMemberScope().getClassifier(segments.first!!) as? ClassDescriptor ?: return null val topLevelClass = packageViewDescriptor.getMemberScope().getClassifier(segments.first()) as? ClassDescriptor ?: return null
var result = topLevelClass var result = topLevelClass
for (name in segments.subList(1, segments.size())) { for (name in segments.subList(1, segments.size())) {
result = findInnerClass(result, name) ?: return null result = findInnerClass(result, name) ?: return null
@@ -156,7 +156,7 @@ class PartialBodyResolveFilter(
fun addPlaces(name: SmartCastName, places: Collection<JetExpression>) { fun addPlaces(name: SmartCastName, places: Collection<JetExpression>) {
assert(!places.isEmpty()) assert(!places.isEmpty())
map.getOrPut(name, { ArrayList(places.size) }).addAll(places) map.getOrPut(name, { ArrayList(places.size()) }).addAll(places)
} }
fun addIfCanBeSmartCast(expression: JetExpression) { fun addIfCanBeSmartCast(expression: JetExpression) {
@@ -217,7 +217,7 @@ public class KotlinCacheService(val project: Project) {
} }
private fun assertAreInSameModule(elements: Collection<JetElement>) { private fun assertAreInSameModule(elements: Collection<JetElement>) {
if (elements.size <= 1) { if (elements.size() <= 1) {
return return
} }
val thisInfo = elements.first().getModuleInfo() val thisInfo = elements.first().getModuleInfo()
@@ -259,7 +259,7 @@ public object ShortenReferences {
val newContext = selectorCopy.analyzeInContext(scope) val newContext = selectorCopy.analyzeInContext(scope)
val targetsAfter = (selectorCopy.getCalleeExpressionIfAny() as JetReferenceExpression).getTargets(newContext) val targetsAfter = (selectorCopy.getCalleeExpressionIfAny() as JetReferenceExpression).getTargets(newContext)
when (targetsAfter.size) { when (targetsAfter.size()) {
0 -> return importInserter.addImport(targetBefore) 0 -> return importInserter.addImport(targetBefore)
1 -> if (targetBefore == targetsAfter.first()) return true 1 -> if (targetBefore == targetsAfter.first()) return true
@@ -93,7 +93,7 @@ private object DeclarationKindDetector : JetVisitor<AnnotationHostKind?, Unit?>(
override fun visitProperty(d: JetProperty, _: Unit?) = detect(d, d.getValOrVarNode().getText()!!) override fun visitProperty(d: JetProperty, _: Unit?) = detect(d, d.getValOrVarNode().getText()!!)
override fun visitMultiDeclaration(d: JetMultiDeclaration, _: Unit?) = detect(d, d.getValOrVarNode()?.getText() ?: "val", override fun visitMultiDeclaration(d: JetMultiDeclaration, _: Unit?) = detect(d, d.getValOrVarNode()?.getText() ?: "val",
name = d.getEntries().map { it.getName() }.makeString(", ", "(", ")")) name = d.getEntries().map { it.getName() }.join(", ", "(", ")"))
override fun visitTypeParameter(d: JetTypeParameter, _: Unit?) = detect(d, "type parameter", newLineNeeded = false) override fun visitTypeParameter(d: JetTypeParameter, _: Unit?) = detect(d, "type parameter", newLineNeeded = false)
@@ -60,7 +60,7 @@ fun <D : CallableDescriptor> renderResolvedCall(resolvedCall: ResolvedCall<D>):
append("<br/>$indent<i>where</i> ") append("<br/>$indent<i>where</i> ")
if (!notInferredTypeParameters.isEmpty()) { if (!notInferredTypeParameters.isEmpty()) {
append(notInferredTypeParameters.map { typeParameter -> IdeRenderers.error(typeParameter.getName()) }.makeString()) append(notInferredTypeParameters.map { typeParameter -> IdeRenderers.error(typeParameter.getName()) }.join())
append("<i> cannot be inferred</i>") append("<i> cannot be inferred</i>")
if (!inferredTypeParameters.isEmpty()) { if (!inferredTypeParameters.isEmpty()) {
append("; ") append("; ")
@@ -71,7 +71,7 @@ fun <D : CallableDescriptor> renderResolvedCall(resolvedCall: ResolvedCall<D>):
if (!inferredTypeParameters.isEmpty()) { if (!inferredTypeParameters.isEmpty()) {
append(inferredTypeParameters.map { typeParameter -> append(inferredTypeParameters.map { typeParameter ->
"${typeParameter.getName()} = ${htmlRenderer.renderType(typeParameterToTypeArgumentMap[typeParameter]!!)}" "${typeParameter.getName()} = ${htmlRenderer.renderType(typeParameterToTypeArgumentMap[typeParameter]!!)}"
}.makeString()) }.join())
} }
} }
@@ -81,7 +81,7 @@ fun <D : CallableDescriptor> renderResolvedCall(resolvedCall: ResolvedCall<D>):
append(htmlRenderer.renderType(receiverParameter.getType())).append(".") append(htmlRenderer.renderType(receiverParameter.getType())).append(".")
} }
append(resultingDescriptor.getName()).append("(") append(resultingDescriptor.getName()).append("(")
append(resultingDescriptor.getValueParameters().map { parameter -> renderParameter(parameter) }.makeString()) append(resultingDescriptor.getValueParameters().map { parameter -> renderParameter(parameter) }.join())
append(if (resolvedCall.hasUnmappedArguments()) IdeRenderers.error(")") else ")") append(if (resolvedCall.hasUnmappedArguments()) IdeRenderers.error(")") else ")")
if (!resolvedCall.getCandidateDescriptor().getTypeParameters().isEmpty()) { if (!resolvedCall.getCandidateDescriptor().getTypeParameters().isEmpty()) {
@@ -62,7 +62,7 @@ public class SubpackagesIndexService(private val project: Project) {
public fun getSubpackages(fqName: FqName, scope: GlobalSearchScope): Collection<FqName> { public fun getSubpackages(fqName: FqName, scope: GlobalSearchScope): Collection<FqName> {
val possibleFilesFqNames = fqNameByPrefix[fqName] val possibleFilesFqNames = fqNameByPrefix[fqName]
val existingSubPackagesShortNames = HashSet<Name>() val existingSubPackagesShortNames = HashSet<Name>()
val len = fqName.pathSegments().size val len = fqName.pathSegments().size()
for (filesFqName in possibleFilesFqNames) { for (filesFqName in possibleFilesFqNames) {
val candidateSubPackageShortName = filesFqName.pathSegments()[len] val candidateSubPackageShortName = filesFqName.pathSegments()[len]
if (candidateSubPackageShortName in existingSubPackagesShortNames) { if (candidateSubPackageShortName in existingSubPackagesShortNames) {
@@ -30,7 +30,7 @@ public class JsFunctionScope(parent: JsScope, description: String) : JsScope(par
private val labelScopes = Stack<LabelScope>() private val labelScopes = Stack<LabelScope>()
private val topLabelScope: LabelScope? private val topLabelScope: LabelScope?
get() = if (labelScopes.notEmpty) labelScopes.peek() else null get() = if (labelScopes.isNotEmpty()) labelScopes.peek() else null
override fun declareName(identifier: String): JsName = super.declareFreshName(identifier) override fun declareName(identifier: String): JsName = super.declareFreshName(identifier)
@@ -45,7 +45,7 @@ public class JsFunctionScope(parent: JsScope, description: String) : JsScope(par
} }
public fun exitLabel() { public fun exitLabel() {
assert(labelScopes.notEmpty) { "No scope to exit from" } assert(labelScopes.isNotEmpty()) { "No scope to exit from" }
labelScopes.pop() labelScopes.pop()
} }
@@ -96,7 +96,7 @@ private fun isNameInitialized(
initializer: JsStatement initializer: JsStatement
): Boolean { ): Boolean {
val thenStmt = (initializer as JsIf).getThenStatement()!! val thenStmt = (initializer as JsIf).getThenStatement()!!
val lastThenStmt = flattenStatement(thenStmt).last val lastThenStmt = flattenStatement(thenStmt).last()
val expr = (lastThenStmt as? JsExpressionStatement)?.getExpression() val expr = (lastThenStmt as? JsExpressionStatement)?.getExpression()
if (expr !is JsBinaryOperation) return false if (expr !is JsBinaryOperation) return false
@@ -88,7 +88,7 @@ public fun isCallInvocation(invocation: JsInvocation): Boolean {
val qualifier = invocation.getQualifier() as? JsNameRef val qualifier = invocation.getQualifier() as? JsNameRef
val arguments = invocation.getArguments() val arguments = invocation.getArguments()
return qualifier?.getIdent() == Namer.CALL_FUNCTION && arguments.notEmpty return qualifier?.getIdent() == Namer.CALL_FUNCTION && arguments.isNotEmpty()
} }
/** /**
@@ -34,7 +34,7 @@ public fun aliasArgumentsIfNeeded(
arguments: List<JsExpression>, arguments: List<JsExpression>,
parameters: List<JsParameter> parameters: List<JsParameter>
) { ) {
assertTrue { arguments.size <= parameters.size } assertTrue { arguments.size() <= parameters.size() }
for ((arg, param) in arguments zip parameters) { for ((arg, param) in arguments zip parameters) {
val paramName = param.getName() val paramName = param.getName()
@@ -50,7 +50,7 @@ public fun aliasArgumentsIfNeeded(
context.replaceName(paramName, replacement) context.replaceName(paramName, replacement)
} }
val defaultParams = parameters.subList(arguments.size, parameters.size) val defaultParams = parameters.subList(arguments.size(), parameters.size())
for (defaultParam in defaultParams) { for (defaultParam in defaultParams) {
val paramName = defaultParam.getName() val paramName = defaultParam.getName()
val freshName = context.getFreshName(paramName) val freshName = context.getFreshName(paramName)
+1 -1
View File
@@ -8,7 +8,7 @@ public inline fun String.indexOf(ch : Char, fromIndex : Int) : Int = indexOf(ch.
public inline fun String.matches(regex : String) : Boolean { public inline fun String.matches(regex : String) : Boolean {
val result = this.match(regex) val result = this.match(regex)
return result != null && result.size > 0 return result != null && result.size() > 0
} }
/** /**
@@ -73,7 +73,7 @@ public fun UsageTracker.getNameForCapturedDescriptor(descriptor: CallableDescrip
public fun UsageTracker.hasCapturedExceptContaining(): Boolean { public fun UsageTracker.hasCapturedExceptContaining(): Boolean {
val hasNotCaptured = val hasNotCaptured =
capturedDescriptorToJsName.isEmpty() || capturedDescriptorToJsName.isEmpty() ||
(capturedDescriptorToJsName.size == 1 && capturedDescriptorToJsName.containsKey(containingDescriptor)) (capturedDescriptorToJsName.size() == 1 && capturedDescriptorToJsName.containsKey(containingDescriptor))
return !hasNotCaptured return !hasNotCaptured
} }
@@ -67,9 +67,9 @@ class CatchTranslator(
* } * }
*/ */
public fun translate(): JsCatch? { public fun translate(): JsCatch? {
if (catches.empty) return null if (catches.isEmpty()) return null
val firstCatch = catches.first!! val firstCatch = catches.first()
val catchParameter = firstCatch.getCatchParameter() val catchParameter = firstCatch.getCatchParameter()
val parameterName = context().getNameForElement(catchParameter!!) val parameterName = context().getNameForElement(catchParameter!!)
val parameterRef = parameterName.makeRef() val parameterRef = parameterName.makeRef()
@@ -39,7 +39,7 @@ public abstract class ChangeSupport {
} }
var listeners = nameListeners?.get(name) var listeners = nameListeners?.get(name)
if (listeners == null) { if (listeners == null) {
listeners = arrayList<ChangeListener>() listeners = arrayListOf<ChangeListener>()
nameListeners?.put(name, listeners!!) nameListeners?.put(name, listeners!!)
} }
listeners?.add(listener) listeners?.add(listener)
+3 -3
View File
@@ -10,10 +10,10 @@ private fun listDifference<T>(first : List<T>, second : List<T>) : List<T> {
class StdLibIssuesTest { class StdLibIssuesTest {
test fun test_KT_1131() { test fun test_KT_1131() {
val data = arrayList("blah", "foo", "bar") val data = arrayListOf("blah", "foo", "bar")
val filterValues = arrayList("bar", "something", "blah") val filterValues = arrayListOf("bar", "something", "blah")
expect(arrayList("foo")) { expect(arrayListOf("foo")) {
val answer = listDifference(data, filterValues) val answer = listDifference(data, filterValues)
println("Found answer ${answer}") println("Found answer ${answer}")
answer answer
@@ -33,7 +33,7 @@ class MapJVMTest {
test fun toProperties() { test fun toProperties() {
val map = mapOf("a" to "A", "b" to "B") val map = mapOf("a" to "A", "b" to "B")
val prop = map.toProperties() val prop = map.toProperties()
assertEquals(2, prop.size) assertEquals(2, prop.size())
assertEquals("A", prop.getProperty("a", "fail")) assertEquals("A", prop.getProperty("a", "fail"))
assertEquals("B", prop.getProperty("b", "fail")) assertEquals("B", prop.getProperty("b", "fail"))
} }
+17 -17
View File
@@ -36,18 +36,18 @@ class MapTest {
test fun sizeAndEmpty() { test fun sizeAndEmpty() {
val data = hashMapOf<String, Int>() val data = hashMapOf<String, Int>()
assertTrue { data.empty } assertTrue { data.none() }
assertEquals(data.size, 0) assertEquals(data.size(), 0)
} }
test fun setViaIndexOperators() { test fun setViaIndexOperators() {
val map = hashMapOf<String, String>() val map = hashMapOf<String, String>()
assertTrue { map.empty } assertTrue { map.none() }
assertEquals(map.size, 0) assertEquals(map.size(), 0)
map["name"] = "James" map["name"] = "James"
assertTrue { !map.empty } assertTrue { map.any() }
assertEquals(map.size(), 1) assertEquals(map.size(), 1)
assertEquals("James", map["name"]) assertEquals("James", map["name"])
} }
@@ -119,21 +119,21 @@ class MapTest {
test fun createUsingPairs() { test fun createUsingPairs() {
val map = mapOf(Pair("a", 1), Pair("b", 2)) val map = mapOf(Pair("a", 1), Pair("b", 2))
assertEquals(2, map.size) assertEquals(2, map.size())
assertEquals(1, map["a"]) assertEquals(1, map["a"])
assertEquals(2, map["b"]) assertEquals(2, map["b"])
} }
test fun createFromIterable() { test fun createFromIterable() {
val map = listOf(Pair("a", 1), Pair("b", 2)).toMap() val map = listOf(Pair("a", 1), Pair("b", 2)).toMap()
assertEquals(2, map.size) assertEquals(2, map.size())
assertEquals(1, map.get("a")) assertEquals(1, map.get("a"))
assertEquals(2, map.get("b")) assertEquals(2, map.get("b"))
} }
test fun createWithSelector() { test fun createWithSelector() {
val map = listOf("a", "bb", "ccc").toMap { it.length } val map = listOf("a", "bb", "ccc").toMap { it.length }
assertEquals(3, map.size) assertEquals(3, map.size())
assertEquals("a", map.get(1)) assertEquals("a", map.get(1))
assertEquals("bb", map.get(2)) assertEquals("bb", map.get(2))
assertEquals("ccc", map.get(3)) assertEquals("ccc", map.get(3))
@@ -141,14 +141,14 @@ class MapTest {
test fun createWithSelectorAndOverwrite() { test fun createWithSelectorAndOverwrite() {
val map = listOf("aa", "bb", "ccc").toMap { it.length } val map = listOf("aa", "bb", "ccc").toMap { it.length }
assertEquals(2, map.size) assertEquals(2, map.size())
assertEquals("bb", map.get(2)) assertEquals("bb", map.get(2))
assertEquals("ccc", map.get(3)) assertEquals("ccc", map.get(3))
} }
test fun createUsingTo() { test fun createUsingTo() {
val map = mapOf("a" to 1, "b" to 2) val map = mapOf("a" to 1, "b" to 2)
assertEquals(2, map.size) assertEquals(2, map.size())
assertEquals(1, map["a"]) assertEquals(1, map["a"])
assertEquals(2, map["b"]) assertEquals(2, map["b"])
} }
@@ -164,21 +164,21 @@ class MapTest {
test fun filter() { test fun filter() {
val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2)) val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2))
val filteredByKey = map.filter { it.key == "b" } val filteredByKey = map.filter { it.key == "b" }
assertEquals(1, filteredByKey.size) assertEquals(1, filteredByKey.size())
assertEquals(3, filteredByKey["b"]) assertEquals(3, filteredByKey["b"])
val filteredByKey2 = map.filterKeys { it == "b" } val filteredByKey2 = map.filterKeys { it == "b" }
assertEquals(1, filteredByKey2.size) assertEquals(1, filteredByKey2.size())
assertEquals(3, filteredByKey2["b"]) assertEquals(3, filteredByKey2["b"])
val filteredByValue = map.filter { it.value == 2 } val filteredByValue = map.filter { it.value == 2 }
assertEquals(2, filteredByValue.size) assertEquals(2, filteredByValue.size())
assertEquals(null, filteredByValue["b"]) assertEquals(null, filteredByValue["b"])
assertEquals(2, filteredByValue["c"]) assertEquals(2, filteredByValue["c"])
assertEquals(2, filteredByValue["a"]) assertEquals(2, filteredByValue["a"])
val filteredByValue2 = map.filterValues { it == 2 } val filteredByValue2 = map.filterValues { it == 2 }
assertEquals(2, filteredByValue2.size) assertEquals(2, filteredByValue2.size())
assertEquals(null, filteredByValue2["b"]) assertEquals(null, filteredByValue2["b"])
assertEquals(2, filteredByValue2["c"]) assertEquals(2, filteredByValue2["c"])
assertEquals(2, filteredByValue2["a"]) assertEquals(2, filteredByValue2["a"])
@@ -187,20 +187,20 @@ class MapTest {
test fun filterNot() { test fun filterNot() {
val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2)) val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2))
val filteredByKey = map.filterNot { it.key == "b" } val filteredByKey = map.filterNot { it.key == "b" }
assertEquals(2, filteredByKey.size) assertEquals(2, filteredByKey.size())
assertEquals(null, filteredByKey["b"]) assertEquals(null, filteredByKey["b"])
assertEquals(2, filteredByKey["c"]) assertEquals(2, filteredByKey["c"])
assertEquals(2, filteredByKey["a"]) assertEquals(2, filteredByKey["a"])
val filteredByValue = map.filterNot { it.value == 2 } val filteredByValue = map.filterNot { it.value == 2 }
assertEquals(1, filteredByValue.size) assertEquals(1, filteredByValue.size())
assertEquals(3, filteredByValue["b"]) assertEquals(3, filteredByValue["b"])
} }
test fun plusAssign() { test fun plusAssign() {
val extended = hashMapOf(Pair("b", 3)) val extended = hashMapOf(Pair("b", 3))
extended += ("c" to 2) extended += ("c" to 2)
assertEquals(2, extended.size) assertEquals(2, extended.size())
assertEquals(2, extended["c"]) assertEquals(2, extended["c"])
assertEquals(3, extended["b"]) assertEquals(3, extended["b"])
} }
@@ -10,17 +10,17 @@ class FunctionIteratorTest {
Test fun iterateOverFunction() { Test fun iterateOverFunction() {
var count = 3 var count = 3
val iter = iterate<Int> { val iter = stream<Int> {
count-- count--
if (count >= 0) count else null if (count >= 0) count else null
} }
val list = iter.toList() val list = iter.toList()
assertEquals(arrayList(2, 1, 0), list) assertEquals(arrayListOf(2, 1, 0), list)
} }
Test fun iterateOverFunction2() { Test fun iterateOverFunction2() {
val values = iterate<Int>(3) { n -> if (n > 0) n - 1 else null } val values = stream<Int>(3) { n -> if (n > 0) n - 1 else null }
assertEquals(arrayList(3, 2, 1, 0), values.toList()) assertEquals(arrayListOf(3, 2, 1, 0), values.toList())
} }
} }
@@ -11,7 +11,7 @@ class IteratorsJVMTest {
fun intToBinaryDigits() = { (i: Int) -> fun intToBinaryDigits() = { (i: Int) ->
val binary = Integer.toBinaryString(i)!! val binary = Integer.toBinaryString(i)!!
var index = 0 var index = 0
iterate<Char> { if (index < binary.length()) binary.get(index++) else null } stream<Char> { if (index < binary.length()) binary.get(index++) else null }
} }
val expected = arrayListOf( val expected = arrayListOf(
@@ -27,7 +27,7 @@ class IteratorsJVMTest {
} }
test fun flatMapOnIterator() { test fun flatMapOnIterator() {
val result = listOf(1, 2).iterator().flatMap { i -> (0..i).iterator()} val result = streamOf(1, 2).flatMap { i -> (0..i).stream()}
assertEquals(listOf(0, 1, 0, 1, 2), result.toList()) assertEquals(listOf(0, 1, 0, 1, 2), result.toList())
} }
} }
@@ -5,67 +5,67 @@ import org.junit.Test as test
import kotlin.test.fails import kotlin.test.fails
import java.util.ArrayList import java.util.ArrayList
fun fibonacci(): Iterator<Int> { fun fibonacci(): Stream<Int> {
// fibonacci terms // fibonacci terms
var index = 0; var a = 0; var b = 1 var index = 0; var a = 0; var b = 1
return iterate<Int> { when (index++) { 0 -> a; 1 -> b; else -> { val result = a + b; a = b; b = result; result } } } return stream<Int> { when (index++) { 0 -> a; 1 -> b; else -> { val result = a + b; a = b; b = result; result } } }
} }
class IteratorsTest { class IteratorsTest {
test fun filterAndTakeWhileExtractTheElementsWithinRange() { test fun filterAndTakeWhileExtractTheElementsWithinRange() {
assertEquals(arrayList(144, 233, 377, 610, 987), fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.toList()) assertEquals(arrayListOf(144, 233, 377, 610, 987), fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.toList())
} }
test fun foldReducesTheFirstNElements() { test fun foldReducesTheFirstNElements() {
val sum = { (a: Int, b: Int) -> a + b } val sum = { (a: Int, b: Int) -> a + b }
assertEquals(arrayList(13, 21, 34, 55, 89).fold(0, sum), fibonacci().filter { it > 10 }.take(5).fold(0, sum)) assertEquals(arrayListOf(13, 21, 34, 55, 89).fold(0, sum), fibonacci().filter { it > 10 }.take(5).fold(0, sum))
} }
test fun takeExtractsTheFirstNElements() { test fun takeExtractsTheFirstNElements() {
assertEquals(arrayList(0, 1, 1, 2, 3, 5, 8, 13, 21, 34), fibonacci().take(10).toList()) assertEquals(arrayListOf(0, 1, 1, 2, 3, 5, 8, 13, 21, 34), fibonacci().take(10).toList())
} }
test fun mapAndTakeWhileExtractTheTransformedElements() { test fun mapAndTakeWhileExtractTheTransformedElements() {
assertEquals(arrayList(0, 3, 3, 6, 9, 15), fibonacci().map { it * 3 }.takeWhile { (i: Int) -> i < 20 }.toList()) assertEquals(arrayListOf(0, 3, 3, 6, 9, 15), fibonacci().map { it * 3 }.takeWhile { (i: Int) -> i < 20 }.toList())
} }
test fun joinConcatenatesTheFirstNElementsAboveAThreshold() { test fun joinConcatenatesTheFirstNElementsAboveAThreshold() {
assertEquals("13, 21, 34, 55, 89, ...", fibonacci().filter { it > 10 }.makeString(separator = ", ", limit = 5)) assertEquals("13, 21, 34, 55, 89, ...", fibonacci().filter { it > 10 }.joinToString(separator = ", ", limit = 5))
} }
test fun plus() { test fun plus() {
val iter = arrayList("foo", "bar").iterator() val iter = arrayListOf("foo", "bar").stream()
val iter2 = iter + "cheese" val iter2 = iter + "cheese"
assertEquals(arrayList("foo", "bar", "cheese"), iter2.toList()) assertEquals(arrayListOf("foo", "bar", "cheese"), iter2.toList())
// lets use a mutable variable // lets use a mutable variable
var mi : Iterator<String> = arrayList("a", "b").iterator() var mi = streamOf("a", "b")
mi += "c" mi += "c"
assertEquals(arrayList("a", "b", "c"), mi.toList()) assertEquals(arrayListOf("a", "b", "c"), mi.toList())
} }
test fun plusCollection() { test fun plusCollection() {
val a = arrayList("foo", "bar") val a = arrayListOf("foo", "bar")
val b = arrayList("cheese", "wine") val b = arrayListOf("cheese", "wine")
val iter = a.iterator() + b.iterator() val iter = a.stream() + b.stream()
assertEquals(arrayList("foo", "bar", "cheese", "wine"), iter.toList()) assertEquals(arrayListOf("foo", "bar", "cheese", "wine"), iter.toList())
// lets use a mutable variable // lets use a mutable variable
var ml : Iterator<String> = arrayList("a").iterator() var ml = arrayListOf("a").stream()
ml += a.iterator() ml += a.stream()
ml += "beer" ml += "beer"
ml += b ml += b
ml += "z" ml += "z"
assertEquals(arrayList("a", "foo", "bar", "beer", "cheese", "wine", "z"), ml.toList()) assertEquals(arrayListOf("a", "foo", "bar", "beer", "cheese", "wine", "z"), ml.toList())
} }
test fun requireNoNulls() { test fun requireNoNulls() {
val iter = arrayList<String?>("foo", "bar").iterator() val iter = arrayListOf<String?>("foo", "bar").stream()
val notNull = iter.requireNoNulls() val notNull = iter.requireNoNulls()
assertEquals(arrayList("foo", "bar"), notNull.toList()) assertEquals(arrayListOf("foo", "bar"), notNull.toList())
val iterWithNulls = arrayList("foo", null, "bar").iterator() val iterWithNulls = arrayListOf("foo", null, "bar").stream()
val notNull2 = iterWithNulls.requireNoNulls() val notNull2 = iterWithNulls.requireNoNulls()
fails { fails {
// should throw an exception as we have a null // should throw an exception as we have a null
@@ -74,23 +74,23 @@ class IteratorsTest {
} }
test fun toStringJoinsNoMoreThanTheFirstTenElements() { test fun toStringJoinsNoMoreThanTheFirstTenElements() {
assertEquals("0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...", fibonacci().makeString(limit = 10)) assertEquals("0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...", fibonacci().joinToString(limit = 10))
assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().filter { it > 10 }.makeString(limit = 10)) assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().filter { it > 10 }.joinToString(limit = 10))
assertEquals("144, 233, 377, 610, 987", fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.makeString()) assertEquals("144, 233, 377, 610, 987", fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.joinToString())
} }
test fun pairIterator() { test fun pairIterator() {
val pairStr = (fibonacci() zip fibonacci().map { i -> i*2 }).makeString(limit = 10) val pairStr = (fibonacci() zip fibonacci().map { i -> i*2 }).joinToString(limit = 10)
assertEquals("(0, 0), (1, 2), (1, 2), (2, 4), (3, 6), (5, 10), (8, 16), (13, 26), (21, 42), (34, 68), ...", pairStr) assertEquals("(0, 0), (1, 2), (1, 2), (2, 4), (3, 6), (5, 10), (8, 16), (13, 26), (21, 42), (34, 68), ...", pairStr)
} }
test fun skippingIterator() { test fun skippingIterator() {
assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().skip(7).makeString(limit = 10)) assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().drop(7).joinToString(limit = 10))
assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().skip(3).skip(4).makeString(limit = 10)) assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().drop(3).drop(4).joinToString(limit = 10))
} }
test fun iterationOverIterator() { test fun iterationOverIterator() {
val c = arrayList(0, 1, 2, 3, 4, 5) val c = arrayListOf(0, 1, 2, 3, 4, 5)
var s = "" var s = ""
for (i in c.iterator()) { for (i in c.iterator()) {
s = s + i.toString() s = s + i.toString()
@@ -104,7 +104,7 @@ class IteratorsTest {
} }
test fun iterableExtension() { test fun iterableExtension() {
val c = arrayList(0, 1, 2, 3, 4, 5) val c = arrayListOf(0, 1, 2, 3, 4, 5)
val d = ArrayList<Int>() val d = ArrayList<Int>()
c.iterator().takeWhileTo(d, {i -> i < 4 }) c.iterator().takeWhileTo(d, {i -> i < 4 })
assertEquals(4, d.size()) assertEquals(4, d.size())
+6 -7
View File
@@ -126,20 +126,19 @@ abstract class MapJsTest {
val data = emptyMap() val data = emptyMap()
assertTrue(data.isEmpty()) assertTrue(data.isEmpty())
assertTrue(data.empty) assertTrue(data.none())
assertEquals(0, data.size()) assertEquals(0, data.size())
assertEquals(0, data.size) assertEquals(0, data.size())
} }
test fun sizeAndEmpty() { test fun sizeAndEmpty() {
val data = createTestMap() val data = createTestMap()
assertFalse(data.isEmpty()) assertFalse(data.isEmpty())
assertFalse(data.empty) assertFalse(data.none())
assertEquals(KEYS.size(), data.size()) assertEquals(KEYS.size(), data.size())
assertEquals(KEYS.size(), data.size)
} }
// #KT-3035 // #KT-3035
@@ -200,7 +199,7 @@ abstract class MapJsTest {
val map = createTestMap() val map = createTestMap()
val newMap = emptyMutableMap() val newMap = emptyMutableMap()
newMap.putAll(map) newMap.putAll(map)
assertEquals(KEYS.size(), newMap.size) assertEquals(KEYS.size(), newMap.size())
} }
test fun mapRemove() { test fun mapRemove() {
@@ -271,14 +270,14 @@ abstract class MapJsTest {
test fun createUsingPairs() { test fun createUsingPairs() {
val map = mapOf(Pair("a", 1), Pair("b", 2)) val map = mapOf(Pair("a", 1), Pair("b", 2))
assertEquals(2, map.size) assertEquals(2, map.size())
assertEquals(1, map.get("a")) assertEquals(1, map.get("a"))
assertEquals(2, map.get("b")) assertEquals(2, map.get("b"))
} }
test fun createUsingTo() { test fun createUsingTo() {
val map = mapOf("a" to 1, "b" to 2) val map = mapOf("a" to 1, "b" to 2)
assertEquals(2, map.size) assertEquals(2, map.size())
assertEquals(1, map.get("a")) assertEquals(1, map.get("a"))
assertEquals(2, map.get("b")) assertEquals(2, map.get("b"))
} }
+1 -1
View File
@@ -217,7 +217,7 @@ class StringJVMTest {
// group characters by their case // group characters by their case
val data = "abAbaABcD" val data = "abAbaABcD"
val result = data.groupBy { it.isLowerCase() } val result = data.groupBy { it.isLowerCase() }
assertEquals(2, result.size) assertEquals(2, result.size())
assertEquals(listOf('a','b','b','a','c'), result.get(true)) assertEquals(listOf('a','b','b','a','c'), result.get(true))
} }