Compare commits

...

29 Commits

Author SHA1 Message Date
Dmitry Jemerov
3674663d30 use Kotlin call hierarchy provider only for Kotlin elements, to ensure that it does not interfere with standard Java features of IntelliJ IDEA
(cherry picked from commit 7004917)
2015-11-26 11:34:34 +01:00
Natalia Ukhorskaya
e74282753a Fix compatibility with AS 2.0
#KT-10153 Fixed
2015-11-24 19:06:47 +03:00
Dmitry Jemerov
bbb92ead5b ensure that the short name of the Kotlin unused import inspection does not clash with Java (KT-10046)
(cherry picked from commit 30084df)
2015-11-20 14:07:12 +01:00
Michael Nedzelsky
08e9ff602f fix KT-10068 JsLibraryStdDetectionUtil does not use caching through JarUserDataManager
#KT-10068 Fixed
(cherry picked from commit ea4470a)
2015-11-19 18:54:44 +01:00
Nikolay Krasko
73596f7464 Enable bootstrapping for the branch 2015-11-19 16:14:54 +03:00
Alexander Udalov
0dcf34bb55 Fix deadlock on static initializers of KProperty implementations
#KT-10041 Fixed
2015-11-19 02:58:00 +03:00
Mikhail Glukhikh
0bcdfce84b Diagnostics corrected for smart cast impossible (cherry picked from commit 03287d5) 2015-11-18 20:13:28 +03:00
Yan Zhulanow
e8be0962c2 Android extensions: get descriptors using reflection (temporary change)
(cherry picked from commit f228c04)
2015-11-17 20:29:53 +03:00
Yan Zhulanow
8afd6421bb Revert "do not package kotlin-runtime and kotlin-reflect into Kotlin Android extensions zip"
This reverts commit 83bf5daf7f.
(cherry picked from commit a1dcede)
2015-11-17 20:29:45 +03:00
Dmitry Jemerov
a946126dca do not package kotlin-runtime and kotlin-reflect into Kotlin Android extensions zip
(cherry picked from commit 83bf5da)
2015-11-17 13:15:24 +01:00
Ilya Gorbunov
47895c0cc2 Correct deprecation replacement for Progression constructors.
Update testdata for LoadBuiltinsTest
2015-11-13 21:57:27 +03:00
Ilya Chernikov
bb6677620a Additional fix to the previous one: Disabling parallel builds without daemon again and undoing apprpriate fix to broken tests problem, since it effectively cancelled fix for parallel building itself and was causing exceptions on heavy builds 2015-11-12 19:14:00 +01:00
Ilya Chernikov
06104521f2 Disabling parallel builds without daemon again and undoing apprpriate fix to broken tests problem, since it effectively cancelled fix for parallel building itself and was causing exceptions on heavy builds 2015-11-12 17:13:26 +01:00
Valentin Kipyatkov
63fc7110a7 KT-9981 Code cleanup replace usages of !in incorrectly
#KT-9981 Fixed
2015-11-12 15:11:07 +03:00
Michael Bogdanov
f5bab93fd1 Additional diagnostic for KT-9980: KotlinFrontEndException: Exception while analyzing expression 2015-11-12 15:11:29 +03:00
Ilya Gorbunov
8f2c05668e Make MutableMap.set return Unit
#KT-7853 Fixed
2015-11-11 19:15:52 +03:00
Ilya Gorbunov
737763cc67 Restore correct sorting order (after cleanup in 17fc1d95) 2015-11-11 19:15:51 +03:00
Ilya Gorbunov
2bd44799f8 Simplify message expression from lambda argument when converting assert to if. 2015-11-11 19:15:50 +03:00
Ilya Gorbunov
e13fb0e7bc Deprecated with ERROR preconditions with eager message. 2015-11-11 19:15:49 +03:00
Ilya Gorbunov
16df7a9d92 Replace getStackTrace usages in j2k and testData. 2015-11-11 19:15:48 +03:00
Ilya Gorbunov
d5d803963f Replace Regex.match and matchAll usages 2015-11-11 19:15:47 +03:00
Ilya Gorbunov
20a15dc175 Refactor intention test files enumerating, do not use deprecated filter method, which would get another behavior after dropping deprecated one. 2015-11-11 19:15:46 +03:00
Ilya Gorbunov
26bd8600cf Drop deprecations and tighten up left ones. 2015-11-11 19:15:45 +03:00
Nikolay Krasko
abb116ef9a Fix locator syntax 2015-11-11 19:06:57 +03:00
Ilya Gorbunov
a336888858 Make emptyMap upperbound to be Any? rather than Any.
#KT-9963
2015-11-11 17:17:42 +03:00
Ilya Gorbunov
19501aac59 Do not override default AbstractList iterator() implementation for primitiveArray.asList wrappers.
#KT-9927 Fixed
2015-11-11 17:17:41 +03:00
Nikolay Krasko
f9ac5ae737 Enable auto-increment in beta2 branch 2015-11-11 17:13:27 +03:00
Dmitry Jemerov
9cb5defc43 don't analyze class repeatedly if we already found an annotated member there
#KT-8557 Fixed
(cherry picked from commit 6f2fb3f)
2015-11-11 15:10:12 +01:00
Valentin Kipyatkov
4782077357 KT-9928 Replacement not offered for a usage of symbol deprecated with DeprecationLevel.ERROR
#KT-9928 Fixed
(cherry picked from commit de11d57)
2015-11-11 17:08:58 +03:00
116 changed files with 454 additions and 648 deletions

View File

