From a7b88e9485d8969d17b877394a14b86460277f22 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 26 Nov 2014 18:50:04 +0300 Subject: [PATCH] Make CharSequence.length a function instead of property And String.length as well. This is done for JVM interoperability: java.lang.CharSequence is an open class and has a function 'length()' which should be implemented in subclasses somehow. A minor unexpected effect of this is that String.length() is now a compile-time constant (it wasn't such as a property because properties are not supported in compile-time constant evaluation) #KT-3571 Fixed --- .../codegen/intrinsics/IntrinsicMethods.java | 7 ---- .../jet/codegen/intrinsics/StringLength.kt | 38 ------------------- .../lang/evaluate/OperationsMapGenerated.kt | 1 + compiler/testData/builtin-classes.txt | 6 +-- .../expressions/propertySafeCall.instructions | 22 +++++------ .../cfg/expressions/propertySafeCall.kt | 6 +-- .../cfg/expressions/propertySafeCall.values | 14 +++---- .../testData/codegen/box/classes/kt940.kt | 4 +- .../codegen/box/controlStructures/doWhile.kt | 2 +- .../codegen/box/controlStructures/kt3273.kt | 2 +- .../propertyMetadataShouldBeCached.kt | 2 +- .../tailRecursion/realStringEscape.kt | 3 +- .../tailRecursion/realStringRepeat.kt | 4 +- .../box/intrinsics/stringFromCollection.kt | 2 +- .../codegen/box/primitiveTypes/kt684.kt | 4 +- .../testData/codegen/box/properties/kt3556.kt | 2 +- .../testData/codegen/box/safeCall/kt247.kt | 2 +- .../testData/codegen/box/strings/kt3571.kt | 6 +++ .../strings/multilineStringsWithTemplates.kt | 2 +- compiler/testData/codegen/box/super/kt4982.kt | 4 +- .../sam/adapters/severalSamParameters.kt | 4 +- .../sam/adapters/typeParameterOfClass.kt | 4 +- .../sam/adapters/typeParameterOfMethod.kt | 6 +-- .../sam/adapters/typeParameterOfOuterClass.kt | 2 +- .../boxInline/complex/closureChain.1.kt | 5 +-- .../callSite/exceptionTableSplit.2.kt | 4 +- .../callSite/exceptionTableSplitNoReturn.2.kt | 4 +- .../exceptionTable/tryCatchInFinally.2.kt | 4 +- .../PropertyReference.A.kt | 2 +- .../tests/MergePackagesWithJava.txt | 8 ++-- .../tests/MultilineStringTemplates.kt | 2 +- .../diagnostics/tests/QualifiedExpressions.kt | 14 +++---- .../tests/QualifiedExpressions.txt | 2 +- .../cast/neverSucceeds/MappedSubtypes.txt | 2 +- .../definiteReturnInWhen.kt | 4 +- .../local/LocalClassInMemberOfLocalClass.kt | 5 +-- .../dataFlow/local/LocalClassProperty.kt | 6 +-- .../tests/dataFlow/local/LocalObject.kt | 4 +- .../tests/dataFlow/local/NestedLocalClass.kt | 3 +- .../kt4332WhenBranches.kt | 6 +-- .../tests/inference/regressions/kt2407.kt | 2 +- .../tests/inference/regressions/kt2484.kt | 20 +++++----- .../tests/inference/regressions/kt943.kt | 4 +- .../diagnostics/tests/inline/labeled.kt | 4 +- ...ertypeArgumentsNullability-SpecialTypes.kt | 3 +- compiler/testData/diagnostics/tests/kt310.kt | 4 +- compiler/testData/diagnostics/tests/kt310.txt | 2 +- .../diagnostics/tests/labels/kt4247.kt | 4 +- .../tests/nullabilityAndSmartCasts/kt244.kt | 12 +++--- .../tests/platformTypes/dereference.kt | 4 +- .../diagnostics/tests/platformTypes/elvis.kt | 4 +- .../platformTypes/nullableTypeArgument.kt | 2 +- .../tests/platformTypes/safeCall.kt | 4 +- .../tests/regressions/DoubleDefine.kt | 3 +- .../diagnostics/tests/regressions/Jet121.kt | 2 +- .../diagnostics/tests/regressions/kt549.kt | 2 +- .../diagnostics/tests/regressions/kt580.kt | 4 +- .../nestedCalls/kt5971NestedSafeCall.kt | 4 +- .../diagnostics/tests/scopes/kt939.kt | 9 ++--- .../diagnostics/tests/scopes/kt955.txt | 8 ++-- .../smartCasts/combineWithNoSelectorInfo.kt | 2 +- .../diagnostics/tests/smartCasts/elvisRHS.kt | 2 +- .../diagnostics/tests/smartCasts/kt5455.kt | 2 +- .../testData/evaluate/constant/strings.kt | 3 ++ .../BlackBoxCodegenTestGenerated.java | 6 +++ core/builtins/native/kotlin/CharSequence.kt | 2 +- core/builtins/native/kotlin/String.kt | 4 +- .../KTopLevelExtensionPropertyImpl.kt | 8 ++-- .../src/kotlin/reflect/jvm/internal/util.kt | 2 +- idea/testData/checker/QualifiedExpressions.kt | 16 ++++---- .../checker/regression/DoubleDefine.kt | 2 +- idea/testData/checker/regression/Jet121.kt | 17 +++++---- .../blockHasMoreThanOneStatement.kt | 2 +- .../blockUsesDifferentVar.kt | 2 +- .../conditionComparesNullWithNull.kt | 2 +- .../conditionInvalidBinaryExp.kt | 2 +- .../conditionNotBinaryExpr.kt | 2 +- .../doesNotinlineValueIfUsedMoreThanOnce.kt | 2 +- ...sNotinlineValueIfUsedMoreThanOnce.kt.after | 2 +- .../doesNotinlineValueOutsideOfScope.kt | 2 +- .../doesNotinlineValueOutsideOfScope.kt.after | 2 +- .../ifThenToSafeAccess/emptyCondition.kt | 2 +- .../ifThenToSafeAccess/emptyElseBlock.kt | 2 +- .../emptyElseBlock.kt.after | 2 +- .../ifThenToSafeAccess/emptyThenBlock.kt | 2 +- .../emptyThenBlock.kt.after | 2 +- .../ifAndElseBothInBlocks.kt | 2 +- .../ifAndElseBothInBlocks.kt.after | 2 +- .../ifAndElseNotInBlocks.kt | 2 +- .../ifAndElseNotInBlocks.kt.after | 2 +- .../ifThenToSafeAccess/ifAsExpression.kt | 2 +- .../ifAsExpression.kt.after | 2 +- .../ifThenToSafeAccess/lhsEqualsNull.kt | 2 +- .../ifThenToSafeAccess/lhsEqualsNull.kt.after | 2 +- .../ifThenToSafeAccess/lhsNotEqualsNull.kt | 2 +- .../lhsNotEqualsNull.kt.after | 2 +- .../ifThenToSafeAccess/noCondition.kt | 2 +- .../ifThenToSafeAccess/noElseBlock.kt | 2 +- .../ifThenToSafeAccess/noElseBlock.kt.after | 2 +- .../ifThenToSafeAccess/noNullInCondition.kt | 2 +- .../ifThenToSafeAccess/noNullInCondition2.kt | 2 +- .../ifThenToSafeAccess/noThenBlock.kt | 2 +- .../ifThenToSafeAccess/noThenBlock.kt.after | 2 +- .../notApplicableForFunction.kt | 2 +- .../notApplicableForLocalVar.kt | 2 +- .../otherBlockHasMoreThanOneStatement.kt | 2 +- .../ifThenToSafeAccess/rhsEqualsNull.kt | 2 +- .../ifThenToSafeAccess/rhsEqualsNull.kt.after | 2 +- .../ifThenToSafeAccess/rhsNotEqualsNull.kt | 2 +- .../rhsNotEqualsNull.kt.after | 2 +- .../ifThenToSafeAccess/thenAndElseNotNull.kt | 4 +- .../safeAccessToIfThen/binaryExpressionLhs.kt | 2 +- .../binaryExpressionLhs.kt.after | 2 +- .../safeAccessToIfThen/callExpression.kt | 2 - .../callExpression.kt.after | 2 - .../callExpressionParens.kt | 2 +- .../callExpressionParens.kt.after | 2 +- .../customGetterAsReceiver.kt | 2 +- .../customGetterAsReceiver.kt.after | 2 +- .../safeAccessToIfThen/localValAsReceiver.kt | 2 +- .../localValAsReceiver.kt.after | 2 +- .../safeAccessToIfThen/localValLhs.kt | 2 +- .../safeAccessToIfThen/localValLhs.kt.after | 2 +- .../safeAccessToIfThen/localVarLhs.kt | 2 +- .../safeAccessToIfThen/localVarLhs.kt.after | 2 +- .../resultAssignedToLocalVal.kt | 2 +- .../resultAssignedToLocalVal.kt.after | 2 +- .../safeAccessAsFunctionArgument.kt | 2 +- .../safeAccessAsFunctionArgument.kt.after | 2 +- .../simpleNameExpression.kt | 2 +- .../simpleNameExpression.kt.after | 2 +- .../simpleNameExpressionInParens.kt | 2 +- .../simpleNameExpressionInParens.kt.after | 2 +- .../safeAccessToIfThen/topLevelVal.kt | 2 +- .../safeAccessToIfThen/topLevelVal.kt.after | 2 +- .../topLevelValCustomGetter.kt | 2 +- .../topLevelValCustomGetter.kt.after | 2 +- .../safeAccessToIfThen/topLevelVar.kt | 2 +- .../safeAccessToIfThen/topLevelVar.kt.after | 2 +- .../topLevelVarCustomGetter.kt | 2 +- .../topLevelVarCustomGetter.kt.after | 2 +- .../safeAccessToIfThen/usedAsFunctionRhs.kt | 2 +- .../usedAsFunctionRhs.kt.after | 2 +- .../usedAsResultOfCheckedIf.kt | 2 +- .../usedAsResultOfCheckedIf.kt.after | 2 +- .../safeAccessToIfThen/usedAsReturnValue.kt | 2 +- .../usedAsReturnValue.kt.after | 2 +- .../usedInUncheckedIfExpression.kt | 2 +- .../usedInUncheckedIfExpression.kt.after | 2 +- .../doubleNegation.kt | 2 +- .../doubleNegation.kt.after | 2 +- .../necessaryBrackets1.kt | 2 +- .../propertyAccess.kt | 4 +- .../afterUnnecessaryNonNullAssertion3.kt | 2 +- .../beforeUnnecessaryNonNullAssertion3.kt | 2 +- js/js.libraries/src/core/string.kt | 3 -- .../factories/StringOperationFIF.java | 2 +- libraries/stdlib/src/kotlin/text/Strings.kt | 3 ++ .../stdlib/src/kotlin/text/StringsJVM.kt | 9 ----- 159 files changed, 265 insertions(+), 313 deletions(-) delete mode 100644 compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/StringLength.kt create mode 100644 compiler/testData/codegen/box/strings/kt3571.kt diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java index 14dec6bc802..65d1d4f7051 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java @@ -130,9 +130,6 @@ public class IntrinsicMethods { declareIntrinsicFunction(typeName + "Iterator", "next", 0, ITERATOR_NEXT); } - declareIntrinsicProperty("CharSequence", "length", new StringLength()); - declareIntrinsicProperty("String", "length", new StringLength()); - declareArrayMethods(); } @@ -168,10 +165,6 @@ public class IntrinsicMethods { } } - private void declareIntrinsicProperty(@NotNull String className, @NotNull String methodName, @NotNull IntrinsicMethod implementation) { - declareIntrinsicFunction(className, methodName, -1, implementation); - } - private void declareIntrinsicFunction( @NotNull String className, @NotNull String methodName, diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/StringLength.kt b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/StringLength.kt deleted file mode 100644 index 4c389fd5783..00000000000 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/StringLength.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2010-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.codegen.intrinsics - -import com.intellij.psi.PsiElement -import org.jetbrains.org.objectweb.asm.Type -import org.jetbrains.jet.codegen.ExpressionCodegen -import org.jetbrains.jet.codegen.StackValue -import org.jetbrains.jet.lang.psi.JetExpression - -public class StringLength : LazyIntrinsicMethod() { - override fun generateImpl( - codegen: ExpressionCodegen, - returnType: Type, - element: PsiElement?, - arguments: List, - receiver: StackValue - ): StackValue { - return StackValue.operation(Type.INT_TYPE) { - receiver.put(receiver.type, it) - it.invokeinterface("java/lang/CharSequence", "length", "()I") - } - } -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/OperationsMapGenerated.kt b/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/OperationsMapGenerated.kt index d61ecf68d2f..34b93508e49 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/OperationsMapGenerated.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/OperationsMapGenerated.kt @@ -100,6 +100,7 @@ private val unaryOperations: HashMap, Pair a.toLong() }, emptyUnaryFun), unaryOperation(SHORT, "toShort", { a -> a.toShort() }, emptyUnaryFun), unaryOperation(SHORT, "toString", { a -> a.toString() }, emptyUnaryFun), + unaryOperation(STRING, "length", { a -> a.length() }, emptyUnaryFun), unaryOperation(STRING, "toString", { a -> a.toString() }, emptyUnaryFun) ) diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index 8ee10fa0ff2..713118325db 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -294,9 +294,8 @@ public final class CharRange : kotlin.Range, kotlin.Progression(): kotlin.Int public abstract fun get(/*0*/ index: kotlin.Int): kotlin.Char + public abstract fun length(): kotlin.Int } public trait Cloneable { @@ -1429,10 +1428,9 @@ public final class ShortRange : kotlin.Range, kotlin.Progression, kotlin.CharSequence { /*primary*/ public constructor String() - public open override /*1*/ val length: kotlin.Int - public open override /*1*/ fun (): kotlin.Int public open override /*1*/ fun compareTo(/*0*/ other: kotlin.String): kotlin.Int public open override /*1*/ fun get(/*0*/ index: kotlin.Int): kotlin.Char + public open override /*1*/ fun length(): kotlin.Int public final fun plus(/*0*/ other: kotlin.Any?): kotlin.String } diff --git a/compiler/testData/cfg/expressions/propertySafeCall.instructions b/compiler/testData/cfg/expressions/propertySafeCall.instructions index 56a9f456e9a..4f75eab602e 100644 --- a/compiler/testData/cfg/expressions/propertySafeCall.instructions +++ b/compiler/testData/cfg/expressions/propertySafeCall.instructions @@ -1,21 +1,21 @@ == test == -fun test(s: String?) { - s?.length +fun test(s: IntProgression?) { + s?.start } --------------------- L0: 1 - v(s: String?) - magic[FAKE_INITIALIZER](s: String?) -> + v(s: IntProgression?) + magic[FAKE_INITIALIZER](s: IntProgression?) -> w(s|) - 2 mark({ s?.length }) - mark(s?.length) + 2 mark({ s?.start }) + mark(s?.start) r(s) -> - r(length|) -> + r(start|) -> L1: - 1 NEXT:[] + 1 NEXT:[] error: - PREV:[] + PREV:[] sink: - PREV:[, ] -===================== \ No newline at end of file + PREV:[, ] +===================== diff --git a/compiler/testData/cfg/expressions/propertySafeCall.kt b/compiler/testData/cfg/expressions/propertySafeCall.kt index 0db80f8f5a6..48423ce9389 100644 --- a/compiler/testData/cfg/expressions/propertySafeCall.kt +++ b/compiler/testData/cfg/expressions/propertySafeCall.kt @@ -1,3 +1,3 @@ - fun test(s: String?) { - s?.length -} \ No newline at end of file +fun test(s: IntProgression?) { + s?.start +} diff --git a/compiler/testData/cfg/expressions/propertySafeCall.values b/compiler/testData/cfg/expressions/propertySafeCall.values index 672540824d3..38cac8833b7 100644 --- a/compiler/testData/cfg/expressions/propertySafeCall.values +++ b/compiler/testData/cfg/expressions/propertySafeCall.values @@ -1,11 +1,11 @@ == test == -fun test(s: String?) { - s?.length +fun test(s: IntProgression?) { + s?.start } --------------------- - : {<: String?} NEW: magic[FAKE_INITIALIZER](s: String?) -> -s : {<: CharSequence?} NEW: r(s) -> -length : * NEW: r(length|) -> -s?.length : * COPY -{ s?.length } : * COPY + : {<: IntProgression?} NEW: magic[FAKE_INITIALIZER](s: IntProgression?) -> +s : {<: Progression?} NEW: r(s) -> +start : * NEW: r(start|) -> +s?.start : * COPY +{ s?.start } : * COPY ===================== diff --git a/compiler/testData/codegen/box/classes/kt940.kt b/compiler/testData/codegen/box/classes/kt940.kt index a81d971ffba..ebefd2ccaba 100644 --- a/compiler/testData/codegen/box/classes/kt940.kt +++ b/compiler/testData/codegen/box/classes/kt940.kt @@ -4,8 +4,8 @@ fun box() : String { val w = object : Comparator { override fun compare(o1 : String?, o2 : String?) : Int { - val l1 : Int = o1?.length ?: 0 - val l2 = o2?.length ?: 0 + val l1 : Int = o1?.length() ?: 0 + val l2 = o2?.length() ?: 0 return l1 - l2 } diff --git a/compiler/testData/codegen/box/controlStructures/doWhile.kt b/compiler/testData/codegen/box/controlStructures/doWhile.kt index f9b776c736c..8e04ad4fea2 100644 --- a/compiler/testData/codegen/box/controlStructures/doWhile.kt +++ b/compiler/testData/codegen/box/controlStructures/doWhile.kt @@ -8,7 +8,7 @@ fun box(): String { if (y != 5) return "Fail 2 $y" var z = "" - do { z += z.length } while (z.length < 5) + do { z += z.length() } while (z.length() < 5) if (z != "01234") return "Fail 3 $z" return "OK" diff --git a/compiler/testData/codegen/box/controlStructures/kt3273.kt b/compiler/testData/codegen/box/controlStructures/kt3273.kt index 187dc50ecf8..9754ca8f5b8 100644 --- a/compiler/testData/codegen/box/controlStructures/kt3273.kt +++ b/compiler/testData/codegen/box/controlStructures/kt3273.kt @@ -12,7 +12,7 @@ public fun testCoalesce() { else -> "Hello world" } - printlnMock(value.length) + printlnMock(value.length()) } fun box(): String { diff --git a/compiler/testData/codegen/box/delegatedProperty/propertyMetadataShouldBeCached.kt b/compiler/testData/codegen/box/delegatedProperty/propertyMetadataShouldBeCached.kt index 8af9886fee9..c00bf16c9ff 100644 --- a/compiler/testData/codegen/box/delegatedProperty/propertyMetadataShouldBeCached.kt +++ b/compiler/testData/codegen/box/delegatedProperty/propertyMetadataShouldBeCached.kt @@ -34,7 +34,7 @@ object StringHandler { fun box(): String { val a = A() a.foo = 42 - a.foo = a.foo + baz.length + a.foo = a.foo + baz.length() a.foo = 239 A.bar = baz + a.foo baz + A.bar diff --git a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringEscape.kt b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringEscape.kt index 28ad0abc393..dc6b192088b 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringEscape.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringEscape.kt @@ -6,11 +6,10 @@ fun escapeChar(c : Char) : String? = when (c) { } tailRecursive fun String.escape(i : Int = 0, result : StringBuilder = StringBuilder()) : String = - if (i == length) result.toString() + if (i == length()) result.toString() else escape(i + 1, result.append(escapeChar(get(i)))) fun box() : String { "test me not \\".escape() return "OK" } - diff --git a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringRepeat.kt b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringRepeat.kt index d05e69d7f13..238624e022c 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringRepeat.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/realStringRepeat.kt @@ -4,5 +4,5 @@ tailRecursive fun String.repeat(num : Int, acc : StringBuilder = StringBuilder() fun box() : String { val s = "a".repeat(10000) - return if (s.length == 10000) "OK" else "FAIL: ${s.length}" -} \ No newline at end of file + return if (s.length() == 10000) "OK" else "FAIL: ${s.length()}" +} diff --git a/compiler/testData/codegen/box/intrinsics/stringFromCollection.kt b/compiler/testData/codegen/box/intrinsics/stringFromCollection.kt index daacb2d0131..0abb5e5a043 100644 --- a/compiler/testData/codegen/box/intrinsics/stringFromCollection.kt +++ b/compiler/testData/codegen/box/intrinsics/stringFromCollection.kt @@ -2,6 +2,6 @@ fun box(): String { val list = java.util.ArrayList() list.add("0") list[0][0] - list[0].length + list[0].length() return "OK" } diff --git a/compiler/testData/codegen/box/primitiveTypes/kt684.kt b/compiler/testData/codegen/box/primitiveTypes/kt684.kt index 90a792730b5..adad3994920 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt684.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt684.kt @@ -6,7 +6,7 @@ fun escapeChar(c : Char) : String? = when (c) { } fun String.escape(i : Int = 0, result : String = "") : String = - if (i == length) result + if (i == length()) result else escape(i + 1, result + escapeChar(get(i))) fun box() : String { @@ -19,7 +19,7 @@ fun box() : String { System.out?.println("}"); System.out?.println(); System.out?.println("fun String.escape(i : Int = 0, result : String = \"\") : String ="); - System.out?.println(" if (i == length) result"); + System.out?.println(" if (i == length()) result"); System.out?.println(" else escape(i + 1, result + escapeChar(this.get(i)))"); System.out?.println(); System.out?.println("fun main(args : Array) {"); diff --git a/compiler/testData/codegen/box/properties/kt3556.kt b/compiler/testData/codegen/box/properties/kt3556.kt index adce0368131..6d480831de5 100644 --- a/compiler/testData/codegen/box/properties/kt3556.kt +++ b/compiler/testData/codegen/box/properties/kt3556.kt @@ -3,7 +3,7 @@ class Test { private val b : String get() = a fun outer() : Int { - return b.length + return b.length() } } diff --git a/compiler/testData/codegen/box/safeCall/kt247.kt b/compiler/testData/codegen/box/safeCall/kt247.kt index 55a7fbe74f8..ccf66fbaf76 100644 --- a/compiler/testData/codegen/box/safeCall/kt247.kt +++ b/compiler/testData/codegen/box/safeCall/kt247.kt @@ -1,7 +1,7 @@ fun t1() : Boolean { val s1 : String? = "sff" val s2 : String? = null - return s1?.length == 3 && s2?.length == null + return s1?.length() == 3 && s2?.length() == null } fun t2() : Boolean { diff --git a/compiler/testData/codegen/box/strings/kt3571.kt b/compiler/testData/codegen/box/strings/kt3571.kt new file mode 100644 index 00000000000..28346ef232f --- /dev/null +++ b/compiler/testData/codegen/box/strings/kt3571.kt @@ -0,0 +1,6 @@ +class Thing(delegate: CharSequence) : CharSequence by delegate + +fun box(): String { + val l = Thing("hello there").length() + return if (l == 11) "OK" else "Fail $l" +} diff --git a/compiler/testData/codegen/box/strings/multilineStringsWithTemplates.kt b/compiler/testData/codegen/box/strings/multilineStringsWithTemplates.kt index 38e661755cd..bc9f1daa504 100644 --- a/compiler/testData/codegen/box/strings/multilineStringsWithTemplates.kt +++ b/compiler/testData/codegen/box/strings/multilineStringsWithTemplates.kt @@ -14,7 +14,7 @@ fun box() : String { val test5 = """ - ${s.length} + ${s.length()} """ if (test5 != "\n 3\n") return "Fail 5: $test5" diff --git a/compiler/testData/codegen/box/super/kt4982.kt b/compiler/testData/codegen/box/super/kt4982.kt index d8abff3d5a9..ee67309c429 100644 --- a/compiler/testData/codegen/box/super/kt4982.kt +++ b/compiler/testData/codegen/box/super/kt4982.kt @@ -13,9 +13,9 @@ fun box(): String { override fun condition(): Boolean { result = "OK" - return result.length == 2 + return result.length() == 2 } } return result; -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/boxAgainstJava/sam/adapters/severalSamParameters.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/severalSamParameters.kt index cf8de53fd7f..72a84a91bf3 100644 --- a/compiler/testData/codegen/boxAgainstJava/sam/adapters/severalSamParameters.kt +++ b/compiler/testData/codegen/boxAgainstJava/sam/adapters/severalSamParameters.kt @@ -1,6 +1,6 @@ fun box(): String { var v = "FAIL" - val max = JavaClass.findMaxAndInvokeCallback({ a, b -> a.length - b.length }, "foo", "kotlin", { v = "OK" }) + val max = JavaClass.findMaxAndInvokeCallback({ a, b -> a.length() - b.length() }, "foo", "kotlin", { v = "OK" }) if (max != "kotlin") return "Wrong max: $max" return v -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfClass.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfClass.kt index 04b17d6395c..264c185505d 100644 --- a/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfClass.kt +++ b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfClass.kt @@ -1,6 +1,6 @@ fun box(): String { val wc = WeirdComparator() - val result = wc.max({ a, b -> a.length - b.length }, "java", "kotlin") + val result = wc.max({ a, b -> a.length() - b.length() }, "java", "kotlin") if (result != "kotlin") return "Wrong: $result" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfMethod.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfMethod.kt index fe0efd5053f..da39df3e650 100644 --- a/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfMethod.kt +++ b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfMethod.kt @@ -1,9 +1,9 @@ fun box(): String { - val result = WeirdComparator.max({ a, b -> a.length - b.length }, "java", "kotlin") + val result = WeirdComparator.max({ a, b -> a.length() - b.length() }, "java", "kotlin") if (result != "kotlin") return "Wrong: $result" - val result2 = WeirdComparator.max2({ a, b -> a.length - b.length }, "java", "kotlin") + val result2 = WeirdComparator.max2({ a, b -> a.length() - b.length() }, "java", "kotlin") if (result2 != "kotlin") return "Wrong: $result" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfOuterClass.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfOuterClass.kt index 4788b8b669a..780e8262ad2 100644 --- a/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfOuterClass.kt +++ b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfOuterClass.kt @@ -1,6 +1,6 @@ fun box(): String { val wc = WeirdComparator().createInner()!! - val result = wc.max({ a, b -> a.length - b.length }, "java", "kotlin") + val result = wc.max({ a, b -> a.length() - b.length() }, "java", "kotlin") if (result != "kotlin") return "Wrong: $result" return "OK" } diff --git a/compiler/testData/codegen/boxInline/complex/closureChain.1.kt b/compiler/testData/codegen/boxInline/complex/closureChain.1.kt index 2602d89f0c2..b65222a0bd6 100644 --- a/compiler/testData/codegen/boxInline/complex/closureChain.1.kt +++ b/compiler/testData/codegen/boxInline/complex/closureChain.1.kt @@ -1,11 +1,10 @@ - fun test1(): Int { val inlineX = Inline() - return inlineX.foo({(z: Int) -> "" + z}, 25, {String.() -> this.length}) + return inlineX.foo({(z: Int) -> "" + z}, 25, {String.() -> this.length()}) } fun box(): String { if (test1() != 2) return "test1: ${test1()}" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplit.2.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplit.2.kt index c1b24ca2490..57462caf683 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplit.2.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplit.2.kt @@ -3,7 +3,7 @@ package test public class Holder(var value: String = "") { public fun plusAssign(s: String?) { - if (value.length != 0) { + if (value.length() != 0) { value += " -> " } value += s @@ -30,4 +30,4 @@ public inline fun doCallWithException(h: Holder, block: ()-> R) : R { h += "inline fun finally" throw RuntimeException("fail"); } -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplitNoReturn.2.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplitNoReturn.2.kt index 79c3e6ff2de..d6ba6580229 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplitNoReturn.2.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/callSite/exceptionTableSplitNoReturn.2.kt @@ -3,7 +3,7 @@ package test public class Holder(var value: String = "") { public fun plusAssign(s: String?) { - if (value.length != 0) { + if (value.length() != 0) { value += " -> " } value += s @@ -30,4 +30,4 @@ public inline fun doCallWithException(h: Holder, block: ()-> R) { h += "inline fun finally" throw RuntimeException("fail"); } -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/tryCatchInFinally.2.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/tryCatchInFinally.2.kt index c401339df38..57e72fe54b6 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/tryCatchInFinally.2.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/exceptionTable/tryCatchInFinally.2.kt @@ -3,7 +3,7 @@ package test public class Holder(var value: String = "") { public fun plusAssign(s: String?) { - if (value.length != 0) { + if (value.length() != 0) { value += " -> " } value += s @@ -33,4 +33,4 @@ public inline fun doCall(block: ()-> String, finallyBlock: ()-> String, } } return res -} \ No newline at end of file +} diff --git a/compiler/testData/compileKotlinAgainstKotlin/PropertyReference.A.kt b/compiler/testData/compileKotlinAgainstKotlin/PropertyReference.A.kt index ea68a0dea53..f1131339069 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/PropertyReference.A.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/PropertyReference.A.kt @@ -3,4 +3,4 @@ package a public var topLevel: Int = 42 public val String.extension: Long - get() = length.toLong() + get() = length().toLong() diff --git a/compiler/testData/diagnostics/tests/MergePackagesWithJava.txt b/compiler/testData/diagnostics/tests/MergePackagesWithJava.txt index 5ff8b9c9dae..6f48297e8f5 100644 --- a/compiler/testData/diagnostics/tests/MergePackagesWithJava.txt +++ b/compiler/testData/diagnostics/tests/MergePackagesWithJava.txt @@ -4502,7 +4502,7 @@ package java { public open fun insert(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.String!): java.lang.AbstractStringBuilder! public open fun lastIndexOf(/*0*/ p0: kotlin.String!): kotlin.Int public open fun lastIndexOf(/*0*/ p0: kotlin.String!, /*1*/ p1: kotlin.Int): kotlin.Int - public open fun length(): kotlin.Int + public open override /*1*/ fun length(): kotlin.Int public open fun offsetByCodePoints(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Int public open fun replace(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int, /*2*/ p2: kotlin.String!): java.lang.AbstractStringBuilder! public open fun reverse(): java.lang.AbstractStringBuilder! @@ -8004,7 +8004,7 @@ package java { public open fun lastIndexOf(/*0*/ p0: kotlin.String!): kotlin.Int public open fun lastIndexOf(/*0*/ p0: kotlin.String!, /*1*/ p1: kotlin.Int): kotlin.Int private open fun lastIndexOfSupplementary(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Int - public open fun length(): kotlin.Int + public open override /*1*/ fun length(): kotlin.Int public open fun matches(/*0*/ p0: kotlin.String!): kotlin.Boolean public open fun offsetByCodePoints(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Int public open fun regionMatches(/*0*/ p0: kotlin.Boolean, /*1*/ p1: kotlin.Int, /*2*/ p2: kotlin.String!, /*3*/ p3: kotlin.Int, /*4*/ p4: kotlin.Int): kotlin.Boolean @@ -8113,7 +8113,7 @@ package java { public open override /*1*/ fun insert(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.String!): java.lang.StringBuffer! public open override /*1*/ fun lastIndexOf(/*0*/ p0: kotlin.String!): kotlin.Int public open override /*1*/ fun lastIndexOf(/*0*/ p0: kotlin.String!, /*1*/ p1: kotlin.Int): kotlin.Int - public open override /*1*/ fun length(): kotlin.Int + public open override /*2*/ fun length(): kotlin.Int public open override /*1*/ fun offsetByCodePoints(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Int private open fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit public open override /*1*/ fun replace(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int, /*2*/ p2: kotlin.String!): java.lang.StringBuffer! @@ -8184,7 +8184,7 @@ package java { public open override /*1*/ fun insert(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.String!): java.lang.StringBuilder! public open override /*1*/ fun lastIndexOf(/*0*/ p0: kotlin.String!): kotlin.Int public open override /*1*/ fun lastIndexOf(/*0*/ p0: kotlin.String!, /*1*/ p1: kotlin.Int): kotlin.Int - public open override /*1*/ /*fake_override*/ fun length(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun length(): kotlin.Int public open override /*1*/ /*fake_override*/ fun offsetByCodePoints(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Int private open fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit public open override /*1*/ fun replace(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int, /*2*/ p2: kotlin.String!): java.lang.StringBuilder! diff --git a/compiler/testData/diagnostics/tests/MultilineStringTemplates.kt b/compiler/testData/diagnostics/tests/MultilineStringTemplates.kt index 715007c246c..3ec9a7931c7 100644 --- a/compiler/testData/diagnostics/tests/MultilineStringTemplates.kt +++ b/compiler/testData/diagnostics/tests/MultilineStringTemplates.kt @@ -14,7 +14,7 @@ fun box() : String { val test5 = """ - ${s.length} + ${s.length()} """ if (test5 != "\n 3\n") return "Fail 5: $test5" diff --git a/compiler/testData/diagnostics/tests/QualifiedExpressions.kt b/compiler/testData/diagnostics/tests/QualifiedExpressions.kt index 4760d6ac3a0..ad1da7d0a35 100644 --- a/compiler/testData/diagnostics/tests/QualifiedExpressions.kt +++ b/compiler/testData/diagnostics/tests/QualifiedExpressions.kt @@ -1,12 +1,12 @@ package qualified_expressions -fun test(s: String?) { - val a: Int = s?.length - val b: Int? = s?.length - val c: Int = s?.length ?: -11 - val d: Int = s?.length ?: "empty" - val e: String = s?.length ?: "empty" - val f: Int = s?.length ?: b ?: 1 +fun test(s: IntRange?) { + val a: Int = s?.start + val b: Int? = s?.start + val c: Int = s?.start ?: -11 + val d: Int = s?.start ?: "empty" + val e: String = s?.start ?: "empty" + val f: Int = s?.end ?: b ?: 1 val g: Boolean? = e.startsWith("s")//?.length } diff --git a/compiler/testData/diagnostics/tests/QualifiedExpressions.txt b/compiler/testData/diagnostics/tests/QualifiedExpressions.txt index 86672dd4462..4f8b95ecc72 100644 --- a/compiler/testData/diagnostics/tests/QualifiedExpressions.txt +++ b/compiler/testData/diagnostics/tests/QualifiedExpressions.txt @@ -1,6 +1,6 @@ package package qualified_expressions { - internal fun test(/*0*/ s: kotlin.String?): kotlin.Unit + internal fun test(/*0*/ s: kotlin.IntRange?): kotlin.Unit internal fun kotlin.String.startsWith(/*0*/ s: kotlin.String): kotlin.Boolean } diff --git a/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.txt b/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.txt index 4f539ad4bc5..9372c67b568 100644 --- a/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.txt +++ b/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.txt @@ -14,9 +14,9 @@ internal final class JSub : java.lang.CharSequence { internal final class Sub : kotlin.CharSequence { public constructor Sub() - public abstract override /*1*/ /*fake_override*/ val length: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public abstract override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.Char public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract override /*1*/ /*fake_override*/ fun length(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt index 31099398381..e5487348b98 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt @@ -1,6 +1,6 @@ fun illegalWhenBlock(a: Any): Int { when(a) { is Int -> return a - is String -> return a.length + is String -> return a.length() } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt index 6e06fec26eb..6470bf9c71b 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt @@ -6,11 +6,10 @@ fun test(x: Any) { if (y !is String) return class Local { { - x.length - y.length + x.length() + y.length() } } } } } - diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt index 96357b94178..2644c4672ef 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt @@ -2,11 +2,11 @@ fun test(x: Any?) { if (x !is String) return class C { - val v = x.length + val v = x.length() val vGet: Int - get() = x.length + get() = x.length() val s: String = x } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt index 3d50c52d888..fa1dfa048b4 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt @@ -1,9 +1,9 @@ fun foo(x: Any?) { if (x is String) { object : Base(x) { - fun bar() = x.length + fun bar() = x.length() } } } -open class Base(s: String) \ No newline at end of file +open class Base(s: String) diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt b/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt index 0fd0dcf5896..114cbaf8f32 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt @@ -4,9 +4,8 @@ fun test(x: Any) { class LocalOuter { inner class Local { { - x.length + x.length() } } } } - diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt4332WhenBranches.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt4332WhenBranches.kt index a91e0222ac0..356300a8ab5 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt4332WhenBranches.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/kt4332WhenBranches.kt @@ -3,7 +3,7 @@ fun testWhen(t: String?, x: String?): Int { return when { t == null -> 0 - x == null -> t.length // Wrong error report here. t can be inferred as not-null. (And it actually does if you replace when with if/else if) - else -> (t + x).length + x == null -> t.length() // Wrong error report here. t can be inferred as not-null. (And it actually does if you replace when with if/else if) + else -> (t + x).length() } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt index eda5bf86014..cf1e05c1aa3 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2407.kt @@ -3,7 +3,7 @@ package n import java.util.* fun test() { - val foo = arrayList("").map { it -> it.length }.fold(0, { x, y -> Math.max(x, y) }) + val foo = arrayList("").map { it -> it.length() }.fold(0, { x, y -> Math.max(x, y) }) foo : Int foo : String } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt index 4a779371524..7afa0c2eec9 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2484.kt @@ -8,15 +8,15 @@ fun Array.forEach(operation: (T) -> Unit) : Unit { for (element in this) fun bar(operation: (String) -> Unit) = operation("") fun main(args: Array) { - args.forEach { (a : String) : Unit -> a.length } // Type mismatch: (String) -> Unit required, (String) -> Int found - args.forEach { (a) : Unit -> a.length } // Type mismatch: (String) -> Unit required, (String) -> Int found - args.forEach { (a : String) -> a.length } // Type mismatch: (String) -> Unit required, (String) -> Int found - args.forEach { a -> a.length } // Type mismatch: (String) -> Unit required, (String) -> Int found - args.forEach { it.length } // This works! + args.forEach { (a : String) : Unit -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found + args.forEach { (a) : Unit -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found + args.forEach { (a : String) -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found + args.forEach { a -> a.length() } // Type mismatch: (String) -> Unit required, (String) -> Int found + args.forEach { it.length() } // This works! - bar { (a: String) : Unit -> a.length } - bar { (a) : Unit -> a.length } - bar { (a: String) -> a.length } - bar { a -> a.length } - bar { it.length } + bar { (a: String) : Unit -> a.length() } + bar { (a) : Unit -> a.length() } + bar { (a: String) -> a.length() } + bar { a -> a.length() } + bar { it.length() } } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt index 2df5de1d2f4..30f27a96271 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt943.kt @@ -7,8 +7,8 @@ import java.util.* fun foo(lines: List) { val w = max(lines, comparator {o1, o2 -> - val l1 : Int = o1.length // Types of o1 and o2 are ERROR - val l2 = o2.length + val l1 : Int = o1.length() // Types of o1 and o2 are ERROR + val l2 = o2.length() l1 - l2 }).sure() w : String diff --git a/compiler/testData/diagnostics/tests/inline/labeled.kt b/compiler/testData/diagnostics/tests/inline/labeled.kt index 7e20c8e1747..0f0847b27e2 100644 --- a/compiler/testData/diagnostics/tests/inline/labeled.kt +++ b/compiler/testData/diagnostics/tests/inline/labeled.kt @@ -2,11 +2,11 @@ inline fun foo(bar1: (String.() -> Int) -> Int, bar2: (()->Int) -> Int) { bar1 @label { - this@label.length + this@label.length() } bar1 { - this.length + this.length() } //unmute after KT-4247 fix //bar1 { diff --git a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-SpecialTypes.kt b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-SpecialTypes.kt index db61d0ee80a..55a63591ff5 100644 --- a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-SpecialTypes.kt +++ b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-SpecialTypes.kt @@ -15,7 +15,6 @@ public class Y extends X { // FILE: test.kt fun main() { - Y().foo().length + Y().foo().length() Y().bar(null) } - diff --git a/compiler/testData/diagnostics/tests/kt310.kt b/compiler/testData/diagnostics/tests/kt310.kt index 7f7228bcb63..57c2f43f97a 100644 --- a/compiler/testData/diagnostics/tests/kt310.kt +++ b/compiler/testData/diagnostics/tests/kt310.kt @@ -1,3 +1,3 @@ -fun f(c: String): Int { - return c.length() +fun f(c: LongRange): Int { + return c.start() } diff --git a/compiler/testData/diagnostics/tests/kt310.txt b/compiler/testData/diagnostics/tests/kt310.txt index feaa0c7ce41..9949eda0fbe 100644 --- a/compiler/testData/diagnostics/tests/kt310.txt +++ b/compiler/testData/diagnostics/tests/kt310.txt @@ -1,3 +1,3 @@ package -internal fun f(/*0*/ c: kotlin.String): kotlin.Int +internal fun f(/*0*/ c: kotlin.LongRange): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/labels/kt4247.kt b/compiler/testData/diagnostics/tests/labels/kt4247.kt index 4160394e1f0..96dca2c2bfd 100644 --- a/compiler/testData/diagnostics/tests/labels/kt4247.kt +++ b/compiler/testData/diagnostics/tests/labels/kt4247.kt @@ -2,10 +2,10 @@ fun foo(bar1: (String.() -> Int) -> Int) { bar1 { - this.length + this.length() } bar1 { - this@bar1.length + this@bar1.length() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt index d6a9f0c0503..528d88899ce 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt244.kt @@ -5,18 +5,18 @@ package kt244 fun f(s: String?) { if (s != null) { - s.length //ok - var i = s.length //error: Only safe calls are allowed on a nullable receiver - System.out.println(s.length) //error + s.length() //ok + var i = s.length() //error: Only safe calls are allowed on a nullable receiver + System.out.println(s.length()) //error } } // more tests class A(a: String?) { - val b = if (a != null) a.length else 1 + val b = if (a != null) a.length() else 1 { if (a != null) { - val c = a.length + val c = a.length() } } @@ -24,7 +24,7 @@ class A(a: String?) { { if (a is String) { - i = a.length + i = a.length() } else { i = 3 diff --git a/compiler/testData/diagnostics/tests/platformTypes/dereference.kt b/compiler/testData/diagnostics/tests/platformTypes/dereference.kt index b2d0826da40..6240acdb6e5 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/dereference.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/dereference.kt @@ -19,8 +19,8 @@ fun test(j: J) { j.j()!!.j() val ann = j.foo() - ann!!.length - ann.length + ann!!.length() + ann.length() val a = j.foo() a!!.j() diff --git a/compiler/testData/diagnostics/tests/platformTypes/elvis.kt b/compiler/testData/diagnostics/tests/platformTypes/elvis.kt index 6507d737ae9..c3facb9e32b 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/elvis.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/elvis.kt @@ -12,5 +12,5 @@ public class J { import p.* fun test(j: J) { - j.s()?.length ?: "" -} \ No newline at end of file + j.s()?.length() ?: "" +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullableTypeArgument.kt b/compiler/testData/diagnostics/tests/platformTypes/nullableTypeArgument.kt index 268c905ad05..4ffd831a9ed 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullableTypeArgument.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullableTypeArgument.kt @@ -4,6 +4,6 @@ fun foo() { val list = ArrayList() for (s in list) { - s.length + s.length() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/safeCall.kt b/compiler/testData/diagnostics/tests/platformTypes/safeCall.kt index 2c67f98cc28..6fc9a05a8d5 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/safeCall.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/safeCall.kt @@ -11,5 +11,5 @@ public class J { import p.* fun test(j: J) { - j.s()?.length.checkType { it : _ } -} \ No newline at end of file + j.s()?.length().checkType { it : _ } +} diff --git a/compiler/testData/diagnostics/tests/regressions/DoubleDefine.kt b/compiler/testData/diagnostics/tests/regressions/DoubleDefine.kt index e6299c6f135..db7afd30edd 100644 --- a/compiler/testData/diagnostics/tests/regressions/DoubleDefine.kt +++ b/compiler/testData/diagnostics/tests/regressions/DoubleDefine.kt @@ -1,4 +1,3 @@ - import java.util.* import java.io.* @@ -10,7 +9,7 @@ fun takeFirst(expr: StringBuilder): Char { } fun evaluateArg(expr: CharSequence, numbers: ArrayList): Int { - if (expr.length == 0) throw Exception("Syntax error: Character expected"); + if (expr.length() == 0) throw Exception("Syntax error: Character expected"); val c = takeFirst(expr) if (c >= '0' && c <= '9') { val n = c - '0' diff --git a/compiler/testData/diagnostics/tests/regressions/Jet121.kt b/compiler/testData/diagnostics/tests/regressions/Jet121.kt index 6a8ab166aee..804e3c5121e 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet121.kt +++ b/compiler/testData/diagnostics/tests/regressions/Jet121.kt @@ -3,7 +3,7 @@ package jet121 fun box() : String { val answer = apply("OK") { String.() : Int -> get(0) - length + length() } return if (answer == 2) "OK" else "FAIL" diff --git a/compiler/testData/diagnostics/tests/regressions/kt549.kt b/compiler/testData/diagnostics/tests/regressions/kt549.kt index bc69d91b48d..e50b6e39dea 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt549.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt549.kt @@ -11,7 +11,7 @@ package demo } fun main(args : Array) { - for (a in filter(args, {it.length > 1})) { + for (a in filter(args, {it.length() > 1})) { System.out.println("Hello, ${a}!") } } diff --git a/compiler/testData/diagnostics/tests/regressions/kt580.kt b/compiler/testData/diagnostics/tests/regressions/kt580.kt index 460aa8cc956..5512d5604f0 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt580.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt580.kt @@ -11,9 +11,9 @@ fun main() { val diffs = ArrayList() for (i in vals.indices) { for (j in i..vals.lastIndex()) // Type inference failed - diffs.add(vals[i].length - vals[j].length) + diffs.add(vals[i].length() - vals[j].length()) for (j in i..vals.lastIndex) // Type inference failed - diffs.add(vals[i].length - vals[j].length) + diffs.add(vals[i].length() - vals[j].length()) } } diff --git a/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt5971NestedSafeCall.kt b/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt5971NestedSafeCall.kt index 23bb5f3362d..3fdd642668b 100644 --- a/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt5971NestedSafeCall.kt +++ b/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt5971NestedSafeCall.kt @@ -5,5 +5,5 @@ fun foo(i: Int) {} fun test(s: String?) { - foo(s?.length) -} \ No newline at end of file + foo(s?.length()) +} diff --git a/compiler/testData/diagnostics/tests/scopes/kt939.kt b/compiler/testData/diagnostics/tests/scopes/kt939.kt index 5fbec35e5da..e2e8773b1be 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt939.kt +++ b/compiler/testData/diagnostics/tests/scopes/kt939.kt @@ -1,19 +1,18 @@ package kt939 - //KT-939 CommonSupertypes erases scopes associated to types fun compare(o1 : String?, o2 : String?) : Int { - val l1 = o1?.length ?: 0 - val l2 = o2?.length ?: 0 + val l1 = o1?.length() ?: 0 + val l2 = o2?.length() ?: 0 return l1 - l2 // '-' is unresolved, because the type of l1 is Int with an empty member scope } //KT-1117 Unresolved reference to multiply sign fun test() { - (System.getProperty("path.separator")?.length ?: 4) * 55 + 5 + (System.getProperty("path.separator")?.length() ?: 4) * 55 + 5 - val x = System.getProperty("path.separator")?.length ?: 4 + val x = System.getProperty("path.separator")?.length() ?: 4 x * 55 + 5 } diff --git a/compiler/testData/diagnostics/tests/scopes/kt955.txt b/compiler/testData/diagnostics/tests/scopes/kt955.txt index 983f108bde8..262b54fb624 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt955.txt +++ b/compiler/testData/diagnostics/tests/scopes/kt955.txt @@ -4507,7 +4507,7 @@ package java { public open fun insert(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.String!): java.lang.AbstractStringBuilder! public open fun lastIndexOf(/*0*/ p0: kotlin.String!): kotlin.Int public open fun lastIndexOf(/*0*/ p0: kotlin.String!, /*1*/ p1: kotlin.Int): kotlin.Int - public open fun length(): kotlin.Int + public open override /*1*/ fun length(): kotlin.Int public open fun offsetByCodePoints(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Int public open fun replace(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int, /*2*/ p2: kotlin.String!): java.lang.AbstractStringBuilder! public open fun reverse(): java.lang.AbstractStringBuilder! @@ -8009,7 +8009,7 @@ package java { public open fun lastIndexOf(/*0*/ p0: kotlin.String!): kotlin.Int public open fun lastIndexOf(/*0*/ p0: kotlin.String!, /*1*/ p1: kotlin.Int): kotlin.Int private open fun lastIndexOfSupplementary(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Int - public open fun length(): kotlin.Int + public open override /*1*/ fun length(): kotlin.Int public open fun matches(/*0*/ p0: kotlin.String!): kotlin.Boolean public open fun offsetByCodePoints(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Int public open fun regionMatches(/*0*/ p0: kotlin.Boolean, /*1*/ p1: kotlin.Int, /*2*/ p2: kotlin.String!, /*3*/ p3: kotlin.Int, /*4*/ p4: kotlin.Int): kotlin.Boolean @@ -8118,7 +8118,7 @@ package java { public open override /*1*/ fun insert(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.String!): java.lang.StringBuffer! public open override /*1*/ fun lastIndexOf(/*0*/ p0: kotlin.String!): kotlin.Int public open override /*1*/ fun lastIndexOf(/*0*/ p0: kotlin.String!, /*1*/ p1: kotlin.Int): kotlin.Int - public open override /*1*/ fun length(): kotlin.Int + public open override /*2*/ fun length(): kotlin.Int public open override /*1*/ fun offsetByCodePoints(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Int private open fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit public open override /*1*/ fun replace(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int, /*2*/ p2: kotlin.String!): java.lang.StringBuffer! @@ -8189,7 +8189,7 @@ package java { public open override /*1*/ fun insert(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.String!): java.lang.StringBuilder! public open override /*1*/ fun lastIndexOf(/*0*/ p0: kotlin.String!): kotlin.Int public open override /*1*/ fun lastIndexOf(/*0*/ p0: kotlin.String!, /*1*/ p1: kotlin.Int): kotlin.Int - public open override /*1*/ /*fake_override*/ fun length(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun length(): kotlin.Int public open override /*1*/ /*fake_override*/ fun offsetByCodePoints(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Int private open fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit public open override /*1*/ fun replace(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int, /*2*/ p2: kotlin.String!): java.lang.StringBuilder! diff --git a/compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt b/compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt index 705b772b9d2..fdb1e785cb5 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt @@ -3,7 +3,7 @@ package foo fun dispatch(request: Request) { val url = request.getRequestURI() as String - if (request.getMethod()?.length != 0) { + if (request.getMethod()?.length() != 0) { } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/elvisRHS.kt b/compiler/testData/diagnostics/tests/smartCasts/elvisRHS.kt index f886778d875..8a061d3f413 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/elvisRHS.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/elvisRHS.kt @@ -5,6 +5,6 @@ fun foo(p1: String?, p2: String?) { if (p2 != null) { val v = p1 ?: p2 - val size = v.length + val size = v.length() } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt b/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt index 173016bff7a..449ee5e84c4 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt @@ -1,7 +1,7 @@ //KT-5455 Need warning about redundant type cast fun foo(o: Any): Int { if (o is String) { - return (o as String).length + return (o as String).length() } return -1 } diff --git a/compiler/testData/evaluate/constant/strings.kt b/compiler/testData/evaluate/constant/strings.kt index c3bd1b26ea7..86c706e82b0 100644 --- a/compiler/testData/evaluate/constant/strings.kt +++ b/compiler/testData/evaluate/constant/strings.kt @@ -33,3 +33,6 @@ val prop9 = "a" + "b" // val prop10: \"abb\" val prop10 = prop9 + "b" + +// val prop11: 6 +val prop11 = "kotlin".length() diff --git a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java index ea765e46934..2c24cd7f25f 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -6286,6 +6286,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("kt3571.kt") + public void testKt3571() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/strings/kt3571.kt"); + doTest(fileName); + } + @TestMetadata("kt3652.kt") public void testKt3652() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/strings/kt3652.kt"); diff --git a/core/builtins/native/kotlin/CharSequence.kt b/core/builtins/native/kotlin/CharSequence.kt index dc6e6e85b51..d61536668f7 100644 --- a/core/builtins/native/kotlin/CharSequence.kt +++ b/core/builtins/native/kotlin/CharSequence.kt @@ -19,5 +19,5 @@ package kotlin public trait CharSequence { public fun get(index: Int): Char - public val length: Int + public fun length(): Int } diff --git a/core/builtins/native/kotlin/String.kt b/core/builtins/native/kotlin/String.kt index fa6d54e21ca..2d77ae1f685 100644 --- a/core/builtins/native/kotlin/String.kt +++ b/core/builtins/native/kotlin/String.kt @@ -20,6 +20,8 @@ public class String : Comparable, CharSequence { public fun plus(other: Any?): String public override fun compareTo(other: String): Int + public override fun get(index: Int): Char - public override val length: Int + + public override fun length(): Int } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTopLevelExtensionPropertyImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTopLevelExtensionPropertyImpl.kt index 01e1b284f26..f364616cc93 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTopLevelExtensionPropertyImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTopLevelExtensionPropertyImpl.kt @@ -95,8 +95,8 @@ private fun mapJavaClassToKotlin(name: String): String { } } if (name[0] == '[') { - val element = (name as java.lang.String).substring(1) - return when (element[0]) { + val element = (name as java.lang.String).substring(1) as java.lang.String + return when (element.charAt(0)) { 'Z' -> "kotlin.BooleanArray" 'C' -> "kotlin.CharArray" 'B' -> "kotlin.ByteArray" @@ -105,8 +105,8 @@ private fun mapJavaClassToKotlin(name: String): String { 'F' -> "kotlin.FloatArray" 'J' -> "kotlin.LongArray" 'D' -> "kotlin.DoubleArray" - 'L' -> "kotlin.Array<${mapJavaClassToKotlin((element as java.lang.String).substring(1, element.length() - 1))}>" - else -> "kotlin.Array<${mapJavaClassToKotlin(element)}>" + 'L' -> "kotlin.Array<${mapJavaClassToKotlin(element.substring(1, element.length() - 1))}>" + else -> "kotlin.Array<${mapJavaClassToKotlin(element as kotlin.String)}>" } } return name diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/util.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/util.kt index b92d03a0e6c..ed4d8d5590d 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/util.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/util.kt @@ -24,7 +24,7 @@ suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") private fun String.capitalizeWithJavaBeanConvention(): String { // The code is a bit crooked because otherwise there are overload resolution ambiguities caused by the fact // that we compile it with the built-ins both in source and as a compiled library - val l = length + val l = length() if (l > 1 && Character.isUpperCase(get(1))) return this val first = get(0) this as java.lang.String diff --git a/idea/testData/checker/QualifiedExpressions.kt b/idea/testData/checker/QualifiedExpressions.kt index d35193fc0ac..cb9d14aa719 100644 --- a/idea/testData/checker/QualifiedExpressions.kt +++ b/idea/testData/checker/QualifiedExpressions.kt @@ -1,13 +1,13 @@ package qualified_expressions -fun test(s: String?) { - val a: Int = s?.length - val b: Int? = s?.length - val c: Int = s?.length ?: -11 - val d: Int = s?.length ?: "empty" - val e: String = s?.length ?: "empty" - val f: Int = s?.length ?: b ?: 1 +fun test(s: IntRange?) { + val a: Int = s?.start + val b: Int? = s?.start + val c: Int = s?.start ?: -11 + val d: Int = s?.start ?: "empty" + val e: String = s?.start ?: "empty" + val f: Int = s?.end ?: b ?: 1 val g: Boolean? = e.startsWith("s")//?.length } -fun String.startsWith(s: String): Boolean = true \ No newline at end of file +fun String.startsWith(s: String): Boolean = true diff --git a/idea/testData/checker/regression/DoubleDefine.kt b/idea/testData/checker/regression/DoubleDefine.kt index 8baa2ef4107..f4582304ae7 100644 --- a/idea/testData/checker/regression/DoubleDefine.kt +++ b/idea/testData/checker/regression/DoubleDefine.kt @@ -9,7 +9,7 @@ fun takeFirst(expr: StringBuilder): Char { } fun evaluateArg(expr: CharSequence, numbers: ArrayList): Int { - if (expr.length == 0) throw Exception("Syntax error: Character expected"); + if (expr.length() == 0) throw Exception("Syntax error: Character expected"); val c = takeFirst(expr) if (c >= '0' && c <= '9') { val n = c - '0' diff --git a/idea/testData/checker/regression/Jet121.kt b/idea/testData/checker/regression/Jet121.kt index bba231a4845..95183845189 100644 --- a/idea/testData/checker/regression/Jet121.kt +++ b/idea/testData/checker/regression/Jet121.kt @@ -1,13 +1,14 @@ package jet121 - fun box() : String { - val answer = apply("OK") { String.() : Int -> - get(0) - length + +fun box(): String { + val answer = apply("OK") { String.(): Int -> + get(0) + length() } return if (answer == 2) "OK" else "FAIL" - } +} - fun apply(arg:String, f : String.() -> Int) : Int { - return arg.f() - } \ No newline at end of file +fun apply(arg: String, f: String.() -> Int): Int { + return arg.f() +} diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/blockHasMoreThanOneStatement.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/blockHasMoreThanOneStatement.kt index e46f095b494..e1140a067a2 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/blockHasMoreThanOneStatement.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/blockHasMoreThanOneStatement.kt @@ -5,7 +5,7 @@ fun main(args: Array) { val foo: String? = "abc" if (foo != null) { doSomething ("Hello") - foo.length + foo.length() } else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/blockUsesDifferentVar.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/blockUsesDifferentVar.kt index 33259df89a8..16c3129b7fc 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/blockUsesDifferentVar.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/blockUsesDifferentVar.kt @@ -3,7 +3,7 @@ fun main(args: Array) { var foo: String? = "foo" var bar: String? = "bar" if (foo != null) { - bar?.length + bar?.length() } else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/conditionComparesNullWithNull.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/conditionComparesNullWithNull.kt index dfb67445d55..38c29b095d5 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/conditionComparesNullWithNull.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/conditionComparesNullWithNull.kt @@ -2,7 +2,7 @@ fun main(args: Array) { val foo = "foo" if (null == null) { - foo.length + foo.length() } else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/conditionInvalidBinaryExp.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/conditionInvalidBinaryExp.kt index f6432dc4382..13b6b740395 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/conditionInvalidBinaryExp.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/conditionInvalidBinaryExp.kt @@ -4,7 +4,7 @@ fun T.compareTo(a: T): Int = 0 fun main(args: Array) { val foo = "foo" if (foo > null) { - foo.length + foo.length() } else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/conditionNotBinaryExpr.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/conditionNotBinaryExpr.kt index 681e65feeee..dca0b65b5a7 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/conditionNotBinaryExpr.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/conditionNotBinaryExpr.kt @@ -4,7 +4,7 @@ fun String?.times(a: Int): Boolean = a == 0 fun main(args: Array) { val foo: String = "foo" if (foo * 10) { - foo.length + foo.length() } else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueIfUsedMoreThanOnce.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueIfUsedMoreThanOnce.kt index 728bc651f0d..ed772c7354e 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueIfUsedMoreThanOnce.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueIfUsedMoreThanOnce.kt @@ -8,7 +8,7 @@ fun main(args: Array) { val foo = maybeFoo() doSomething(foo) if (foo != null) { - foo.length + foo.length() } else { null diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueIfUsedMoreThanOnce.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueIfUsedMoreThanOnce.kt.after index 1333ac3b987..2065935924f 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueIfUsedMoreThanOnce.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueIfUsedMoreThanOnce.kt.after @@ -7,5 +7,5 @@ fun doSomething(a: T) {} fun main(args: Array) { val foo = maybeFoo() doSomething(foo) - foo?.length + foo?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueOutsideOfScope.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueOutsideOfScope.kt index e78849e13b2..ad692c4df57 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueOutsideOfScope.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueOutsideOfScope.kt @@ -6,7 +6,7 @@ val x = maybeFoo() fun main(args: Array) { if (x != null) { - x.length + x.length() } else { null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueOutsideOfScope.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueOutsideOfScope.kt.after index 336763c63b8..6665cb79390 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueOutsideOfScope.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/doesNotinlineValueOutsideOfScope.kt.after @@ -5,5 +5,5 @@ fun maybeFoo(): String? { val x = maybeFoo() fun main(args: Array) { - x?.length + x?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/emptyCondition.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/emptyCondition.kt index 410f549fae4..878ed352205 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/emptyCondition.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/emptyCondition.kt @@ -2,7 +2,7 @@ fun main(args: Array) { val foo = "foo" if () { - foo.length + foo.length() } else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/emptyElseBlock.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/emptyElseBlock.kt index 1175234b604..f4ce36dade9 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/emptyElseBlock.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/emptyElseBlock.kt @@ -5,7 +5,7 @@ fun maybeFoo(): String? { fun main(args: Array) { val foo = maybeFoo() if (foo != null) { - foo.length + foo.length() } else { diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/emptyElseBlock.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/emptyElseBlock.kt.after index cb42a95887b..005ab996cad 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/emptyElseBlock.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/emptyElseBlock.kt.after @@ -3,5 +3,5 @@ fun maybeFoo(): String? { } fun main(args: Array) { - maybeFoo()?.length + maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/emptyThenBlock.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/emptyThenBlock.kt index 6898c3e73b6..783bdd89eb3 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/emptyThenBlock.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/emptyThenBlock.kt @@ -7,6 +7,6 @@ fun main(args: Array) { if (foo == null) { } else { - foo.length + foo.length() } } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/emptyThenBlock.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/emptyThenBlock.kt.after index cb42a95887b..005ab996cad 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/emptyThenBlock.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/emptyThenBlock.kt.after @@ -3,5 +3,5 @@ fun maybeFoo(): String? { } fun main(args: Array) { - maybeFoo()?.length + maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseBothInBlocks.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseBothInBlocks.kt index 0fa6af278bc..380ad91c1a9 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseBothInBlocks.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseBothInBlocks.kt @@ -5,7 +5,7 @@ fun maybeFoo(): String? { fun main(args: Array) { val foo = maybeFoo() if (foo != null) { - foo.length + foo.length() } else { null diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseBothInBlocks.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseBothInBlocks.kt.after index cb42a95887b..005ab996cad 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseBothInBlocks.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseBothInBlocks.kt.after @@ -3,5 +3,5 @@ fun maybeFoo(): String? { } fun main(args: Array) { - maybeFoo()?.length + maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseNotInBlocks.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseNotInBlocks.kt index 1704670fb88..477185371da 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseNotInBlocks.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseNotInBlocks.kt @@ -5,7 +5,7 @@ fun maybeFoo(): String? { fun main(args: Array) { val foo = maybeFoo() if (foo != null) - foo.length + foo.length() else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseNotInBlocks.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseNotInBlocks.kt.after index cb42a95887b..005ab996cad 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseNotInBlocks.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAndElseNotInBlocks.kt.after @@ -3,5 +3,5 @@ fun maybeFoo(): String? { } fun main(args: Array) { - maybeFoo()?.length + maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAsExpression.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAsExpression.kt index 0c1862c362a..17506cf365e 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAsExpression.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAsExpression.kt @@ -8,6 +8,6 @@ fun main(args: Array) { null } else { - foo.length + foo.length() } } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAsExpression.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAsExpression.kt.after index 4bbf14d33eb..81d4655758b 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/ifAsExpression.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/ifAsExpression.kt.after @@ -3,5 +3,5 @@ fun maybeFoo(): String? { } fun main(args: Array) { - val x = maybeFoo()?.length + val x = maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/lhsEqualsNull.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/lhsEqualsNull.kt index 6f3bbb05e81..9e40449ed9d 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/lhsEqualsNull.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/lhsEqualsNull.kt @@ -7,5 +7,5 @@ fun main(args: Array) { if (foo == null) null else - foo.length + foo.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/lhsEqualsNull.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/lhsEqualsNull.kt.after index cb42a95887b..005ab996cad 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/lhsEqualsNull.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/lhsEqualsNull.kt.after @@ -3,5 +3,5 @@ fun maybeFoo(): String? { } fun main(args: Array) { - maybeFoo()?.length + maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/lhsNotEqualsNull.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/lhsNotEqualsNull.kt index 1704670fb88..477185371da 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/lhsNotEqualsNull.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/lhsNotEqualsNull.kt @@ -5,7 +5,7 @@ fun maybeFoo(): String? { fun main(args: Array) { val foo = maybeFoo() if (foo != null) - foo.length + foo.length() else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/lhsNotEqualsNull.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/lhsNotEqualsNull.kt.after index cb42a95887b..005ab996cad 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/lhsNotEqualsNull.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/lhsNotEqualsNull.kt.after @@ -3,5 +3,5 @@ fun maybeFoo(): String? { } fun main(args: Array) { - maybeFoo()?.length + maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/noCondition.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/noCondition.kt index 4a4e380e71e..ab438d560f9 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/noCondition.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/noCondition.kt @@ -3,6 +3,6 @@ fun main(args: Array) { val foo: String? = "foo" if { - foo.length + foo.length() } else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/noElseBlock.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/noElseBlock.kt index fe5c1033f6d..540f6c9c2ad 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/noElseBlock.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/noElseBlock.kt @@ -5,6 +5,6 @@ fun maybeFoo(): String? { fun main(args: Array) { val foo = maybeFoo() if (foo != null) { - foo.length + foo.length() } } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/noElseBlock.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/noElseBlock.kt.after index cb42a95887b..005ab996cad 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/noElseBlock.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/noElseBlock.kt.after @@ -3,5 +3,5 @@ fun maybeFoo(): String? { } fun main(args: Array) { - maybeFoo()?.length + maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/noNullInCondition.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/noNullInCondition.kt index 12cf26a8d30..034d969048b 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/noNullInCondition.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/noNullInCondition.kt @@ -3,7 +3,7 @@ fun main(args: Array) { val foo: String? = "foo" val bar: String? = null if (foo == bar) { - foo?.length + foo?.length() } else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/noNullInCondition2.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/noNullInCondition2.kt index 248646563b1..a679c325061 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/noNullInCondition2.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/noNullInCondition2.kt @@ -3,7 +3,7 @@ fun main(args: Array) { val foo: String? = "foo" val bar: String? = null if (foo == bar) { - bar?.length + bar?.length() } else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/noThenBlock.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/noThenBlock.kt index d7bc397240b..35dd651a2d1 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/noThenBlock.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/noThenBlock.kt @@ -5,6 +5,6 @@ fun maybeFoo(): String? { fun main(args: Array) { val foo = maybeFoo() if (foo == null) else { - foo.length + foo.length() } } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/noThenBlock.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/noThenBlock.kt.after index cb42a95887b..005ab996cad 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/noThenBlock.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/noThenBlock.kt.after @@ -3,5 +3,5 @@ fun maybeFoo(): String? { } fun main(args: Array) { - maybeFoo()?.length + maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/notApplicableForFunction.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/notApplicableForFunction.kt index cdd13643c7a..ae1e3e1ce87 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/notApplicableForFunction.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/notApplicableForFunction.kt @@ -7,5 +7,5 @@ fun main(args: Array) { if (maybeFoo() == null) null else - maybeFoo()?.length + maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/notApplicableForLocalVar.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/notApplicableForLocalVar.kt index 5c49d8494d4..93916d260df 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/notApplicableForLocalVar.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/notApplicableForLocalVar.kt @@ -8,5 +8,5 @@ fun main(args: Array) { if (foo == null) null else - foo?.length + foo?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/otherBlockHasMoreThanOneStatement.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/otherBlockHasMoreThanOneStatement.kt index 355382ecf92..1911aec56ba 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/otherBlockHasMoreThanOneStatement.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/otherBlockHasMoreThanOneStatement.kt @@ -4,7 +4,7 @@ fun doSomething(a: T) {} fun main(args: Array) { val foo: String? = "abc" if (foo != null) { - foo.length + foo.length() } else { doSomething("Hi") diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/rhsEqualsNull.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/rhsEqualsNull.kt index 775eda6f9fd..741c7b8201b 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/rhsEqualsNull.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/rhsEqualsNull.kt @@ -7,5 +7,5 @@ fun main(args: Array) { if (null == foo) null else - foo.length + foo.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/rhsEqualsNull.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/rhsEqualsNull.kt.after index cb42a95887b..005ab996cad 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/rhsEqualsNull.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/rhsEqualsNull.kt.after @@ -3,5 +3,5 @@ fun maybeFoo(): String? { } fun main(args: Array) { - maybeFoo()?.length + maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/rhsNotEqualsNull.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/rhsNotEqualsNull.kt index 1b01ec846fb..446ee02b391 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/rhsNotEqualsNull.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/rhsNotEqualsNull.kt @@ -5,7 +5,7 @@ fun maybeFoo(): String? { fun main(args: Array) { val foo = maybeFoo() if (null != foo) - foo.length + foo.length() else null } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/rhsNotEqualsNull.kt.after b/idea/testData/intentions/branched/ifThenToSafeAccess/rhsNotEqualsNull.kt.after index cb42a95887b..005ab996cad 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/rhsNotEqualsNull.kt.after +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/rhsNotEqualsNull.kt.after @@ -3,5 +3,5 @@ fun maybeFoo(): String? { } fun main(args: Array) { - maybeFoo()?.length + maybeFoo()?.length() } diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/thenAndElseNotNull.kt b/idea/testData/intentions/branched/ifThenToSafeAccess/thenAndElseNotNull.kt index 5fc8dcf9896..0df98e87828 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/thenAndElseNotNull.kt +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/thenAndElseNotNull.kt @@ -3,9 +3,9 @@ fun main(args: Array) { val foo: String? = "foo" if (foo == null) { - foo.length + foo.length() } else { - foo.length + foo.length() } } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/binaryExpressionLhs.kt b/idea/testData/intentions/branched/safeAccessToIfThen/binaryExpressionLhs.kt index 50461c5b885..d43059eb084 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/binaryExpressionLhs.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/binaryExpressionLhs.kt @@ -1,5 +1,5 @@ fun main(args: Array) { val x: String? = null val y: String? = "Hello" - val z = (x ?: y)?.length + val z = (x ?: y)?.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/binaryExpressionLhs.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/binaryExpressionLhs.kt.after index 122322899c0..918fb5c14ac 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/binaryExpressionLhs.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/binaryExpressionLhs.kt.after @@ -2,5 +2,5 @@ fun main(args: Array) { val x: String? = null val y: String? = "Hello" val s = x ?: y - val z = if (s != null) s.length else null + val z = if (s != null) s.length() else null } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/callExpression.kt b/idea/testData/intentions/branched/safeAccessToIfThen/callExpression.kt index 3aee513b5e1..e6d6a17999d 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/callExpression.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/callExpression.kt @@ -1,5 +1,3 @@ -fun String.length() = length - fun foo(): String? = "foo" fun main(args: Array) { foo()?.length() diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/callExpression.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/callExpression.kt.after index 7772f3ea49c..36fd675f675 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/callExpression.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/callExpression.kt.after @@ -1,5 +1,3 @@ -fun String.length() = length - fun foo(): String? = "foo" fun main(args: Array) { val s = foo() diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/callExpressionParens.kt b/idea/testData/intentions/branched/safeAccessToIfThen/callExpressionParens.kt index c139cb26f16..d15f4d385e6 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/callExpressionParens.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/callExpressionParens.kt @@ -1,4 +1,4 @@ fun foo(): String? = "foo" fun main(args: Array) { - (foo())?.length + (foo())?.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/callExpressionParens.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/callExpressionParens.kt.after index 0a3ef666033..36fd675f675 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/callExpressionParens.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/callExpressionParens.kt.after @@ -1,5 +1,5 @@ fun foo(): String? = "foo" fun main(args: Array) { val s = foo() - if (s != null) s.length + if (s != null) s.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/customGetterAsReceiver.kt b/idea/testData/intentions/branched/safeAccessToIfThen/customGetterAsReceiver.kt index 9bfdab5a00e..5b20d44d0a7 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/customGetterAsReceiver.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/customGetterAsReceiver.kt @@ -9,5 +9,5 @@ class Foo { fun main(args: Array) { val a = Foo() - doSomething(a.b?.length) + doSomething(a.b?.length()) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/customGetterAsReceiver.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/customGetterAsReceiver.kt.after index 6bc9e2da30d..12650d0674f 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/customGetterAsReceiver.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/customGetterAsReceiver.kt.after @@ -10,5 +10,5 @@ class Foo { fun main(args: Array) { val a = Foo() val s = a.b - doSomething(if (s != null) s.length else null) + doSomething(if (s != null) s.length() else null) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/localValAsReceiver.kt b/idea/testData/intentions/branched/safeAccessToIfThen/localValAsReceiver.kt index eeba12cf5a0..0358241c05a 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/localValAsReceiver.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/localValAsReceiver.kt @@ -1,4 +1,4 @@ fun main(args: Array) { val x: String? = "abc" - x?.length + x?.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/localValAsReceiver.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/localValAsReceiver.kt.after index 837ffd1f033..e27bd6269ca 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/localValAsReceiver.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/localValAsReceiver.kt.after @@ -1,4 +1,4 @@ fun main(args: Array) { val x: String? = "abc" - if (x != null) x.length + if (x != null) x.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/localValLhs.kt b/idea/testData/intentions/branched/safeAccessToIfThen/localValLhs.kt index 854d092e4b9..bac1a9b0cca 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/localValLhs.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/localValLhs.kt @@ -2,5 +2,5 @@ fun doSomething(a: T) {} fun main(args: Array) { val a: String? = "A" - doSomething(a?.length) + doSomething(a?.length()) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/localValLhs.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/localValLhs.kt.after index f51978ee6a4..bc4f3b6d894 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/localValLhs.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/localValLhs.kt.after @@ -2,5 +2,5 @@ fun doSomething(a: T) {} fun main(args: Array) { val a: String? = "A" - doSomething(if (a != null) a.length else null) + doSomething(if (a != null) a.length() else null) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/localVarLhs.kt b/idea/testData/intentions/branched/safeAccessToIfThen/localVarLhs.kt index e3d5106731e..8ba64a77bd7 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/localVarLhs.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/localVarLhs.kt @@ -2,6 +2,6 @@ fun doSomething(a: T) {} fun main(args: Array) { var a: String? = "A" - doSomething(a?.length) + doSomething(a?.length()) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/localVarLhs.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/localVarLhs.kt.after index fc41c7b64c6..09919a2bb05 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/localVarLhs.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/localVarLhs.kt.after @@ -3,6 +3,6 @@ fun doSomething(a: T) {} fun main(args: Array) { var a: String? = "A" val s = a - doSomething(if (s != null) s.length else null) + doSomething(if (s != null) s.length() else null) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/resultAssignedToLocalVal.kt b/idea/testData/intentions/branched/safeAccessToIfThen/resultAssignedToLocalVal.kt index 5e04bb3e59e..7326b1d277a 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/resultAssignedToLocalVal.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/resultAssignedToLocalVal.kt @@ -1,4 +1,4 @@ fun main(args: Array) { val x: String? = "abc" - val y = x?.length + val y = x?.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/resultAssignedToLocalVal.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/resultAssignedToLocalVal.kt.after index 328d3df4a49..3fe4c6eabbd 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/resultAssignedToLocalVal.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/resultAssignedToLocalVal.kt.after @@ -1,4 +1,4 @@ fun main(args: Array) { val x: String? = "abc" - val y = if (x != null) x.length else null + val y = if (x != null) x.length() else null } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/safeAccessAsFunctionArgument.kt b/idea/testData/intentions/branched/safeAccessToIfThen/safeAccessAsFunctionArgument.kt index 895100a9970..3528d419492 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/safeAccessAsFunctionArgument.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/safeAccessAsFunctionArgument.kt @@ -3,5 +3,5 @@ fun f(s: Int?) { fun main(args: Array) { val x: String? = "foo" - f(x?.length) + f(x?.length()) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/safeAccessAsFunctionArgument.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/safeAccessAsFunctionArgument.kt.after index 79623722267..d304090ca46 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/safeAccessAsFunctionArgument.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/safeAccessAsFunctionArgument.kt.after @@ -3,5 +3,5 @@ fun f(s: Int?) { fun main(args: Array) { val x: String? = "foo" - f(if (x != null) x.length else null) + f(if (x != null) x.length() else null) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpression.kt b/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpression.kt index 399cea3f21b..a9e79d8e66e 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpression.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpression.kt @@ -1,4 +1,4 @@ fun main(args: Array) { val foo: String? = "foo" - foo?.length + foo?.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpression.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpression.kt.after index 91b7da93332..7edbddc06a4 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpression.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpression.kt.after @@ -1,4 +1,4 @@ fun main(args: Array) { val foo: String? = "foo" - if (foo != null) foo.length + if (foo != null) foo.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpressionInParens.kt b/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpressionInParens.kt index d7bc97f1bcf..362ca42d6d5 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpressionInParens.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpressionInParens.kt @@ -1,4 +1,4 @@ fun main(args: Array) { val foo: String? = "foo" - (foo)?.length + (foo)?.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpressionInParens.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpressionInParens.kt.after index 91b7da93332..7edbddc06a4 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpressionInParens.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/simpleNameExpressionInParens.kt.after @@ -1,4 +1,4 @@ fun main(args: Array) { val foo: String? = "foo" - if (foo != null) foo.length + if (foo != null) foo.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVal.kt b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVal.kt index cda046018dd..7d59ddf2097 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVal.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVal.kt @@ -2,5 +2,5 @@ fun doSomething(a: T) {} val a: String? = "A" fun main(args: Array) { - doSomething(a?.length) + doSomething(a?.length()) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVal.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVal.kt.after index 6e492136395..084ed52d5b2 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVal.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVal.kt.after @@ -2,5 +2,5 @@ fun doSomething(a: T) {} val a: String? = "A" fun main(args: Array) { - doSomething(if (a != null) a.length else null) + doSomething(if (a != null) a.length() else null) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelValCustomGetter.kt b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelValCustomGetter.kt index 7993bb0bb8c..7764dd6b2a6 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelValCustomGetter.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelValCustomGetter.kt @@ -4,5 +4,5 @@ val a: String? get() = "" fun main(args: Array) { - doSomething(a?.length) + doSomething(a?.length()) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelValCustomGetter.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelValCustomGetter.kt.after index 7e26971ef74..a4a59867cd1 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelValCustomGetter.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelValCustomGetter.kt.after @@ -5,5 +5,5 @@ val a: String? fun main(args: Array) { val s = a - doSomething(if (s != null) s.length else null) + doSomething(if (s != null) s.length() else null) } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVar.kt b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVar.kt index 36f93c10162..025d2cb3f84 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVar.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVar.kt @@ -1,4 +1,4 @@ var a: String? = "A" fun main(args: Array) { - a?.length + a?.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVar.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVar.kt.after index 3210c752652..75f22822585 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVar.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVar.kt.after @@ -1,5 +1,5 @@ var a: String? = "A" fun main(args: Array) { val s = a - if (s != null) s.length + if (s != null) s.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVarCustomGetter.kt b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVarCustomGetter.kt index 07ceabf3af2..305056ba6f4 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVarCustomGetter.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVarCustomGetter.kt @@ -3,5 +3,5 @@ var a: String? set(v) {} fun main(args: Array) { - a?.length + a?.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVarCustomGetter.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVarCustomGetter.kt.after index fcf29763a12..ac86b6ace94 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVarCustomGetter.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/topLevelVarCustomGetter.kt.after @@ -4,5 +4,5 @@ var a: String? fun main(args: Array) { val s = a - if (s != null) s.length + if (s != null) s.length() } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsFunctionRhs.kt b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsFunctionRhs.kt index 82c1bd1734f..2e8b1bdd99a 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsFunctionRhs.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsFunctionRhs.kt @@ -1,4 +1,4 @@ -fun foo(arg: String?): Int? = arg?.length +fun foo(arg: String?): Int? = arg?.length() fun main(args: Array) { foo("bar") } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsFunctionRhs.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsFunctionRhs.kt.after index 2be935e3ce5..4929adf5d1d 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsFunctionRhs.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsFunctionRhs.kt.after @@ -1,4 +1,4 @@ -fun foo(arg: String?): Int? = if (arg != null) arg.length else null +fun foo(arg: String?): Int? = if (arg != null) arg.length() else null fun main(args: Array) { foo("bar") } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsResultOfCheckedIf.kt b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsResultOfCheckedIf.kt index 5f676080296..8fac3f4df26 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsResultOfCheckedIf.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsResultOfCheckedIf.kt @@ -1,4 +1,4 @@ fun main(args: Array) { val foo: String? = "foo" - val y = if (true) foo?.length else null + val y = if (true) foo?.length() else null } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsResultOfCheckedIf.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsResultOfCheckedIf.kt.after index 934df9a48d2..9aa3f0e4882 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsResultOfCheckedIf.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsResultOfCheckedIf.kt.after @@ -1,4 +1,4 @@ fun main(args: Array) { val foo: String? = "foo" - val y = if (true) if (foo != null) foo.length else null else null + val y = if (true) if (foo != null) foo.length() else null else null } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsReturnValue.kt b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsReturnValue.kt index bcb92df6cd2..7aef1933cf5 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsReturnValue.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsReturnValue.kt @@ -1,6 +1,6 @@ fun doSth(): Int? { val x: String? = "abc" - return x?.length + return x?.length() } fun main(args: Array) { val y = doSth() diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsReturnValue.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsReturnValue.kt.after index 97656a5c0cf..f6cd676ae57 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/usedAsReturnValue.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/usedAsReturnValue.kt.after @@ -1,6 +1,6 @@ fun doSth(): Int? { val x: String? = "abc" - return if (x != null) x.length else null + return if (x != null) x.length() else null } fun main(args: Array) { val y = doSth() diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/usedInUncheckedIfExpression.kt b/idea/testData/intentions/branched/safeAccessToIfThen/usedInUncheckedIfExpression.kt index fac801cbee7..3c803c93d22 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/usedInUncheckedIfExpression.kt +++ b/idea/testData/intentions/branched/safeAccessToIfThen/usedInUncheckedIfExpression.kt @@ -1,6 +1,6 @@ fun main(args: Array) { val foo: String? = "foo" if (true) { - foo?.length + foo?.length() } } diff --git a/idea/testData/intentions/branched/safeAccessToIfThen/usedInUncheckedIfExpression.kt.after b/idea/testData/intentions/branched/safeAccessToIfThen/usedInUncheckedIfExpression.kt.after index 4845e7f7f61..6531d3ce562 100644 --- a/idea/testData/intentions/branched/safeAccessToIfThen/usedInUncheckedIfExpression.kt.after +++ b/idea/testData/intentions/branched/safeAccessToIfThen/usedInUncheckedIfExpression.kt.after @@ -1,6 +1,6 @@ fun main(args: Array) { val foo: String? = "foo" if (true) { - if (foo != null) foo.length + if (foo != null) foo.length() } } diff --git a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt index 51ede2c0e1f..4b07fa3ca73 100644 --- a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt +++ b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt @@ -1,5 +1,5 @@ fun String.not(): Boolean { - return length == 0 + return length() == 0 } fun foo(a: Boolean, b: Boolean) : Boolean { diff --git a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt.after b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt.after index 6c6a20b38bc..b8c77df713c 100644 --- a/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt.after +++ b/idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/doubleNegation.kt.after @@ -1,5 +1,5 @@ fun String.not(): Boolean { - return length == 0 + return length() == 0 } fun foo(a: Boolean, b: Boolean) : Boolean { diff --git a/idea/testData/intentions/removeCurlyBracesFromTemplate/necessaryBrackets1.kt b/idea/testData/intentions/removeCurlyBracesFromTemplate/necessaryBrackets1.kt index ba0e7fbdcc9..b268658eed5 100644 --- a/idea/testData/intentions/removeCurlyBracesFromTemplate/necessaryBrackets1.kt +++ b/idea/testData/intentions/removeCurlyBracesFromTemplate/necessaryBrackets1.kt @@ -1,5 +1,5 @@ // IS_APPLICABLE: false fun foo() { val x = "x" - val y = "${x.length}" + val y = "${x.length()}" } \ No newline at end of file diff --git a/idea/testData/intentions/replaceWithInfixFunctionCall/propertyAccess.kt b/idea/testData/intentions/replaceWithInfixFunctionCall/propertyAccess.kt index a056d68d8a3..0008bdba3b0 100644 --- a/idea/testData/intentions/replaceWithInfixFunctionCall/propertyAccess.kt +++ b/idea/testData/intentions/replaceWithInfixFunctionCall/propertyAccess.kt @@ -1,4 +1,4 @@ // IS_APPLICABLE: false -fun foo(x: String) { - x.length +fun foo(x: IntRange) { + x.start } diff --git a/idea/testData/quickfix/expressions/afterUnnecessaryNonNullAssertion3.kt b/idea/testData/quickfix/expressions/afterUnnecessaryNonNullAssertion3.kt index 9872deea316..ce60477f285 100644 --- a/idea/testData/quickfix/expressions/afterUnnecessaryNonNullAssertion3.kt +++ b/idea/testData/quickfix/expressions/afterUnnecessaryNonNullAssertion3.kt @@ -1,4 +1,4 @@ // "Remove unnecessary non-null assertion (!!)" "true" fun test(value : String) : Int { - return value.length + return value.length() } diff --git a/idea/testData/quickfix/expressions/beforeUnnecessaryNonNullAssertion3.kt b/idea/testData/quickfix/expressions/beforeUnnecessaryNonNullAssertion3.kt index 2422453b1cb..f246dfab42f 100644 --- a/idea/testData/quickfix/expressions/beforeUnnecessaryNonNullAssertion3.kt +++ b/idea/testData/quickfix/expressions/beforeUnnecessaryNonNullAssertion3.kt @@ -1,4 +1,4 @@ // "Remove unnecessary non-null assertion (!!)" "true" fun test(value : String) : Int { - return value!!.length + return value!!.length() } diff --git a/js/js.libraries/src/core/string.kt b/js/js.libraries/src/core/string.kt index 3a7ea799724..3e985d5136c 100644 --- a/js/js.libraries/src/core/string.kt +++ b/js/js.libraries/src/core/string.kt @@ -38,9 +38,6 @@ native public fun String.trim() : String = noImpl native("length") public val CharSequence.size: Int get() = noImpl -library -public fun CharSequence.length(): Int = noImpl - library public fun CharSequence.isEmpty(): Boolean = noImpl diff --git a/js/js.translator/src/org/jetbrains/k2js/translate/intrinsic/functions/factories/StringOperationFIF.java b/js/js.translator/src/org/jetbrains/k2js/translate/intrinsic/functions/factories/StringOperationFIF.java index 8bff6f12ea7..f73f549e253 100644 --- a/js/js.translator/src/org/jetbrains/k2js/translate/intrinsic/functions/factories/StringOperationFIF.java +++ b/js/js.translator/src/org/jetbrains/k2js/translate/intrinsic/functions/factories/StringOperationFIF.java @@ -27,7 +27,7 @@ public final class StringOperationFIF extends CompositeFIF { private StringOperationFIF() { add(pattern("kotlin", "CharSequence", "get").checkOverridden(), new BuiltInFunctionIntrinsic("charAt")); - add(pattern("kotlin.js", "length").isExtensionOf("kotlin.CharSequence"), LENGTH_PROPERTY_INTRINSIC); + add(pattern("kotlin", "CharSequence", "length").checkOverridden(), LENGTH_PROPERTY_INTRINSIC); add(pattern("kotlin.js", "isEmpty").isExtensionOf("kotlin.CharSequence"), IS_EMPTY_INTRINSIC); } } diff --git a/libraries/stdlib/src/kotlin/text/Strings.kt b/libraries/stdlib/src/kotlin/text/Strings.kt index 60c69b59e00..844b9822e0b 100644 --- a/libraries/stdlib/src/kotlin/text/Strings.kt +++ b/libraries/stdlib/src/kotlin/text/Strings.kt @@ -64,6 +64,9 @@ public fun String?.orEmpty(): String = this ?: "" public val String.indices: IntRange get() = 0..length() - 1 +public val CharSequence.length: Int + get() = length() + /** * Returns a subsequence specified by given set of indices. */ diff --git a/libraries/stdlib/src/kotlin/text/StringsJVM.kt b/libraries/stdlib/src/kotlin/text/StringsJVM.kt index 3ccbdd2e1e4..b6ce97d23b7 100644 --- a/libraries/stdlib/src/kotlin/text/StringsJVM.kt +++ b/libraries/stdlib/src/kotlin/text/StringsJVM.kt @@ -2,9 +2,6 @@ package kotlin import java.io.StringReader import java.util.ArrayList -import java.util.HashMap -import java.util.HashSet -import java.util.LinkedList import java.util.Locale import java.nio.charset.Charset @@ -30,8 +27,6 @@ public fun String.toUpperCase(): String = (this as java.lang.String).toUpperCase public fun String.toLowerCase(): String = (this as java.lang.String).toLowerCase() -public fun String.length(): Int = (this as java.lang.String).length() - public fun String.toCharArray(): CharArray = (this as java.lang.String).toCharArray() public fun String.format(vararg args: Any?): String = java.lang.String.format(this, *args) @@ -132,10 +127,6 @@ public fun CharSequence.charAt(index: Int): Char = (this as java.lang.CharSequen public fun CharSequence.subSequence(start: Int, end: Int): CharSequence? = (this as java.lang.CharSequence).subSequence(start, end) -public fun CharSequence.toString(): String? = (this as java.lang.CharSequence).toString() - -public fun CharSequence.length(): Int = (this as java.lang.CharSequence).length() - public val CharSequence.size: Int get() = this.length