Fix "infix modifier required" errors in project

This commit is contained in:
Yan Zhulanow
2015-11-24 17:27:48 +03:00
parent d1c5bd4526
commit 46ac3571d5
44 changed files with 65 additions and 65 deletions
@@ -125,7 +125,7 @@ public open class MethodAnalyzer<V : Value>(
frames[instructions.indexOf(insn)]
private fun checkAssertions() {
if (instructions.toArray() any { it.getOpcode() == Opcodes.JSR || it.getOpcode() == Opcodes.RET })
if (instructions.toArray().any { it.getOpcode() == Opcodes.JSR || it.getOpcode() == Opcodes.RET })
throw AssertionError("Subroutines are deprecated since Java 6")
}
@@ -36,10 +36,10 @@ found top-level declarations to <destination dir> (files such as
val destDir = File(args[0])
val srcDirs = args drop(1) map { File(it) }
val srcDirs = args.drop(1).map { File(it) }
assert(srcDirs.isNotEmpty()) { "At least one source directory should be specified" }
val missing = srcDirs filterNot { it.exists() }
val missing = srcDirs.filterNot { it.exists() }
assert(missing.isEmpty()) { "These source directories are missing: $missing" }
BuiltInsSerializer(dependOnOldBuiltIns = false).serialize(destDir, srcDirs, listOf()) { totalSize, totalFiles ->
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.cli.jvm.repl.ReplFromTerminal
import java.io.File
public class ConsoleReplCommandReader : ReplCommandReader {
private val consoleReader = ConsoleReader("kotlin", System.`in`, System.`out`, null) apply {
private val consoleReader = ConsoleReader("kotlin", System.`in`, System.`out`, null).apply {
isHistoryEnabled = true
expandEvents = false
history = FileHistory(File(File(System.getProperty("user.home")), ".kotlin_history"))
@@ -412,7 +412,7 @@ public val KtDeclaration.containingClassOrObject: KtClassOrObject?
get() = (parent as? KtClassBody)?.parent as? KtClassOrObject
public fun KtExpression.getOutermostParenthesizerOrThis(): KtExpression {
return (parentsWithSelf zip parents).firstOrNull {
return (parentsWithSelf.zip(parents)).firstOrNull {
val (element, parent) = it
when (parent) {
is KtParenthesizedExpression -> false
@@ -37,7 +37,7 @@ public class KotlinObjectStubImpl(
) : KotlinStubBaseImpl<KtObjectDeclaration>(parent, KtStubElementTypes.OBJECT_DECLARATION), KotlinObjectStub {
override fun getFqName() = fqName
override fun getName() = StringRef.toString(name)
override fun getSuperNames() = superNames map { it.toString() }
override fun getSuperNames() = superNames.map { it.toString() }
override fun isTopLevel() = isTopLevel
override fun isCompanion() = isDefault
override fun isObjectLiteral() = isObjectLiteral
@@ -118,7 +118,7 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
while (userType != null) {
val referenceExpression = userType.referenceExpression
if (referenceExpression != null) {
result add QualifierPart(referenceExpression.getReferencedNameAsName(), referenceExpression, userType.typeArgumentList)
result.add(QualifierPart(referenceExpression.getReferencedNameAsName(), referenceExpression, userType.typeArgumentList))
}
else {
hasError = true
@@ -261,12 +261,12 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
loop@ while (expression != null) {
when (expression) {
is KtSimpleNameExpression -> {
result add QualifierPart(expression.getReferencedNameAsName(), expression)
result.add(QualifierPart(expression.getReferencedNameAsName(), expression))
break@loop
}
is KtQualifiedExpression -> {
(expression.selectorExpression as? KtSimpleNameExpression)?.let {
result add QualifierPart(it.getReferencedNameAsName(), it)
result.add(QualifierPart(it.getReferencedNameAsName(), it))
}
expression = expression.receiverExpression
if (expression is KtSafeQualifiedExpression) {
@@ -192,6 +192,6 @@ class VarianceChecker(private val trace: BindingTrace) {
return noError
}
private fun Boolean.and(other: Boolean?) = if (other == null) this else this and other
private infix fun Boolean.and(other: Boolean?) = if (other == null) this else this and other
}
}
@@ -36,7 +36,7 @@ public class CliDeclarationProviderFactoryService(private val sourceFiles: Colle
val vFile = it.getVirtualFile().sure { "Source files should be physical files" }
filesScope.contains(vFile)
}
allFiles addAll syntheticFiles
allFiles.addAll(syntheticFiles)
return FileBasedDeclarationProviderFactory(storageManager, allFiles)
}
}
@@ -49,7 +49,7 @@ public class ValueParameterResolver(
val contextForDefaultValue = ExpressionTypingContext.newContext(trace, scopeForDefaultValue, dataFlowInfo, TypeUtils.NO_EXPECTED_TYPE, callChecker)
for ((descriptor, parameter) in valueParameterDescriptors zip valueParameters) {
for ((descriptor, parameter) in valueParameterDescriptors.zip(valueParameters)) {
ForceResolveUtil.forceResolveAllContents(descriptor.getAnnotations())
resolveDefaultValue(descriptor, parameter, contextForDefaultValue)
}
@@ -138,7 +138,7 @@ class FilteredJvmDiagnostics(val jvmDiagnostics: Diagnostics, val otherDiagnosti
}
}
private fun ConflictingJvmDeclarationsData.higherThan(other: ConflictingJvmDeclarationsData): Boolean {
private infix fun ConflictingJvmDeclarationsData.higherThan(other: ConflictingJvmDeclarationsData): Boolean {
return when (other.classOrigin.originKind) {
PACKAGE_PART -> this.classOrigin.originKind == PACKAGE_FACADE
INTERFACE_DEFAULT_IMPL -> this.classOrigin.originKind != INTERFACE_DEFAULT_IMPL
@@ -124,7 +124,7 @@ public abstract class AbstractWriteSignatureTest : TestCaseWithTmpdir() {
val packageFacadePrefix = classLastName.replace(".class", "\$")
classDir.listFiles { dir, lastName ->
lastName.startsWith(packageFacadePrefix) && lastName.endsWith(".class")
} forEach { packageFacadeFile ->
}.forEach { packageFacadeFile ->
checkClassFile(checker, packageFacadeFile)
}
}
@@ -152,17 +152,17 @@ public abstract class AbstractWriteSignatureTest : TestCaseWithTmpdir() {
private inner class Checker : ClassVisitor(Opcodes.ASM5) {
override fun visit(version: Int, access: Int, name: String, signature: String?, superName: String?, interfaces: Array<out String>?) {
classExpectations forEach { it.check(name, name, signature?:"null") }
classExpectations.forEach { it.check(name, name, signature ?: "null") }
super.visit(version, access, name, signature, superName, interfaces)
}
override fun visitMethod(access: Int, name: String, desc: String, signature: String?, exceptions: Array<out String>?): MethodVisitor? {
methodExpectations forEach { it.check(name, desc, signature?:"null") }
methodExpectations.forEach { it.check(name, desc, signature ?: "null") }
return super.visitMethod(access, name, desc, signature, exceptions)
}
override fun visitField(access: Int, name: String, desc: String, signature: String?, value: Any?): FieldVisitor? {
fieldExpectations forEach { it.check(name, desc, signature?:"null") }
fieldExpectations.forEach { it.check(name, desc, signature ?: "null") }
return super.visitField(access, name, desc, signature, value)
}
}
@@ -51,7 +51,7 @@ public class KotlinJavascriptSerializerTest : TestCaseWithTmpdir() {
val configuration = CompilerConfiguration()
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
configuration.addKotlinSourceRoots(srcDirs map { it.path })
configuration.addKotlinSourceRoots(srcDirs.map { it.path })
serialize(configuration, metaFile)
val module = deserialize(metaFile)
@@ -83,7 +83,7 @@ public class LazyJavaClassMemberScope(
}
enhanceSignatures(
result ifEmpty { emptyOrSingletonList(createDefaultConstructor()) }
result.ifEmpty { emptyOrSingletonList(createDefaultConstructor()) }
).toReadOnlyList()
}
@@ -122,7 +122,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) {
else -> error("Unsupported annotation argument type: ${value.getType()} (expected $expectedType)")
}
if (result.type isSubtypeOf expectedType) {
if (result.type.isSubtypeOf(expectedType)) {
return result
}
else {
@@ -82,7 +82,7 @@ fun main(args: Array<String>) {
generateBuiltIns { file, generator ->
println("generating $file")
file.getParentFile()?.mkdirs()
PrintWriter(file) use {
PrintWriter(file).use {
generator(it).generate()
}
}
@@ -28,7 +28,7 @@ class GenerateBuiltInsTest : UsefulTestCase() {
fun testBuiltInsAreUpToDate() {
generateBuiltIns { file, generator ->
val sw = StringWriter()
PrintWriter(sw) use {
PrintWriter(sw).use {
generator(it).generate()
}
@@ -26,7 +26,7 @@ public fun getTypeSubstitution(baseType: KotlinType, derivedType: KotlinType): L
val substitutedType = TypeCheckingProcedure.findCorrespondingSupertype(derivedType, baseType) ?: return null
val substitution = LinkedHashMap<TypeConstructor, TypeProjection>(substitutedType.getArguments().size())
for ((param, arg) in baseType.getConstructor().getParameters() zip substitutedType.getArguments()) {
for ((param, arg) in baseType.getConstructor().getParameters().zip(substitutedType.getArguments())) {
substitution[param.getTypeConstructor()] = arg
}
@@ -41,7 +41,7 @@ public fun getCallableSubstitution(
val derivedClass = derivedCallable.getContainingDeclaration() as? ClassDescriptor ?: return null
val substitution = getTypeSubstitution(baseClass.getDefaultType(), derivedClass.getDefaultType()) ?: return null
for ((baseParam, derivedParam) in baseCallable.getTypeParameters() zip derivedCallable.getTypeParameters()) {
for ((baseParam, derivedParam) in baseCallable.getTypeParameters().zip(derivedCallable.getTypeParameters())) {
substitution[baseParam.getTypeConstructor()] = TypeProjectionImpl(derivedParam.getDefaultType())
}
@@ -81,7 +81,7 @@ public abstract class AbstractKtReference<T : KtElement>(element: T)
private fun resolveToPsiElements(context: BindingContext, targetDescriptors: Collection<DeclarationDescriptor>): Collection<PsiElement> {
if (targetDescriptors.isNotEmpty()) {
return targetDescriptors flatMap { target -> resolveToPsiElements(target) }
return targetDescriptors.flatMap { target -> resolveToPsiElements(target) }
}
val labelTargets = getLabelTargets(context)
@@ -24,10 +24,10 @@ import com.intellij.psi.search.SearchScope
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.psi.KtFile
public fun SearchScope.and(otherScope: SearchScope): SearchScope = intersectWith(otherScope)
public fun SearchScope.or(otherScope: SearchScope): SearchScope = union(otherScope)
public fun SearchScope.minus(otherScope: GlobalSearchScope): SearchScope = this and !otherScope
public fun GlobalSearchScope.not(): GlobalSearchScope = GlobalSearchScope.notScope(this)
infix fun SearchScope.and(otherScope: SearchScope): SearchScope = intersectWith(otherScope)
infix fun SearchScope.or(otherScope: SearchScope): SearchScope = union(otherScope)
operator fun SearchScope.minus(otherScope: GlobalSearchScope): SearchScope = this and !otherScope
operator fun GlobalSearchScope.not(): GlobalSearchScope = GlobalSearchScope.notScope(this)
public fun Project.allScope(): GlobalSearchScope = GlobalSearchScope.allScope(this)
@@ -103,8 +103,8 @@ abstract class CompletionSession(
protected val bindingContext = resolutionFacade.analyze(position.parentsWithSelf.firstIsInstance<KtElement>(), BodyResolveMode.PARTIAL_FOR_COMPLETION)
protected val inDescriptor = position.getResolutionScope(bindingContext, resolutionFacade).ownerDescriptor
private val kotlinIdentifierStartPattern = StandardPatterns.character().javaIdentifierStart() andNot singleCharPattern('$')
private val kotlinIdentifierPartPattern = StandardPatterns.character().javaIdentifierPart() andNot singleCharPattern('$')
private val kotlinIdentifierStartPattern = StandardPatterns.character().javaIdentifierStart().andNot(singleCharPattern('$'))
private val kotlinIdentifierPartPattern = StandardPatterns.character().javaIdentifierPart().andNot(singleCharPattern('$'))
protected val prefix = CompletionUtil.findIdentifierPrefix(
parameters.getPosition().getContainingFile(),
@@ -123,7 +123,7 @@ abstract class CompletionSession(
nameFilter
}
private fun ((Name) -> Boolean).or(otherFilter: (Name) -> Boolean): (Name) -> Boolean
private infix fun ((Name) -> Boolean).or(otherFilter: (Name) -> Boolean): (Name) -> Boolean
= { this(it) || otherFilter(it) }
protected val isVisibleFilter: (DeclarationDescriptor) -> Boolean = { isVisibleDescriptor(it, completeNonAccessible = configuration.completeNonAccessibleDeclarations) }
@@ -345,9 +345,9 @@ fun shortenReferences(context: InsertionContext, startOffset: Int, endOffset: In
ShortenReferences.DEFAULT.process(context.file as KtFile, startOffset, endOffset)
}
fun <T> ElementPattern<T>.and(rhs: ElementPattern<T>) = StandardPatterns.and(this, rhs)
infix fun <T> ElementPattern<T>.and(rhs: ElementPattern<T>) = StandardPatterns.and(this, rhs)
fun <T> ElementPattern<T>.andNot(rhs: ElementPattern<T>) = StandardPatterns.and(this, StandardPatterns.not(rhs))
fun <T> ElementPattern<T>.or(rhs: ElementPattern<T>) = StandardPatterns.or(this, rhs)
infix fun <T> ElementPattern<T>.or(rhs: ElementPattern<T>) = StandardPatterns.or(this, rhs)
fun singleCharPattern(char: Char) = StandardPatterns.character().equalTo(char)
@@ -215,7 +215,7 @@ public class KotlinCompletionContributor : CompletionContributor() {
if (tokenType == KtTokens.FUN_KEYWORD) {
tail += "()"
}
builder append tail
builder.append(tail)
val text = builder.toString()
val file = KtPsiFactory(tokenBefore.getProject()).createFile(text)
@@ -28,7 +28,7 @@ public class ConsoleErrorRenderer(private val messages: List<SeverityDetails>) :
}
override fun getTooltipText(): String {
val htmlTooltips = messages map { "<b>${msgType(it.severity)}</b> ${it.description}" }
val htmlTooltips = messages.map { "<b>${msgType(it.severity)}</b> ${it.description}" }
return "<html>${htmlTooltips.joinToString("<hr size=1 noshade>")}</html>"
}
@@ -85,7 +85,7 @@ public fun getOverriddenMethodTooltip(method: PsiMethod): String? {
val comparator = MethodCellRenderer(false).getComparator()
val overridingJavaMethods = processor.getCollection().filter { !it.isMethodWithDeclarationInOtherClass() } sortedWith (comparator)
val overridingJavaMethods = processor.getCollection().filter { !it.isMethodWithDeclarationInOtherClass() }.sortedWith(comparator)
if (overridingJavaMethods.isEmpty()) return null
val start = if (isAbstract) DaemonBundle.message("method.is.implemented.header") else DaemonBundle.message("method.is.overriden.header")
@@ -377,7 +377,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
fakeFunction: FunctionDescriptor,
typeArguments: Set<KotlinType>,
result: MutableMap<KotlinType, KotlinType>) {
for ((typeArgument, typeParameter) in typeArguments zip fakeFunction.getTypeParameters()) {
for ((typeArgument, typeParameter) in typeArguments.zip(fakeFunction.getTypeParameters())) {
result[typeArgument] = typeParameter.getDefaultType()
}
}
@@ -43,7 +43,7 @@ internal class ParameterNameExpression(
private val names: Array<String>,
private val parameterTypeToNamesMap: Map<String, Array<String>>) : Expression() {
init {
assert(names all { it.isNotEmpty() })
assert(names.all { it.isNotEmpty() })
}
override fun calculateResult(context: ExpressionContext?): Result? {
@@ -276,7 +276,7 @@ private fun TypePredicate.getRepresentativeTypes(): Set<KotlinType> {
is AllSubtypes -> Collections.singleton(upperBound)
is ForAllTypes -> {
if (typeSets.isEmpty()) AllTypes.getRepresentativeTypes()
else typeSets.map { it.getRepresentativeTypes() }.reduce { a, b -> a intersect b }
else typeSets.map { it.getRepresentativeTypes() }.reduce { a, b -> a.intersect(b) }
}
is ForSomeType -> typeSets.flatMapTo(LinkedHashSet<KotlinType>()) { it.getRepresentativeTypes() }
is AllTypes -> emptySet()
@@ -109,7 +109,7 @@ public abstract class CallableRefactoring<T: CallableDescriptor>(
public fun run(): Boolean {
fun buttonPressed(code: Int, dialogButtons: List<String>, button: String): Boolean {
return code == dialogButtons indexOf button && button in dialogButtons
return code == dialogButtons.indexOf(button) && button in dialogButtons
}
fun performForWholeHierarchy(dialogButtons: List<String>, code: Int): Boolean {
@@ -337,7 +337,7 @@ public open class KotlinChangeInfo(
if (!(isPrimaryMethodUpdated
&& originalBaseFunctionDescriptor is FunctionDescriptor
&& originalBaseFunctionDescriptor.hasJvmOverloadsAnnotation())) {
return (originalPsiMethods zip currentPsiMethods).toMap()
return (originalPsiMethods.zip(currentPsiMethods)).toMap()
}
if (originalPsiMethods.isEmpty() || currentPsiMethods.isEmpty()) return emptyMap()
@@ -158,7 +158,7 @@ public class KotlinChangeSignature(project: Project,
// TODO: Support visibility change
val visibility = VisibilityUtil.getVisibilityModifier(originalMethod.getModifierList())
val returnType = CanonicalTypes.createTypeWrapper(preview.getReturnType() ?: PsiType.VOID)
val params = (preview.getParameterList().getParameters() zip ktChangeInfo.getNewParameters()).map {
val params = (preview.getParameterList().getParameters().zip(ktChangeInfo.getNewParameters())).map {
val (param, paramInfo) = it
// Keep original default value for proper update of Kotlin usages
KotlinAwareJavaParameterInfoImpl(paramInfo.getOldIndex(), param.getName()!!, param.getType(), paramInfo.defaultValueForCall)
@@ -213,7 +213,7 @@ fun ExtractableCodeDescriptor.findDuplicates(): List<DuplicateInfo> {
.originalRange
.match(scopeElement, unifier)
.asSequence()
.filter { !(it.range.getPhysicalTextRange() intersects originalTextRange) }
.filter { !(it.range.getPhysicalTextRange().intersects(originalTextRange)) }
.mapNotNull { match ->
val controlFlow = getControlFlowIfMatched(match)
val range = with(match.range) {
@@ -179,7 +179,7 @@ fun selectNewParameterContext(
file = file,
getContainers = { elements, parent ->
val parents = parent.parents
val stopAt = (parent.parents zip parent.parents.drop(1))
val stopAt = (parent.parents.zip(parent.parents.drop(1)))
.firstOrNull { isObjectOrNonInnerClass(it.first) }
?.second
@@ -337,7 +337,7 @@ object KotlinIntroduceVariableHandler : KotlinIntroduceHandlerBase() {
private fun KtElement.getContainer(): KtElement? {
if (this is KtBlockExpression) return this
return (parentsWithSelf zip parents).firstOrNull {
return (parentsWithSelf.zip(parents)).firstOrNull {
val (place, parent) = it
when (parent) {
is KtContainerNode -> !parent.isBadContainerNode(place)
@@ -361,7 +361,7 @@ object KotlinIntroduceVariableHandler : KotlinIntroduceHandlerBase() {
private fun KtExpression.getOccurrenceContainer(): KtElement? {
var result: KtElement? = null
for ((place, parent) in parentsWithSelf zip parents) {
for ((place, parent) in parentsWithSelf.zip(parents)) {
when {
parent is KtContainerNode && place !is KtBlockExpression && !parent.isBadContainerNode(place) -> result = parent
parent is KtClassBody, parent is KtFile -> return result
@@ -301,7 +301,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
oldToNewElementsMapping[sourceFile] = newDeclaration.getContainingKtFile()
getTransaction()!!.getElementListener(oldDeclaration).elementMoved(newDeclaration)
for ((oldElement, newElement) in oldLightElements.asSequence() zip newDeclaration.toLightElements().asSequence()) {
for ((oldElement, newElement) in oldLightElements.asSequence().zip(newDeclaration.toLightElements().asSequence())) {
oldToNewElementsMapping[oldElement] = newElement
}
}
@@ -194,12 +194,12 @@ public class KotlinPsiUnifier(
if (args1.size() != args2.size()) return UNMATCHED
if (rc1.getCall().getValueArguments().size() != args1.size() || rc2.getCall().getValueArguments().size() != args2.size()) return null
return (args1.asSequence() zip args2.asSequence()).fold(MATCHED) { s, p ->
return (args1.asSequence().zip(args2.asSequence())).fold(MATCHED) { s, p ->
val (arg1, arg2) = p
s and when {
arg1 == arg2 -> MATCHED
arg1 == null || arg2 == null -> UNMATCHED
else -> (arg1.getArguments().asSequence() zip arg2.getArguments().asSequence()).fold(MATCHED) { s, p ->
else -> (arg1.getArguments().asSequence().zip(arg2.getArguments().asSequence())).fold(MATCHED) { s, p ->
s and matchArguments(p.first, p.second)
}
}
@@ -250,7 +250,7 @@ public class KotlinPsiUnifier(
val typeArgs2 = rc2.getTypeArguments().toList()
if (typeArgs1.size() != typeArgs2.size()) return UNMATCHED
for ((typeArg1, typeArg2) in (typeArgs1 zip typeArgs2)) {
for ((typeArg1, typeArg2) in (typeArgs1.zip(typeArgs2))) {
if (!matchDescriptors(typeArg1.first, typeArg2.first)) return UNMATCHED
val s = matchTypes(typeArg1.second, typeArg2.second)
@@ -354,7 +354,7 @@ public class KotlinPsiUnifier(
fun sortTypes(types: Collection<KotlinType>) = types.sortedBy { DescriptorRenderer.DEBUG_TEXT.renderType(it) }
if (types1.size() != types2.size()) return false
return (sortTypes(types1) zip sortTypes(types2)).all { matchTypes(it.first, it.second) == MATCHED }
return (sortTypes(types1).zip(sortTypes(types2))).all { matchTypes(it.first, it.second) == MATCHED }
}
private fun KtElement.shouldIgnoreResolvedCall(): Boolean {
@@ -527,7 +527,7 @@ public class KotlinPsiUnifier(
declarations2: List<T>,
matchPair: (Pair<T, T>) -> Boolean
): Boolean {
val zippedParams = declarations1 zip declarations2
val zippedParams = declarations1.zip(declarations2)
if (declarations1.size() != declarations2.size() || !zippedParams.all { matchPair(it) }) return false
zippedParams.forEach { declarationPatternsToTargets.putValue(it.first, it.second) }
@@ -777,7 +777,7 @@ public class KotlinPsiUnifier(
val patternElements = pattern.elements
if (targetElements.size() != patternElements.size()) return UNMATCHED
return (targetElements.asSequence() zip patternElements.asSequence()).fold(MATCHED) { s, p ->
return (targetElements.asSequence().zip(patternElements.asSequence())).fold(MATCHED) { s, p ->
if (s != UNMATCHED) s and doUnify(p.first, p.second) else s
}
}
@@ -60,7 +60,7 @@ class CodeBuilder(private val topElement: PsiElement?, private var docConverter:
private val imports = LinkedHashSet<FqName>()
public fun append(text: String): CodeBuilder
public infix fun append(text: String): CodeBuilder
= append(text, false)
public fun addImport(fqName: FqName) {
@@ -100,7 +100,7 @@ class CodeBuilder(private val topElement: PsiElement?, private var docConverter:
public val importsToAdd: Set<FqName>
get() = imports
public fun append(element: Element): CodeBuilder {
public infix fun append(element: Element): CodeBuilder {
if (element.isEmpty) return this // do not insert comment and spaces for empty elements to avoid multiple blank lines
if (element.prototypes == null && topElement != null) {
@@ -429,7 +429,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
}
else {
if (target is PsiClass) {
if (PrimitiveType.values() any { it.getTypeName().asString() == target.getName() }) {
if (PrimitiveType.values().any { it.getTypeName().asString() == target.getName() }) {
result = Identifier(target.getQualifiedName()!!, false)
return
}
@@ -73,7 +73,7 @@ class Modifiers(modifiers: Collection<Modifier>) : Element() {
fun Modifiers.filter(predicate: (Modifier) -> Boolean): Modifiers
= Modifiers(modifiers.filter(predicate)).assignPrototypesFrom(this)
fun CodeBuilder.appendWithSpaceAfter(modifiers: Modifiers): CodeBuilder {
infix fun CodeBuilder.appendWithSpaceAfter(modifiers: Modifiers): CodeBuilder {
if (!modifiers.isEmpty) {
this append modifiers append " "
}
@@ -117,7 +117,7 @@ internal class NativeSetterChecker : AbstractNativeIndexerChecker(PredefinedAnno
if (parameters.size() < 2) return
val secondParameterType = parameters.get(1).getType()
if (secondParameterType isSubtypeOf returnType) return
if (secondParameterType.isSubtypeOf(returnType)) return
diagnosticHolder.report(ErrorsJs.NATIVE_SETTER_WRONG_RETURN_TYPE.on(declaration))
}
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.js.inline.util.collectors.PropertyCollector
import org.jetbrains.kotlin.js.translate.expression.*
public fun collectFunctionReferencesInside(scope: JsNode): List<JsName> =
collectReferencesInside(scope) filter { it.staticRef is JsFunction }
collectReferencesInside(scope).filter { it.staticRef is JsFunction }
public fun collectReferencesInside(scope: JsNode): List<JsName> {
return with(ReferenceNameCollector()) {
@@ -29,7 +29,7 @@ public fun aliasArgumentsIfNeeded(
) {
assertTrue { arguments.size() <= parameters.size() }
for ((arg, param) in arguments zip parameters) {
for ((arg, param) in arguments.zip(parameters)) {
val paramName = param.getName()
val replacement =
if (arg.needToAlias()) {
@@ -84,7 +84,7 @@ public object KotlinJavascriptSerializationUtil {
public fun contentMapToByteArray(contentMap: Map<String, ByteArray>): ByteArray {
val contentBuilder = JsProtoBuf.Library.newBuilder()
contentMap forEach {
contentMap.forEach {
val entry = JsProtoBuf.Library.FileEntry.newBuilder().setPath(it.getKey()).setContent(ByteString.copyFrom(it.getValue())).build()
contentBuilder.addEntry(entry)
}
@@ -255,9 +255,9 @@ object DynamicInvokeAndBracketAccessCallCase : FunctionCallCase() {
object DynamicOperatorCallCase : FunctionCallCase() {
fun canApply(callInfo: FunctionCallInfo): Boolean =
callInfo.callableDescriptor.isDynamic() &&
callInfo.resolvedCall.getCall().getCallElement() let {
callInfo.resolvedCall.getCall().getCallElement().let {
it is KtOperationExpression &&
PsiUtils.getOperationToken(it) let { (it == KtTokens.NOT_IN || OperatorTable.hasCorrespondingOperator(it)) }
PsiUtils.getOperationToken(it).let { (it == KtTokens.NOT_IN || OperatorTable.hasCorrespondingOperator(it)) }
}
override fun FunctionCallInfo.dispatchReceiver(): JsExpression {
@@ -58,7 +58,7 @@ public abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
}
private fun getFakeFiles(path: String): Collection<String> {
return FileUtil.findFilesByMask(Pattern.compile("^Fake.*\\.kt$"), File(path.replace(getTestName(true), ""))) map { relativePath(it) }
return FileUtil.findFilesByMask(Pattern.compile("^Fake.*\\.kt$"), File(path.replace(getTestName(true), ""))).map { relativePath(it) }
}
private fun needsInvocationTest(path: String): Boolean {