@@ -171,7 +171,7 @@ public object TypeIntrinsics {
*/
private fun getFunctionTypeArity(jetType: KotlinType): Int {
val classFqName = getClassFqName(jetType) ?: return -1
val match = KOTLIN_FUNCTION_INTERFACE_REGEX.match(classFqName) ?: return -1
val match = KOTLIN_FUNCTION_INTERFACE_REGEX.find(classFqName) ?: return -1
return Integer.valueOf(match.groups[1]!!.value)
}

View File

@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.descriptors.PackagePartProvider
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
import java.io.EOFException
public class JvmPackagePartProvider(val env: KotlinCoreEnvironment) : PackagePartProvider {
@@ -47,7 +48,11 @@ public class JvmPackagePartProvider(val env: KotlinCoreEnvironment) : PackagePar
}.filterNotNull().flatMap {
it.children.filter { it.name.endsWith(ModuleMapping.MAPPING_FILE_EXT) }.toList<VirtualFile>()
}.map {
ModuleMapping.create(it.contentsToByteArray())
try {
ModuleMapping.create(it.contentsToByteArray())
} catch (e: EOFException) {
throw RuntimeException("Error on reading package parts for '$packageFqName' package in '$it', roots: $roots", e)
}
}
return mappings.map { it.findPackageParts(packageFqName) }.filterNotNull().flatMap { it.parts }.distinct()

View File

@@ -255,7 +255,7 @@ public class KotlinCoreEnvironment private constructor(
val appEnv = getOrCreateApplicationEnvironmentForProduction(configuration, configFilePaths)
// Disposing of the environment is unsafe in production then parallel builds are enabled, but turning it off universally
// breaks a lot of tests, therefore it is disabled for production and enabled for tests
if (System.getProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY) == null || appEnv.application.isUnitTestMode) {
if (System.getProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY) == null) {
// JPS may run many instances of the compiler in parallel (there's an option for compiling independent modules in parallel in IntelliJ)
// All projects share the same ApplicationEnvironment, and when the last project is disposed, the ApplicationEnvironment is disposed as well
Disposer.register(parentDisposable, object : Disposable {

View File

@@ -33,10 +33,10 @@ class DataFlowValue(val id: Any?, val type: KotlinType, val kind: DataFlowValue.
STABLE_VALUE("stable"),
// Member value with open / custom getter
// Smart casts are not safe
MEMBER_VALUE_WITH_GETTER("custom getter", "member value that has open or custom getter"),
PROPERTY_WITH_GETTER("custom getter", "property that has open or custom getter"),
// Protected / public member value from another module
// Smart casts are not safe
ALIEN_PUBLIC_VALUE("alien public", "public API member value declared in different module"),
ALIEN_PUBLIC_PROPERTY("alien public", "public API property declared in different module"),
// Local variable not yet captured by a changing closure
// Smart casts are safe but possible changes in loops / closures ahead must be taken into account
PREDICTABLE_VARIABLE("predictable", "local variable that can be changed since the check in a loop"),
@@ -45,7 +45,7 @@ class DataFlowValue(val id: Any?, val type: KotlinType, val kind: DataFlowValue.
UNPREDICTABLE_VARIABLE("unpredictable", "local variable that is captured by a changing closure"),
// Member variable regardless of its visibility
// Smart casts are not safe
MEMBER_VARIABLE("member", "member variable that can be changed from another thread"),
MUTABLE_PROPERTY("member", "mutable property that could have been changed by this time"),
// Some complex expression
// Smart casts are not safe
OTHER("other", "complex expression");

View File

@@ -377,13 +377,13 @@ public class DataFlowValueFactory {
}
private static Kind propertyKind(@NotNull PropertyDescriptor propertyDescriptor, @Nullable ModuleDescriptor usageModule) {
if (propertyDescriptor.isVar()) return MEMBER_VARIABLE;
if (!isFinal(propertyDescriptor)) return MEMBER_VALUE_WITH_GETTER;
if (!hasDefaultGetter(propertyDescriptor)) return MEMBER_VALUE_WITH_GETTER;
if (propertyDescriptor.isVar()) return MUTABLE_PROPERTY;
if (!isFinal(propertyDescriptor)) return PROPERTY_WITH_GETTER;
if (!hasDefaultGetter(propertyDescriptor)) return PROPERTY_WITH_GETTER;
if (!invisibleFromOtherModules(propertyDescriptor)) {
ModuleDescriptor declarationModule = DescriptorUtils.getContainingModule(propertyDescriptor);
if (usageModule == null || !usageModule.equals(declarationModule)) {
return ALIEN_PUBLIC_VALUE;
return ALIEN_PUBLIC_PROPERTY;
}
}
return STABLE_VALUE;
@@ -400,7 +400,7 @@ public class DataFlowValueFactory {
}
if (!(variableDescriptor instanceof LocalVariableDescriptor) && !(variableDescriptor instanceof ParameterDescriptor)) return OTHER;
if (!variableDescriptor.isVar()) return STABLE_VALUE;
if (variableDescriptor instanceof SyntheticFieldDescriptor) return MEMBER_VARIABLE;
if (variableDescriptor instanceof SyntheticFieldDescriptor) return MUTABLE_PROPERTY;
// Local variable classification: PREDICTABLE or UNPREDICTABLE
PreliminaryDeclarationVisitor preliminaryVisitor =

View File

@@ -254,8 +254,8 @@ public object KotlinCompilerClient {
private fun String.extractPortFromRunFilename(digest: String): Int =
makeRunFilenameString(timestamp = "[0-9TZ:\\.\\+-]+", digest = digest, port = "(\\d+)", escapeSequence = "\\").toRegex()
.match(this)
makeRunFilenameString(timestamp = "[0-9TZ:\\.\\+-]+", digest = digest, port = "(\\d+)", escapeSequence = "\\").toRegex()
.find(this)
?.groups?.get(1)
?.value?.toInt()
?: 0

View File

@@ -129,7 +129,7 @@ public abstract class ByteIterator : kotlin.Iterator<kotlin.Byte> {
}
@kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "Use IntProgression instead.", replaceWith = kotlin.ReplaceWith(expression = "IntProgression", imports = {})) public open class ByteProgression : kotlin.Progression<kotlin.Byte> {
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use ByteProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "ByteProgression.fromClosedRange(start, end, increment)", imports = {})) public constructor ByteProgression(/*0*/ start: kotlin.Byte, /*1*/ endInclusive: kotlin.Byte, /*2*/ increment: kotlin.Int)
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use ByteProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "ByteProgression.fromClosedRange(start, endInclusive, increment)", imports = {})) public constructor ByteProgression(/*0*/ start: kotlin.Byte, /*1*/ endInclusive: kotlin.Byte, /*2*/ increment: kotlin.Int)
@kotlin.Deprecated(message = "Use 'last' property instead.") public open override /*1*/ val end: kotlin.Byte
public open override /*1*/ fun <get-end>(): kotlin.Byte
public final val first: kotlin.Byte
@@ -231,7 +231,7 @@ public abstract class CharIterator : kotlin.Iterator<kotlin.Char> {
}
public open class CharProgression : kotlin.Progression<kotlin.Char> {
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use CharProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "CharProgression.fromClosedRange(start, end, increment)", imports = {})) public constructor CharProgression(/*0*/ start: kotlin.Char, /*1*/ endInclusive: kotlin.Char, /*2*/ increment: kotlin.Int)
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use CharProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "CharProgression.fromClosedRange(start, endInclusive, increment)", imports = {})) public constructor CharProgression(/*0*/ start: kotlin.Char, /*1*/ endInclusive: kotlin.Char, /*2*/ increment: kotlin.Int)
@kotlin.Deprecated(message = "Use 'last' property instead.") public open override /*1*/ val end: kotlin.Char
public open override /*1*/ fun <get-end>(): kotlin.Char
public final val first: kotlin.Char
@@ -650,7 +650,7 @@ public abstract class IntIterator : kotlin.Iterator<kotlin.Int> {
}
public open class IntProgression : kotlin.Progression<kotlin.Int> {
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use IntProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "IntProgression.fromClosedRange(start, end, increment)", imports = {})) public constructor IntProgression(/*0*/ start: kotlin.Int, /*1*/ endInclusive: kotlin.Int, /*2*/ increment: kotlin.Int)
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use IntProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "IntProgression.fromClosedRange(start, endInclusive, increment)", imports = {})) public constructor IntProgression(/*0*/ start: kotlin.Int, /*1*/ endInclusive: kotlin.Int, /*2*/ increment: kotlin.Int)
@kotlin.Deprecated(message = "Use 'last' property instead.") public open override /*1*/ val end: kotlin.Int
public open override /*1*/ fun <get-end>(): kotlin.Int
public final val first: kotlin.Int
@@ -840,7 +840,7 @@ public abstract class LongIterator : kotlin.Iterator<kotlin.Long> {
}
public open class LongProgression : kotlin.Progression<kotlin.Long> {
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use LongProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "LongProgression.fromClosedRange(start, end, increment)", imports = {})) public constructor LongProgression(/*0*/ start: kotlin.Long, /*1*/ endInclusive: kotlin.Long, /*2*/ increment: kotlin.Long)
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use LongProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "LongProgression.fromClosedRange(start, endInclusive, increment)", imports = {})) public constructor LongProgression(/*0*/ start: kotlin.Long, /*1*/ endInclusive: kotlin.Long, /*2*/ increment: kotlin.Long)
@kotlin.Deprecated(message = "Use 'last' property instead.") public open override /*1*/ val end: kotlin.Long
public open override /*1*/ fun <get-end>(): kotlin.Long
public final val first: kotlin.Long
@@ -1165,7 +1165,7 @@ public abstract class ShortIterator : kotlin.Iterator<kotlin.Short> {
}
@kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "Use IntProgression instead.", replaceWith = kotlin.ReplaceWith(expression = "IntProgression", imports = {})) public open class ShortProgression : kotlin.Progression<kotlin.Short> {
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use ShortProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "ShortProgression.fromClosedRange(start, end, increment)", imports = {})) public constructor ShortProgression(/*0*/ start: kotlin.Short, /*1*/ endInclusive: kotlin.Short, /*2*/ increment: kotlin.Int)
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use ShortProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "ShortProgression.fromClosedRange(start, endInclusive, increment)", imports = {})) public constructor ShortProgression(/*0*/ start: kotlin.Short, /*1*/ endInclusive: kotlin.Short, /*2*/ increment: kotlin.Int)
@kotlin.Deprecated(message = "Use 'last' property instead.") public open override /*1*/ val end: kotlin.Short
public open override /*1*/ fun <get-end>(): kotlin.Short
public final val first: kotlin.Short

View File

@@ -10,35 +10,35 @@ fun box(): String {
val s = J::s
// Check that correct reflection objects are created
assert(i !is KMutableProperty<*>, "Fail i class: ${i.javaClass}")
assert(s is KMutableProperty<*>, "Fail s class: ${s.javaClass}")
assert(i !is KMutableProperty<*>) { "Fail i class: ${i.javaClass}" }
assert(s is KMutableProperty<*>) { "Fail s class: ${s.javaClass}" }
// Check that no Method objects are created for such properties
assert(i.javaGetter == null, "Fail i getter")
assert(s.javaGetter == null, "Fail s getter")
assert(s.javaSetter == null, "Fail s setter")
assert(i.javaGetter == null) { "Fail i getter" }
assert(s.javaGetter == null) { "Fail s getter" }
assert(s.javaSetter == null) { "Fail s setter" }
// Check that correct Field objects are created
val ji = i.javaField!!
val js = s.javaField!!
assert(Modifier.isFinal(ji.getModifiers()), "Fail i final")
assert(!Modifier.isFinal(js.getModifiers()), "Fail s final")
assert(Modifier.isFinal(ji.getModifiers())) { "Fail i final" }
assert(!Modifier.isFinal(js.getModifiers())) { "Fail s final" }
// Check that those Field objects work as expected
val a = J(42, "abc")
assert(ji.get(a) == 42, "Fail ji get")
assert(js.get(a) == "abc", "Fail js get")
assert(ji.get(a) == 42) { "Fail ji get" }
assert(js.get(a) == "abc") { "Fail js get" }
js.set(a, "def")
assert(js.get(a) == "def", "Fail js set")
assert(a.s == "def", "Fail js access")
assert(js.get(a) == "def") { "Fail js set" }
assert(a.s == "def") { "Fail js access" }
// Check that valid Kotlin reflection objects are created by those Field objects
val ki = ji.kotlin as KProperty1<J, Int>
val ks = js.kotlin as KMutableProperty1<J, String>
assert(ki.get(a) == 42, "Fail ki get")
assert(ks.get(a) == "def", "Fail ks get")
assert(ki.get(a) == 42) { "Fail ki get" }
assert(ks.get(a) == "def") { "Fail ks get" }
ks.set(a, "ghi")
assert(ks.get(a) == "ghi", "Fail ks set")
assert(ks.get(a) == "ghi") { "Fail ks set" }
return "OK"
}

View File

@@ -21,7 +21,7 @@ fun testProperLineNumber(): String {
fail()
}
catch(e: AssertionError) {
val entry = e.getStackTrace()!![1]
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("chainCalls.kt:21" != actual) {
return "fail 2: ${actual}"
@@ -34,7 +34,7 @@ fun testProperLineNumber(): String {
fail()
}
catch(e: AssertionError) {
val entry = e.getStackTrace()!![1]
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("chainCalls.kt:34" != actual) {
return "fail 3: ${actual}"
@@ -46,7 +46,7 @@ fun testProperLineNumber(): String {
test().fail()
}
catch(e: AssertionError) {
val entry = e.getStackTrace()!![1]
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("chainCalls.kt:46" != actual) {
return "fail 4: ${actual}"

View File

@@ -18,7 +18,7 @@ fun testProperLineNumber(): String {
test()
}
catch(e: AssertionError) {
val entry = e.getStackTrace()!![1]
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("infixCalls.kt:17" != actual) {
return "fail 1: ${actual}"
@@ -30,7 +30,7 @@ fun testProperLineNumber(): String {
call() fail test()
}
catch(e: AssertionError) {
val entry = e.getStackTrace()!![1]
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("infixCalls.kt:30" != actual) {
return "fail 1: ${actual}"

View File

@@ -18,7 +18,7 @@ fun testProperLineNumberAfterInline(): String {
test())
}
catch(e: AssertionError) {
val entry = e.getStackTrace()!![1]
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("simpleCallWithParams.kt:17" != actual) {
return "fail 2: ${actual}"
@@ -36,7 +36,7 @@ fun testProperLineForOtherParameters(): String {
fail())
}
catch(e: AssertionError) {
val entry = e.getStackTrace()!![1]
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("simpleCallWithParams.kt:35" != actual) {
return "fail 3: ${actual}"
@@ -50,7 +50,7 @@ fun testProperLineForOtherParameters(): String {
test())
}
catch(e: AssertionError) {
val entry = e.getStackTrace()!![1]
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("simpleCallWithParams.kt:49" != actual) {
return "fail 4: ${actual}"
@@ -62,7 +62,7 @@ fun testProperLineForOtherParameters(): String {
checkEquals(fail(), test())
}
catch(e: AssertionError) {
val entry = e.getStackTrace()!![1]
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("simpleCallWithParams.kt:62" != actual) {
return "fail 5: ${actual}"
@@ -74,7 +74,7 @@ fun testProperLineForOtherParameters(): String {
checkEquals(fail(), test())
}
catch(e: AssertionError) {
val entry = e.getStackTrace()!![1]
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("simpleCallWithParams.kt:74" != actual) {
return "fail 6: ${actual}"

View File

@@ -11,14 +11,14 @@ class Secondary {
}
fun check(f: KFunction<Any>) {
assert(f.javaMethod == null, "Fail f method")
assert(f.javaConstructor != null, "Fail f constructor")
assert(f.javaMethod == null) { "Fail f method" }
assert(f.javaConstructor != null) { "Fail f constructor" }
val c = f.javaConstructor!!
assert(c.kotlinFunction != null, "Fail m function")
assert(c.kotlinFunction != null) { "Fail m function" }
val ff = c.kotlinFunction!!
assert(f == ff, "Fail f != ff")
assert(f == ff) { "Fail f != ff" }
}
fun box(): String {

View File

@@ -19,9 +19,9 @@ fun box(): String {
assertEquals(setter, Class.forName("ExtensionPropertyKt").getMethod("setExt", javaClass<K>(), javaClass<Double>()))
val k = K(42L)
assert(getter.invoke(null, k) == 42.0, "Fail k getter")
assert(getter.invoke(null, k) == 42.0) { "Fail k getter" }
setter.invoke(null, k, -239.0)
assert(getter.invoke(null, k) == -239.0, "Fail k setter")
assert(getter.invoke(null, k) == -239.0) { "Fail k setter" }
return "OK"
}

View File

@@ -8,14 +8,14 @@ fun bar(s: String): Int = s.length()
fun String.baz(): Int = this.length()
fun check(f: KFunction<Int>) {
assert(f.javaConstructor == null, "Fail f constructor")
assert(f.javaMethod != null, "Fail f method")
assert(f.javaConstructor == null) { "Fail f constructor" }
assert(f.javaMethod != null) { "Fail f method" }
val m = f.javaMethod!!
assert(m.kotlinFunction != null, "Fail m function")
assert(m.kotlinFunction != null) { "Fail m function" }
val ff = m.kotlinFunction!!
assert(f == ff, "Fail f != ff")
assert(f == ff) { "Fail f != ff" }
}
fun box(): String {

View File

@@ -6,7 +6,7 @@ class K(var value: Long)
fun box(): String {
val p = K::value
assert(p.javaField != null, "Fail p field")
assert(p.javaField != null) { "Fail p field" }
val getter = p.javaGetter!!
val setter = p.javaSetter!!
@@ -15,9 +15,9 @@ fun box(): String {
assertEquals(setter, javaClass<K>().getMethod("setValue", javaClass<Long>()))
val k = K(42L)
assert(getter.invoke(k) == 42L, "Fail k getter")
assert(getter.invoke(k) == 42L) { "Fail k getter" }
setter.invoke(k, -239L)
assert(getter.invoke(k) == -239L, "Fail k setter")
assert(getter.invoke(k) == -239L) { "Fail k setter" }
return "OK"
}

View File

@@ -6,7 +6,7 @@ var topLevel = "123"
fun box(): String {
val p = ::topLevel
assert(p.javaField != null, "Fail p field")
assert(p.javaField != null) { "Fail p field" }
val field = p.javaField!!
val className = field.getDeclaringClass().getName()
assertEquals("TopLevelPropertyKt", className)
@@ -17,9 +17,9 @@ fun box(): String {
assertEquals(getter, Class.forName("TopLevelPropertyKt").getMethod("getTopLevel"))
assertEquals(setter, Class.forName("TopLevelPropertyKt").getMethod("setTopLevel", javaClass<String>()))
assert(getter.invoke(null) == "123", "Fail k getter")
assert(getter.invoke(null) == "123") { "Fail k getter" }
setter.invoke(null, "456")
assert(getter.invoke(null) == "456", "Fail k setter")
assert(getter.invoke(null) == "456") { "Fail k setter" }
return "OK"
}

View File

@@ -8,5 +8,5 @@ fun main(args: Array<String>) {
val annotationClass = javaClass<AnnotationClass>()
val annotation = klass.getAnnotation(annotationClass)!!
val value = annotation.value
require(value == "100 20000 2000000 2000000000000 3.14 3.14 true \u03c0 :)", "Annotation value: $value")
require(value == "100 20000 2000000 2000000000000 3.14 3.14 true \u03c0 :)", { "Annotation value: $value" })
}

View File

@@ -42,7 +42,7 @@ internal fun Sequence<String>.ifNotContainsSequence(patternsIter: Iterator<LineP
{ acc, line ->
when {
!acc.iter.isValid() -> return@fold acc
acc.iter.value.regex.match(line)?.let { acc.iter.value.matchCheck(it) } ?: false -> acc.nextLineAndPattern()
acc.iter.value.regex.find(line)?.let { acc.iter.value.matchCheck(it) } ?: false -> acc.nextLineAndPattern()
else -> acc.nextLine()
}
}

View File

@@ -23,7 +23,7 @@ package kotlin
* A progression of values of type `Byte`.
*/
public open class ByteProgression
@Deprecated("This constructor will become private soon. Use ByteProgression.fromClosedRange() instead.", ReplaceWith("ByteProgression.fromClosedRange(start, end, increment)"))
@Deprecated("This constructor will become private soon. Use ByteProgression.fromClosedRange() instead.", ReplaceWith("ByteProgression.fromClosedRange(start, endInclusive, increment)"))
public constructor
(
start: Byte,
@@ -81,7 +81,7 @@ public open class ByteProgression
* A progression of values of type `Char`.
*/
public open class CharProgression
@Deprecated("This constructor will become private soon. Use CharProgression.fromClosedRange() instead.", ReplaceWith("CharProgression.fromClosedRange(start, end, increment)"))
@Deprecated("This constructor will become private soon. Use CharProgression.fromClosedRange() instead.", ReplaceWith("CharProgression.fromClosedRange(start, endInclusive, increment)"))
public constructor
(
start: Char,
@@ -140,7 +140,7 @@ public open class CharProgression
* A progression of values of type `Short`.
*/
public open class ShortProgression
@Deprecated("This constructor will become private soon. Use ShortProgression.fromClosedRange() instead.", ReplaceWith("ShortProgression.fromClosedRange(start, end, increment)"))
@Deprecated("This constructor will become private soon. Use ShortProgression.fromClosedRange() instead.", ReplaceWith("ShortProgression.fromClosedRange(start, endInclusive, increment)"))
public constructor
(
start: Short,
@@ -198,7 +198,7 @@ public open class ShortProgression
* A progression of values of type `Int`.
*/
public open class IntProgression
@Deprecated("This constructor will become private soon. Use IntProgression.fromClosedRange() instead.", ReplaceWith("IntProgression.fromClosedRange(start, end, increment)"))
@Deprecated("This constructor will become private soon. Use IntProgression.fromClosedRange() instead.", ReplaceWith("IntProgression.fromClosedRange(start, endInclusive, increment)"))
public constructor
(
start: Int,
@@ -256,7 +256,7 @@ public open class IntProgression
* A progression of values of type `Long`.
*/
public open class LongProgression
@Deprecated("This constructor will become private soon. Use LongProgression.fromClosedRange() instead.", ReplaceWith("LongProgression.fromClosedRange(start, end, increment)"))
@Deprecated("This constructor will become private soon. Use LongProgression.fromClosedRange() instead.", ReplaceWith("LongProgression.fromClosedRange(start, endInclusive, increment)"))
public constructor
(
start: Long,

View File

@@ -19,7 +19,6 @@ package kotlin.reflect.jvm.internal
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
import java.lang.reflect.Field
import kotlin.reflect.KProperty
import kotlin.reflect.jvm.internal.JvmPropertySignature.JavaField
import kotlin.reflect.jvm.internal.JvmPropertySignature.KotlinProperty
@@ -40,11 +39,13 @@ internal abstract class DescriptorBasedProperty<out R> protected constructor(
descriptor
)
override val descriptor: PropertyDescriptor by ReflectProperties.lazySoft<PropertyDescriptor>(descriptorInitialValue) {
private val descriptor_ = ReflectProperties.lazySoft<PropertyDescriptor>(descriptorInitialValue) {
container.findPropertyDescriptor(name, signature)
}
val javaField: Field? by ReflectProperties.lazySoft {
override val descriptor: PropertyDescriptor get() = descriptor_()
private val javaField_ = ReflectProperties.lazySoft {
val jvmSignature = RuntimeTypeMapper.mapPropertySignature(descriptor)
when (jvmSignature) {
is KotlinProperty -> {
@@ -56,6 +57,9 @@ internal abstract class DescriptorBasedProperty<out R> protected constructor(
}
}
// Used in subclasses as an implementation of an irrelevant property from KPropertyImpl
val javaField: Field? get() = javaField_()
override fun equals(other: Any?): Boolean {
val that = other.asKPropertyImpl() ?: return false
return container == that.container && name == that.name && signature == that.signature

View File

@@ -25,7 +25,9 @@ internal open class KProperty0Impl<out R> : DescriptorBasedProperty<R>, KPropert
constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
override val getter by ReflectProperties.lazy { Getter(this) }
private val getter_ = ReflectProperties.lazy { Getter(this) }
override val getter: Getter<R> get() = getter_()
override fun get(): R = getter.call()
@@ -39,7 +41,9 @@ internal open class KMutableProperty0Impl<R> : KProperty0Impl<R>, KMutableProper
constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
override val setter by ReflectProperties.lazy { Setter(this) }
private val setter_ = ReflectProperties.lazy { Setter(this) }
override val setter: Setter<R> get() = setter_()
override fun set(value: R) = setter.call(value)

View File

@@ -25,7 +25,9 @@ internal open class KProperty1Impl<T, out R> : DescriptorBasedProperty<R>, KProp
constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
override val getter by ReflectProperties.lazy { Getter(this) }
private val getter_ = ReflectProperties.lazy { Getter(this) }
override val getter: Getter<T, R> get() = getter_()
override fun get(receiver: T): R = getter.call(receiver)
@@ -39,7 +41,9 @@ internal open class KMutableProperty1Impl<T, R> : KProperty1Impl<T, R>, KMutable
constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
override val setter by ReflectProperties.lazy { Setter(this) }
private val setter_ = ReflectProperties.lazy { Setter(this) }
override val setter: Setter<T, R> get() = setter_()
override fun set(receiver: T, value: R) = setter.call(receiver, value)

View File

@@ -25,7 +25,9 @@ internal open class KProperty2Impl<D, E, out R> : DescriptorBasedProperty<R>, KP
constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
override val getter by ReflectProperties.lazy { Getter(this) }
private val getter_ = ReflectProperties.lazy { Getter(this) }
override val getter: Getter<D, E, R> get() = getter_()
override fun get(receiver1: D, receiver2: E): R = getter.call(receiver1, receiver2)
@@ -39,7 +41,9 @@ internal open class KMutableProperty2Impl<D, E, R> : KProperty2Impl<D, E, R>, KM
constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
override val setter by ReflectProperties.lazy { Setter(this) }
private val setter_ = ReflectProperties.lazy { Setter(this) }
override val setter: Setter<D, E, R> get() = setter_()
override fun set(receiver1: D, receiver2: E, value: R) = setter.call(receiver1, receiver2, value)

View File

@@ -56,7 +56,7 @@ class GenerateProgressions(out: PrintWriter) : BuiltInsSourceGenerator(out) {
* A progression of values of type `$t`.
*/
public open class $progression
@Deprecated("This constructor will become private soon. Use $progression.fromClosedRange() instead.", ReplaceWith("$progression.fromClosedRange(start, end, increment)"))
@Deprecated("This constructor will become private soon. Use $progression.fromClosedRange() instead.", ReplaceWith("$progression.fromClosedRange(start, endInclusive, increment)"))
public constructor
(
start: $t,

View File

@@ -41,6 +41,8 @@ public class JsLibraryStdDetectionUtil {
}
public static boolean hasJsStdlibJar(@NotNull Library library) {
if (!KotlinJavaScriptLibraryDetectionUtil.isKotlinJavaScriptLibrary(library)) return false;
List<VirtualFile> classes = Arrays.asList(library.getFiles(OrderRootType.CLASSES));
return getJsLibraryStdVersion(classes, false) != null;
}

View File

@@ -88,7 +88,19 @@ private fun String.amendNextLinesIfNeeded(reader: OutputLineReader): String {
nextLine = reader.readLine()
}
if (nextLine != null) reader.pushBack(nextLine)
if (nextLine != null) {
// This code is needed for compatibility with AS 2.0 and IDEA 15.0, because of difference in android plugins
val positionField = try {
reader.javaClass.getDeclaredField("myPosition")
}
catch(e: Throwable) {
null
}
if (positionField != null) {
positionField.isAccessible = true
positionField.setInt(reader, positionField.getInt(reader) - 1)
}
}
return builder.toString()
}

View File

@@ -0,0 +1,5 @@
<html>
<body>
Reports any <b>import</b> statements in Kotlin code that are unused.
</body>
</html>

View File

@@ -524,10 +524,6 @@
<callHierarchyProvider
language="kotlin"
implementationClass="org.jetbrains.kotlin.idea.hierarchy.calls.KotlinCallHierarchyProvider" />
<callHierarchyProvider
language="JAVA"
implementationClass="org.jetbrains.kotlin.idea.hierarchy.calls.KotlinCallHierarchyProvider"
order="first" />
<methodHierarchyProvider
language="kotlin"
implementationClass="org.jetbrains.kotlin.idea.hierarchy.overrides.KotlinOverrideHierarchyProvider" />
@@ -1219,7 +1215,7 @@
level="WARNING"
/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.UnusedImportInspection"
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.KotlinUnusedImportInspection"
displayName="Unused import directive"
groupName="Kotlin"
enabledByDefault="true"

View File

@@ -28,6 +28,7 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.KotlinLanguage;
import org.jetbrains.kotlin.idea.hierarchy.HierarchyUtils;
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil;
import org.jetbrains.kotlin.psi.KtFile;
@@ -42,7 +43,7 @@ public class KotlinCallHierarchyProvider implements HierarchyProvider {
if (element == null) return null;
element = HierarchyUtils.getCallHierarchyElement(element);
if (element instanceof KtFile) return null;
if (element instanceof KtFile || element.getLanguage() != KotlinLanguage.INSTANCE) return null;
return element;
}

View File

@@ -89,6 +89,7 @@ public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspe
Errors.USELESS_ELVIS,
ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION,
Errors.DEPRECATION,
Errors.DEPRECATION_ERROR,
Errors.NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION,
Errors.OPERATOR_MODIFIER_REQUIRED,
Errors.DEPRECATED_UNARY_PLUS_MINUS,

View File

@@ -50,7 +50,7 @@ import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.ImportPath
import java.util.*
class UnusedImportInspection : AbstractKotlinInspection() {
class KotlinUnusedImportInspection : AbstractKotlinInspection() {
override fun runForWholeFile() = true
override fun checkFile(file: PsiFile, manager: InspectionManager, isOnTheFly: Boolean): Array<out ProblemDescriptor>? {

View File

@@ -23,8 +23,12 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.idea.util.ShortenReferences
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.utils.addToStdlib.check
public class ConvertAssertToIfWithThrowIntention : SelfTargetingIntention<KtCallExpression>(javaClass(), "Replace 'assert' with 'if' statement"), LowPriorityAction {
override fun isApplicableTo(element: KtCallExpression, caretOffset: Int): Boolean {
@@ -44,17 +48,21 @@ public class ConvertAssertToIfWithThrowIntention : SelfTargetingIntention<KtCall
override fun applyTo(element: KtCallExpression, editor: Editor) {
val args = element.getValueArguments()
val conditionText = args[0]?.getArgumentExpression()?.getText() ?: return
val functionLiteral = element.getFunctionLiteralArguments().singleOrNull()
val messageIsFunction = messageIsFunction(element)
val functionLiteralArgument = element.functionLiteralArguments.singleOrNull()
val bindingContext = element.analyze(BodyResolveMode.PARTIAL)
val psiFactory = KtPsiFactory(element)
val messageExpr = when {
args.size() == 2 -> args[1]?.getArgumentExpression() ?: return
functionLiteral != null -> functionLiteral!!
else -> psiFactory.createExpression("\"Assertion failed\"")
val messageFunctionExpr = when {
args.size == 2 -> args[1]?.getArgumentExpression() ?: return
functionLiteralArgument != null -> functionLiteralArgument.getFunctionLiteral()
else -> null
}
val extractedMessageSingleExpr = (messageFunctionExpr as? KtFunctionLiteralExpression)?.let { extractMessageSingleExpression(it, bindingContext) }
val messageIsFunction = extractedMessageSingleExpr == null && messageIsFunction(element, bindingContext)
val messageExpr = extractedMessageSingleExpr ?: messageFunctionExpr ?: psiFactory.createExpression("\"Assertion failed\"")
val ifExpression = replaceWithIfThenThrowExpression(element)
// shorten java.lang.AssertionError
@@ -85,8 +93,14 @@ public class ConvertAssertToIfWithThrowIntention : SelfTargetingIntention<KtCall
simplifyConditionIfPossible(ifExpression)
}
private fun messageIsFunction(callExpr: KtCallExpression): Boolean {
val resolvedCall = callExpr.getResolvedCall(callExpr.analyze()) ?: return false
private fun extractMessageSingleExpression(functionLiteral: KtFunctionLiteralExpression, bindingContext: BindingContext): KtExpression? {
return functionLiteral.bodyExpression?.statements?.singleOrNull()?.let { singleStatement ->
singleStatement.check { it.isUsedAsExpression(bindingContext) }
}
}
private fun messageIsFunction(callExpr: KtCallExpression, bindingContext: BindingContext): Boolean {
val resolvedCall = callExpr.getResolvedCall(bindingContext) ?: return false
val valParameters = resolvedCall.getResultingDescriptor().getValueParameters()
return valParameters.size() > 1 && !KotlinBuiltIns.isAny(valParameters[1].type)
}

View File

@@ -315,6 +315,7 @@ public class QuickFixRegistrar : QuickFixContributor {
ReplaceObsoleteLabelSyntaxFix.createWholeProjectFixFactory())
DEPRECATION.registerFactory(DeprecatedSymbolUsageFix, DeprecatedSymbolUsageInWholeProjectFix)
DEPRECATION_ERROR.registerFactory(DeprecatedSymbolUsageFix, DeprecatedSymbolUsageInWholeProjectFix)
POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION.registerFactory(ReplaceJavaAnnotationPositionedArgumentsFix)

View File

@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference
import org.jetbrains.kotlin.idea.core.*
import org.jetbrains.kotlin.idea.intentions.OperatorToFunctionIntention
import org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArgumentsIntention
import org.jetbrains.kotlin.idea.intentions.setType
import org.jetbrains.kotlin.idea.util.*
@@ -65,8 +66,14 @@ class CallableUsageReplacementStrategy(
if (!callTypeHandler.precheckReplacementPattern(replacement)) return null
return {
// copy replacement expression because it is modified by performCallReplacement
performCallReplacement(usage, bindingContext, resolvedCall, callElement, callTypeHandler, replacement.copy())
if (usage is KtOperationReferenceExpression && usage.getReferencedNameElementType() != KtTokens.IDENTIFIER) {
val nameExpression = OperatorToFunctionIntention.convert(usage.parent as KtExpression).second
createReplacer(nameExpression)!!.invoke()
}
else {
// copy replacement expression because it is modified by performCallReplacement
performCallReplacement(usage, bindingContext, resolvedCall, callElement, callTypeHandler, replacement.copy())
}
}
}

View File

@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.core.OptionalParametersHelper
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
@@ -100,7 +101,7 @@ public abstract class DeprecatedSymbolUsageFixBase(
else
null) ?: return null
val descriptor = Errors.DEPRECATION.cast(deprecatedDiagnostic).a
val descriptor = DiagnosticFactory.cast(deprecatedDiagnostic, Errors.DEPRECATION, Errors.DEPRECATION_ERROR).a
val replacement = DeprecatedSymbolUsageFixBase.fetchReplaceWithPattern(descriptor, nameExpression.project) ?: return null
return Data(nameExpression, replacement, descriptor)
}

View File

@@ -60,22 +60,27 @@ public class KotlinAnnotatedElementsSearcher : QueryExecutor<PsiModifierListOwne
companion object {
private val LOG = Logger.getInstance("#com.intellij.psi.impl.search.AnnotatedMembersSearcher")
public fun processAnnotatedMembers(annClass: PsiClass, useScope: SearchScope, consumer: (KtDeclaration) -> Boolean): Boolean {
public fun processAnnotatedMembers(annClass: PsiClass,
useScope: SearchScope,
preFilter: (KtAnnotationEntry) -> Boolean = { true },
consumer: (KtDeclaration) -> Boolean): Boolean {
assert(annClass.isAnnotationType()) { "Annotation type should be passed to annotated members search" }
val annotationFQN = annClass.getQualifiedName()
assert(annotationFQN != null)
for (elt in getKotlinAnnotationCandidates(annClass, useScope)) {
val candidates = getKotlinAnnotationCandidates(annClass, useScope)
for (elt in candidates) {
if (notKtAnnotationEntry(elt)) continue
val result = runReadAction(fun(): Boolean {
if (elt !is KtAnnotationEntry) return true
if (!preFilter(elt)) return true
val declaration = elt.getStrictParentOfType<KtDeclaration>() ?: return true
val annotationEntry = elt as KtAnnotationEntry
val context = annotationEntry.analyze(BodyResolveMode.PARTIAL)
val annotationDescriptor = context.get(BindingContext.ANNOTATION, annotationEntry) ?: return true
val context = elt.analyze(BodyResolveMode.PARTIAL)
val annotationDescriptor = context.get(BindingContext.ANNOTATION, elt) ?: return true
val descriptor = annotationDescriptor.getType().getConstructor().getDeclarationDescriptor() ?: return true
if (!(DescriptorUtils.getFqName(descriptor).asString() == annotationFQN)) return true

View File

@@ -34,10 +34,12 @@ class KotlinClassesWithAnnotatedMembersSearcher : ScopedQueryExecutor<PsiClass,
override fun execute(queryParameters: ClassesWithAnnotatedMembersSearch.Parameters, consumer: Processor<PsiClass>): Boolean {
val processed = hashSetOf<KtClassOrObject>()
return KotlinAnnotatedElementsSearcher.processAnnotatedMembers(queryParameters.annotationClass, queryParameters.scope) { declaration ->
val jetClass = declaration.getNonStrictParentOfType<KtClassOrObject>()
if (jetClass != null && processed.add(jetClass)) {
val lightClass = LightClassUtil.getPsiClass(jetClass)
return KotlinAnnotatedElementsSearcher.processAnnotatedMembers(queryParameters.annotationClass,
queryParameters.scope,
{ it.getNonStrictParentOfType<KtClassOrObject>() !in processed}) { declaration ->
val ktClass = declaration.getNonStrictParentOfType<KtClassOrObject>()
if (ktClass != null && processed.add(ktClass)) {
val lightClass = LightClassUtil.getPsiClass(ktClass)
if (lightClass != null) consumer.process(lightClass) else true
}
else

View File

@@ -228,13 +228,13 @@ class Mutable(var <info descr="This property has a backing field">x</info>: Stri
fun foo(): String {
if (x is String) {
return <error descr="[SMARTCAST_IMPOSSIBLE] Smart cast to 'kotlin.String' is impossible, because 'x' is a member variable that can be changed from another thread">x</error>
return <error descr="[SMARTCAST_IMPOSSIBLE] Smart cast to 'kotlin.String' is impossible, because 'x' is a mutable property that could have been changed by this time">x</error>
}
if (x != null) {
return <error descr="[SMARTCAST_IMPOSSIBLE] Smart cast to 'kotlin.String' is impossible, because 'x' is a member variable that can be changed from another thread">x</error>
return <error descr="[SMARTCAST_IMPOSSIBLE] Smart cast to 'kotlin.String' is impossible, because 'x' is a mutable property that could have been changed by this time">x</error>
}
if (xx is String) {
return <error descr="[SMARTCAST_IMPOSSIBLE] Smart cast to 'kotlin.String' is impossible, because 'xx' is a member value that has open or custom getter">xx</error>
return <error descr="[SMARTCAST_IMPOSSIBLE] Smart cast to 'kotlin.String' is impossible, because 'xx' is a property that has open or custom getter">xx</error>
}
return ""
}

View File

@@ -1,9 +0,0 @@
<node text="KClient.KClient() ()" base="true">
<node text="KA.KA()(2 usages) ()"/>
<node text="KA.foo(String) ()"/>
<node text="JA.JA()(2 usages) ()"/>
<node text="JA.getName() ()"/>
<node text="JA.foo(String) ()">
<node text="PrintStream.println(String) (java.io)"/>
</node>
</node>

View File

@@ -1,31 +0,0 @@
class KA {
KA() {
}
public final String name = "A";
public final String foo(String s) {
return "A " + s;
}
}
class KClientBase {
}
class KClient extends KClientBase {
public <caret>KClient() {
super();
new KA().foo(new KA().name);
new JA().foo(new JA().getName());
}
{
new KA().foo(new KA().name);
new JA().foo(new JA().getName());
}
public final void bar() {
new KA().foo(new KA().name);
new JA().foo(new JA().getName());
}
}

View File

@@ -1,8 +0,0 @@
open class JA() {
public var name: String = "A"
public open fun foo(s: String): String {
System.out.println(s)
return "A " + s
}
}

View File

@@ -1,18 +0,0 @@
<node text="KClient.bar() ()" base="true">
<node text="KA.KA()(2 usages) ()"/>
<node text="KA.foo(String)(2 usages) ()"/>
<node text="JA.JA()(4 usages) ()"/>
<node text="JA.getName()(2 usages) ()"/>
<node text="JA.foo(String)(2 usages) ()">
<node text="PrintStream.println(String) (java.io)"/>
</node>
<node text="Anonymous in bar() in KClient.run() ()">
<node text="KA.KA() ()"/>
<node text="KA.foo(String) ()"/>
<node text="JA.JA()(2 usages) ()"/>
<node text="JA.getName() ()"/>
<node text="JA.foo(String) ()">
<node text="PrintStream.println(String) (java.io)"/>
</node>
</node>
</node>

View File

@@ -1,25 +0,0 @@
class KA {
public KA() {
}
public final String name = "A";
public final String foo(String s) {
return "A " + s;
}
}
class KClient {
public final void <caret>bar() {
new KA().foo("");
new JA().foo(new JA().getName());
new Runnable() {
public void run() {
new KA().foo("");
new JA().foo(new JA().getName());
}
}.run();
}
}

View File

@@ -1,8 +0,0 @@
open class JA() {
public var name: String = "A"
public open fun foo(s: String): String {
System.out.println(s)
return "A " + s
}
}

View File

@@ -1,10 +0,0 @@
<node text="KA.KA() ()" base="true">
<node text="KClient.bar() ()"/>
<node text="KClient.getBar() ()"/>
<node text="KClient ()"/>
<node text="JA.JA() ()"/>
<node text="JA.newKA() ()"/>
<node text="JA ()"/>
<node text="JA.JA(Int) ()"/>
<node text="JA2 ()"/>
</node>

View File

@@ -1,27 +0,0 @@
class KA {
public <caret>KA() {
}
public final String name = "A";
public String foo(String s) {
return "A " + s;
}
}
class KClient {
{
new KA();
}
public static final a = new KA();
public final String getBar() {
return new KA().name;
}
public final KA bar() {
return new KA();
}
}

View File

@@ -1,19 +0,0 @@
open class JA: KA {
constructor() {
}
constructor(a: Int): super() {
}
public var name: String = KA().getName()
public open fun newKA(): KA? {
return KA()
}
}
class JA2: KA() {
}

View File

@@ -1,7 +0,0 @@
<node text="KA.foo(String) ()" base="true">
<node text="JA(2 usages) ()"/>
<node text="JA.foo()(2 usages) ()"/>
<node text="KClient(4 usages) ()"/>
<node text="KClient.bar()(2 usages) ()"/>
<node text="KClient.getBar()(2 usages) ()"/>
</node>

View File

@@ -1,31 +0,0 @@
class KBase {
public String foo(String s) {
return s;
}
}
class KA extends KBase {
public final String name = "A";
@Override
public final String <caret>foo(String s) {
return "A " + s;
}
}
class KClient {
{
new KBase().foo("");
new KA().foo("");
}
public static final String a = new KBase().foo("") + new KA().foo("");
public final String getBar() {
return new KBase().foo("") + new KA().foo("");
}
public final String bar() {
return new KBase().foo("") + new KA().foo("");
}
}

View File

@@ -1,7 +0,0 @@
open class JA() {
public var name: String = KBase().foo("") + KA().foo("")
public open fun foo(): String {
return KBase().foo("") + KA().foo("")
}
}

View File

@@ -1,12 +0,0 @@
<node text="A ()" base="true">
<node text="B ()"/>
<node text="T ()">
<node text="C ()"/>
<node text="Y ()"/>
</node>
<node text="X ()">
<node text="Z ()">
<node text="D ()"/>
</node>
</node>
</node>

View File

@@ -1,30 +0,0 @@
class A {
public void <caret>foo() {
}
}
class B extends A {
@Override
public void foo() {
}
}
class C implements T {
@Override
public void foo() {
}
}
class D extends Z {
@Override
public void foo() {
}
}
class S {
}

View File

@@ -1,27 +0,0 @@
interface T: A {
override fun foo() {
}
}
open class X: A() {
override fun foo() {
}
}
open class Y: T {
override fun foo() {
}
}
open class Z: X() {
override fun foo() {
}
}
class SS {
}

View File

@@ -1,12 +0,0 @@
<node text="A ()" base="true">
<node text="B ()"/>
<node text="T ()">
<node text="C ()"/>
<node text="Y ()"/>
</node>
<node text="X ()">
<node text="Z ()">
<node text="D ()"/>
</node>
</node>
</node>

View File

@@ -1,28 +0,0 @@
interface A {
public void <caret>foo();
}
class B implements A {
@Override
public void foo() {
}
}
class C implements T {
@Override
public void foo() {
}
}
class D extends Z {
@Override
public void foo() {
}
}
class S {
}

View File

@@ -1,27 +0,0 @@
interface T: A {
override fun foo() {
}
}
open class X: A {
override fun foo() {
}
}
open class Y: T {
override fun foo() {
}
}
open class Z: X() {
override fun foo() {
}
}
class SS {
}

View File

@@ -1 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnusedImportInspection
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.KotlinUnusedImportInspection

View File

@@ -1,7 +1,7 @@
package a
fun foo() {
<caret>assert(true, "text")
<caret>assert(true, { "text" })
}
class AssertionError

View File

@@ -1,4 +1,4 @@
// WITH_RUNTIME
fun foo() {
<caret>assert(true && false, "text")
<caret>assert(true && false, { "text" })
}

View File

@@ -1,4 +1,4 @@
// WITH_RUNTIME
fun foo() {
<caret>assert(1 > 0, "text")
<caret>assert(1 > 0) { "text" }
}

View File

@@ -1,4 +1,4 @@
// WITH_RUNTIME
fun foo() {
<caret>assert(0 != 1, "text")
<caret>assert(0 != 1) { "text" }
}

View File

@@ -2,5 +2,5 @@
fun foo() {
val x = true
val y = false
<caret>assert(x || y, "text")
<caret>assert(x || y) { "text" }
}

View File

@@ -1,5 +1,5 @@
fun main(args: Array<String>) {
asse<caret>rt(false, "mess" as kotlin.String)
asse<caret>rt(false) { "mess" as kotlin.String }
}
// WITH_RUNTIME

View File

@@ -1,4 +1,4 @@
// WITH_RUNTIME
fun foo() {
kotlin.<caret>assert(true, "text")
kotlin.<caret>assert(true) {"text"}
}

View File

@@ -1,6 +1,6 @@
// WITH_RUNTIME
fun foo() {
<caret>assert(bar(), "text")
<caret>assert(bar()) { "text" }
}
fun bar(): Boolean = true

View File

@@ -1,4 +1,6 @@
// WITH_RUNTIME
fun foo() {
<caret>assert(true, { "text" })
<caret>assert(true, {
if (true) "text" else return
})
}

View File

@@ -1,6 +1,6 @@
// WITH_RUNTIME
fun foo() {
if (!true) {
throw AssertionError({ "text" }())
throw AssertionError(if (true) "text" else return)
}
}

View File

@@ -1,4 +1,6 @@
// WITH_RUNTIME
fun foo() {
<caret>assert(true) { "text" }
<caret>assert(true) {
return
}
}

View File

@@ -1,6 +1,8 @@
// WITH_RUNTIME
fun foo() {
if (!true) {
throw AssertionError({ "text" }())
throw AssertionError({
return
}())
}
}

View File

@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun foo() {
<caret>assert(true, {
val value = 1
"text and $value"
})
}

View File

@@ -0,0 +1,9 @@
// WITH_RUNTIME
fun foo() {
if (!true) {
throw AssertionError({
val value = 1
"text and $value"
}())
}
}

View File

@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun foo() {
<caret>assert(true) {
if (false) return
"text"
}
}

View File

@@ -0,0 +1,9 @@
// WITH_RUNTIME
fun foo() {
if (!true) {
throw AssertionError({
if (false) return
"text"
}())
}
}

View File

@@ -1,4 +1,4 @@
// WITH_RUNTIME
fun foo() {
<caret>assert((true && false), "text")
<caret>assert((true && false)) { "text" }
}

View File

@@ -1,4 +1,4 @@
// WITH_RUNTIME
fun foo() {
<caret>assert(true, "text")
<caret>assert(true) { "text" }
}

View File

@@ -1,5 +1,5 @@
// WITH_RUNTIME
fun foo() {
val f = "text"
<caret>assert(true, f)
<caret>assert(true) { f }
}

View File

@@ -0,0 +1,9 @@
// "Replace with 'b()'" "true"
@Deprecated("b!", ReplaceWith("b()"), DeprecationLevel.ERROR)
fun a() {}
fun b() {}
fun usage() {
<caret>a()
}

View File

@@ -0,0 +1,9 @@
// "Replace with 'b()'" "true"
@Deprecated("b!", ReplaceWith("b()"), DeprecationLevel.ERROR)
fun a() {}
fun b() {}
fun usage() {
<caret>b()
}

View File

@@ -0,0 +1,20 @@
// "Replace usages of 'contains(String) on C: Boolean' in whole project" "true"
class C
@Deprecated("", ReplaceWith("checkContains(s)"))
operator fun C.contains(s: String) = true
fun C.checkContains(s: String) = true
fun f(c: C) {
if ("" <caret>!in c) {
}
}
fun g(c: C) {
if ("" in c) {
}
}

View File

@@ -0,0 +1,20 @@
// "Replace usages of 'contains(String) on C: Boolean' in whole project" "true"
class C
@Deprecated("", ReplaceWith("checkContains(s)"))
operator fun C.contains(s: String) = true
fun C.checkContains(s: String) = true
fun f(c: C) {
if (!c.checkContains("")) {
}
}
fun g(c: C) {
if (c.checkContains("")) {
}
}

View File

@@ -0,0 +1,12 @@
// "Replace with 'add(c)'" "true"
class C
@Deprecated("", ReplaceWith("add(c)"))
operator fun C.plus(c: C) = C()
fun C.add(c: C) = C()
fun f() {
var c1 = C()
c1 <caret>+= C()
}

View File

@@ -0,0 +1,12 @@
// "Replace with 'add(c)'" "true"
class C
@Deprecated("", ReplaceWith("add(c)"))
operator fun C.plus(c: C) = C()
fun C.add(c: C) = C()
fun f() {
var c1 = C()
c1 = c1.add(C())
}

View File

@@ -1 +1 @@
org.jetbrains.kotlin.idea.inspections.UnusedImportInspection
org.jetbrains.kotlin.idea.inspections.KotlinUnusedImportInspection

View File

@@ -71,13 +71,13 @@ public abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTest
setTestDataPath("${KotlinTestUtils.getHomeDirectory()}/$srcDir")
val afterFiles = srcDir.listFiles { it.name == "inspectionData" }?.single()?.listFiles { it.extension == "after" } ?: emptyArray()
val psiFiles = srcDir.walkTopDown().filter { it.name != "inspectionData" }.map {
val psiFiles = srcDir.walkTopDown().treeFilter { it.name != "inspectionData" }.map {
file ->
if (file.isDirectory) {
null
}
else if (file.extension != "kt") {
val filePath = file.getPath().substringAfter(srcDir.getPath()).replace("\\", "/")
val filePath = file.relativeTo(srcDir).replace('\\', '/')
configureByFile(filePath)
}
else {
@@ -86,10 +86,10 @@ public abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTest
if (text.startsWith("package"))
text
else
"package ${file.getName().removeSuffix(".kt")};$text"
configureByText(file.getName(), fileText)!!
"package ${file.nameWithoutExtension};$text"
configureByText(file.name, fileText)!!
}
}.filterNotNull().toArrayList()
}.filterNotNull().toList()
val isJs = srcDir.endsWith("js")

View File

@@ -202,8 +202,14 @@ public abstract class AbstractHierarchyTest extends KotlinHierarchyViewTestBase
super.doHierarchyTest(treeStructureComputable, fileNames);
}
catch (RefactoringErrorHintException e) {
String expectedMessage = FileUtil.loadFile(new File(folderName, "messages.txt"), true);
assertEquals(expectedMessage, e.getLocalizedMessage());
File file = new File(folderName, "messages.txt");
if (file.exists()) {
String expectedMessage = FileUtil.loadFile(file, true);
assertEquals(expectedMessage, e.getLocalizedMessage());
}
else {
fail("Unexpected error: " + e.getLocalizedMessage());
}
}
}

View File

@@ -286,18 +286,6 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/hierarchy/calls/callers"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("javaConstructor")
public void testJavaConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/javaConstructor/");
doCallerHierarchyTest(fileName);
}
@TestMetadata("javaMethod")
public void testJavaMethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/javaMethod/");
doCallerHierarchyTest(fileName);
}
@TestMetadata("kotlinClass")
public void testKotlinClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/kotlinClass/");
@@ -421,18 +409,6 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/hierarchy/calls/callees"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("javaConstructor")
public void testJavaConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callees/javaConstructor/");
doCalleeHierarchyTest(fileName);
}
@TestMetadata("javaMethod")
public void testJavaMethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callees/javaMethod/");
doCalleeHierarchyTest(fileName);
}
@TestMetadata("kotlinAnonymousObject")
public void testKotlinAnonymousObject() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callees/kotlinAnonymousObject/");
@@ -520,18 +496,6 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/hierarchy/overrides"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("javaMethodInClass")
public void testJavaMethodInClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/overrides/javaMethodInClass/");
doOverrideHierarchyTest(fileName);
}
@TestMetadata("javaMethodInInterface")
public void testJavaMethodInInterface() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/overrides/javaMethodInInterface/");
doOverrideHierarchyTest(fileName);
}
@TestMetadata("kotlinFunctionInClass")
public void testKotlinFunctionInClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/overrides/kotlinFunctionInClass/");

View File

@@ -3088,6 +3088,18 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("lambdaMultiStatementMessageInsideParentheses.kt")
public void testLambdaMultiStatementMessageInsideParentheses() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageInsideParentheses.kt");
doTest(fileName);
}
@TestMetadata("lambdaMultiStatementMessageOutsideParentheses.kt")
public void testLambdaMultiStatementMessageOutsideParentheses() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertAssertToIf/lambdaMultiStatementMessageOutsideParentheses.kt");
doTest(fileName);
}
@TestMetadata("lambdaVariable.kt")
public void testLambdaVariable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertAssertToIf/lambdaVariable.kt");

View File

@@ -3163,6 +3163,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
doTest(fileName);
}
@TestMetadata("deprecationLevel.kt")
public void testDeprecationLevel() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/deprecationLevel.kt");
doTest(fileName);
}
@TestMetadata("doNotShortenUserReferences.kt")
public void testDoNotShortenUserReferences() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/doNotShortenUserReferences.kt");
@@ -3724,6 +3730,27 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
}
}
@TestMetadata("idea/testData/quickfix/deprecatedSymbolUsage/operatorCalls")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class OperatorCalls extends AbstractQuickFixTest {
public void testAllFilesPresentInOperatorCalls() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/deprecatedSymbolUsage/operatorCalls"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}
@TestMetadata("in.kt")
public void testIn() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/operatorCalls/in.kt");
doTest(fileName);
}
@TestMetadata("plusAssign.kt")
public void testPlusAssign() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/operatorCalls/plusAssign.kt");
doTest(fileName);
}
}
@TestMetadata("idea/testData/quickfix/deprecatedSymbolUsage/optionalParameters")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -83,7 +83,7 @@ abstract class Element {
public var createdAt: String?
= if (saveCreationStacktraces)
Exception().getStackTrace().joinToString("\n")
Exception().stackTrace.joinToString("\n")
else
null

View File

@@ -70,7 +70,7 @@ public class CompilerRunnerUtil {
}
@Nullable
public static Object invokeExecMethod(
public synchronized static Object invokeExecMethod(
@NotNull String compilerClassName,
@NotNull String[] arguments,
@NotNull CompilerEnvironment environment,

View File

@@ -112,8 +112,9 @@ public object KotlinCompilerRunner {
val stream = ByteArrayOutputStream()
val out = PrintStream(stream)
if (System.getProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY) == null)
System.setProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY, "")
// Uncomment after resolving problems with parallel compilation and tests
// if (System.getProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY) == null)
// System.setProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY, "")
val rc = CompilerRunnerUtil.invokeExecMethod(compilerClassName, argsArray, environment, messageCollector, out)

View File

@@ -53,7 +53,7 @@ fun getDirectoryString(dir: File, interestingPaths: List<String>): String {
val listFiles = dir.listFiles()
assertNotNull(listFiles)
val children = listFiles!!.sortedWith(compareBy ({ it.directory }, { it.name } ))
val children = listFiles!!.sortedWith(compareBy ({ it.isDirectory }, { it.name } ))
for (child in children) {
if (child.isDirectory()) {
p.println(child.name)

View File

@@ -12,4 +12,4 @@ Compiling files:
src/usage.kt
End of files
COMPILATION FAILED
Smart cast to 'kotlin.Int' is impossible, because 'a.x' is a member value that has open or custom getter
Smart cast to 'kotlin.Int' is impossible, because 'a.x' is a property that has open or custom getter

View File

@@ -6,7 +6,7 @@ Compiling files:
src/usage.kt
End of files
COMPILATION FAILED
Smart cast to 'kotlin.Int' is impossible, because 'a.x' is a member value that has open or custom getter
Smart cast to 'kotlin.Int' is impossible, because 'a.x' is a property that has open or custom getter
Cleaning output files:

View File

@@ -110,7 +110,7 @@ public class Regex(pattern: String, options: Set<RegexOption>) {
* replacement for that match.
*/
public inline fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String {
var match = match(input)
var match = find(input)
if (match == null) return input.toString()
var lastStart = 0
@@ -148,7 +148,7 @@ public class Regex(pattern: String, options: Set<RegexOption>) {
*/
public fun split(input: CharSequence, limit: Int = 0): List<String> {
require(limit >= 0, { "Limit must be non-negative, but was $limit" } )
val matches = matchAll(input).let { if (limit == 0) it else it.take(limit - 1) }
val matches = findAll(input).let { if (limit == 0) it else it.take(limit - 1) }
val result = ArrayList<String>()
var lastStart = 0

View File

@@ -10600,7 +10600,6 @@ public fun BooleanArray.asList(): List<Boolean> {
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Boolean): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Boolean> = this@asList.iterator() as MutableIterator<Boolean>
override fun get(index: Int): Boolean = this@asList[index]
override fun indexOf(o: Boolean): Int = this@asList.indexOf(o)
override fun lastIndexOf(o: Boolean): Int = this@asList.lastIndexOf(o)
@@ -10616,7 +10615,6 @@ public fun ByteArray.asList(): List<Byte> {
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Byte): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Byte> = this@asList.iterator() as MutableIterator<Byte>
override fun get(index: Int): Byte = this@asList[index]
override fun indexOf(o: Byte): Int = this@asList.indexOf(o)
override fun lastIndexOf(o: Byte): Int = this@asList.lastIndexOf(o)
@@ -10632,7 +10630,6 @@ public fun CharArray.asList(): List<Char> {
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Char): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Char> = this@asList.iterator() as MutableIterator<Char>
override fun get(index: Int): Char = this@asList[index]
override fun indexOf(o: Char): Int = this@asList.indexOf(o)
override fun lastIndexOf(o: Char): Int = this@asList.lastIndexOf(o)
@@ -10648,7 +10645,6 @@ public fun DoubleArray.asList(): List<Double> {
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Double): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Double> = this@asList.iterator() as MutableIterator<Double>
override fun get(index: Int): Double = this@asList[index]
override fun indexOf(o: Double): Int = this@asList.indexOf(o)
override fun lastIndexOf(o: Double): Int = this@asList.lastIndexOf(o)
@@ -10664,7 +10660,6 @@ public fun FloatArray.asList(): List<Float> {
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Float): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Float> = this@asList.iterator() as MutableIterator<Float>
override fun get(index: Int): Float = this@asList[index]
override fun indexOf(o: Float): Int = this@asList.indexOf(o)
override fun lastIndexOf(o: Float): Int = this@asList.lastIndexOf(o)
@@ -10680,7 +10675,6 @@ public fun IntArray.asList(): List<Int> {
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Int): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Int> = this@asList.iterator() as MutableIterator<Int>
override fun get(index: Int): Int = this@asList[index]
override fun indexOf(o: Int): Int = this@asList.indexOf(o)
override fun lastIndexOf(o: Int): Int = this@asList.lastIndexOf(o)
@@ -10696,7 +10690,6 @@ public fun LongArray.asList(): List<Long> {
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Long): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Long> = this@asList.iterator() as MutableIterator<Long>
override fun get(index: Int): Long = this@asList[index]
override fun indexOf(o: Long): Int = this@asList.indexOf(o)
override fun lastIndexOf(o: Long): Int = this@asList.lastIndexOf(o)
@@ -10712,7 +10705,6 @@ public fun ShortArray.asList(): List<Short> {
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Short): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Short> = this@asList.iterator() as MutableIterator<Short>
override fun get(index: Int): Short = this@asList[index]
override fun indexOf(o: Short): Int = this@asList.indexOf(o)
override fun lastIndexOf(o: Short): Int = this@asList.lastIndexOf(o)

View File

@@ -6,7 +6,7 @@ package kotlin
import java.io.Serializable
import java.util.*
private object EmptyMap : Map<Any, Nothing>, Serializable {
private object EmptyMap : Map<Any?, Nothing>, Serializable {
override fun equals(other: Any?): Boolean = other is Map<*,*> && other.isEmpty()
override fun hashCode(): Int = 0
override fun toString(): String = "{}"
@@ -14,11 +14,11 @@ private object EmptyMap : Map<Any, Nothing>, Serializable {
override val size: Int get() = 0
override fun isEmpty(): Boolean = true
override fun containsKey(key: Any): Boolean = false
override fun containsKey(key: Any?): Boolean = false
override fun containsValue(value: Nothing): Boolean = false
override fun get(key: Any): Nothing? = null
override val entries: Set<Map.Entry<Any, Nothing>> get() = EmptySet
override val keys: Set<Any> get() = EmptySet
override fun get(key: Any?): Nothing? = null
override val entries: Set<Map.Entry<Any?, Nothing>> get() = EmptySet
override val keys: Set<Any?> get() = EmptySet
override val values: Collection<Nothing> get() = EmptyList
private fun readResolve(): Any = EmptyMap

View File

@@ -14,13 +14,19 @@ import java.util.concurrent.ConcurrentMap
* Allows to use the index operator for storing values in a mutable map.
*/
// this code is JVM-specific, because JS has native set function
public operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): V? = put(key, value)
public operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit {
put(key, value)
}
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
@JvmName("set")
public fun <K, V> MutableMap<K, V>.set(key: K, value: V): V? = put(key, value)
/**
* getOrPut is not supported on [ConcurrentMap] since it cannot be implemented correctly in terms of concurrency.
* Use [concurrentGetOrPut] instead, or cast this to a [MutableMap] if you want to sacrifice the concurrent-safety.
*/
@Deprecated("Use concurrentGetOrPut instead or cast this map to MutableMap.")
@Deprecated("Use concurrentGetOrPut instead or cast this map to MutableMap.", level = DeprecationLevel.ERROR)
public inline fun <K, V> ConcurrentMap<K, V>.getOrPut(key: K, defaultValue: () -> V): Nothing =
throw UnsupportedOperationException("getOrPut is not supported on ConcurrentMap.")

View File

@@ -61,10 +61,7 @@ public fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStrea
* @param bufferSize the buffer size to use.
*/
public fun InputStream.buffered(bufferSize: Int = defaultBufferSize): InputStream
= if (this is BufferedInputStream)
this
else
BufferedInputStream(this, bufferSize)
= if (this is BufferedInputStream) this else BufferedInputStream(this, bufferSize)
/** Creates a reader on this input stream using UTF-8 or the specified [charset]. */
public fun InputStream.reader(charset: Charset = Charsets.UTF_8): InputStreamReader = InputStreamReader(this, charset)

View File

@@ -48,12 +48,6 @@ public fun String.reader(): StringReader = StringReader(this)
*/
public fun BufferedReader.lineSequence(): Sequence<String> = LinesSequence(this).constrainOnce()
@Deprecated("Use lineSequence() instead to avoid conflict with JDK8 lines() method.", ReplaceWith("lineSequence()"))
public fun BufferedReader.lines(): Sequence<String> = lineSequence()
@Deprecated("Use lineSequence() function which returns Sequence<String>")
public fun BufferedReader.lineIterator(): Iterator<String> = lineSequence().iterator()
private class LinesSequence(private val reader: BufferedReader) : Sequence<String> {
override public fun iterator(): Iterator<String> {
return object : Iterator<String> {

Some files were not shown because too many files have changed in this diff Show More