diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index d43d15c9310..8d4f5341a7e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -217,6 +217,9 @@ public interface Errors { DiagnosticFactory0 DEPRECATED_CLASS_OBJECT_SYNTAX = DiagnosticFactory0.create(WARNING); + DiagnosticFactory1 DEPRECATED_SYMBOL = DiagnosticFactory1.create(WARNING); + DiagnosticFactory2 DEPRECATED_SYMBOL_WITH_MESSAGE = DiagnosticFactory2.create(WARNING); + // Objects DiagnosticFactory1 LOCAL_OBJECT_NOT_ALLOWED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 51c849847b4..2de073349f3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -252,6 +252,8 @@ public class DefaultErrorMessages { MAP.put(COMPANION_OBJECT_NOT_ALLOWED, "A companion object is not allowed here"); MAP.put(DEPRECATED_CLASS_OBJECT_SYNTAX, "'class object' syntax for companion objects was deprecated. Use 'companion' modifier instead"); + MAP.put(DEPRECATED_SYMBOL, "''{0}'' is deprecated.", DEPRECATION); + MAP.put(DEPRECATED_SYMBOL_WITH_MESSAGE, "''{0}'' is deprecated. {1}", DEPRECATION, STRING); MAP.put(LOCAL_OBJECT_NOT_ALLOWED, "Named object ''{0}'' is a singleton and cannot be local. Try to use anonymous object instead", NAME); MAP.put(LOCAL_ENUM_NOT_ALLOWED, "Enum class ''{0}'' cannot be local", NAME); diff --git a/compiler/testData/diagnostics/tests/deprecated/annotationUsage.kt b/compiler/testData/diagnostics/tests/deprecated/annotationUsage.kt new file mode 100644 index 00000000000..1a32023af17 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/annotationUsage.kt @@ -0,0 +1,9 @@ +deprecated("text") +annotation class obsolete() + +deprecated("text") +annotation class obsoleteWithParam(val text: String) + +obsolete class Obsolete + +obsoleteWithParam("text") class Obsolete2 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/annotationUsage.txt b/compiler/testData/diagnostics/tests/deprecated/annotationUsage.txt new file mode 100644 index 00000000000..7e989575d55 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/annotationUsage.txt @@ -0,0 +1,30 @@ +package + +obsolete() internal final class Obsolete { + public constructor Obsolete() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +obsoleteWithParam(text = "text": kotlin.String) internal final class Obsolete2 { + public constructor Obsolete2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.deprecated(value = "text": kotlin.String) internal final annotation class obsolete : kotlin.Annotation { + public constructor obsolete() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.deprecated(value = "text": kotlin.String) internal final annotation class obsoleteWithParam : kotlin.Annotation { + public constructor obsoleteWithParam(/*0*/ text: kotlin.String) + internal final val text: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/deprecated/componentUsage.kt b/compiler/testData/diagnostics/tests/deprecated/componentUsage.kt new file mode 100644 index 00000000000..05533ef6d7a --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/componentUsage.kt @@ -0,0 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE + +class Data { + deprecated("text") + fun component1(): String = throw Exception() + fun component2(): String = throw Exception() +} + +fun use() { + val (x, y) = Data() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/componentUsage.txt b/compiler/testData/diagnostics/tests/deprecated/componentUsage.txt new file mode 100644 index 00000000000..aad36da72f5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/componentUsage.txt @@ -0,0 +1,12 @@ +package + +internal fun use(): kotlin.Unit + +internal final class Data { + public constructor Data() + kotlin.deprecated(value = "text": kotlin.String) internal final fun component1(): kotlin.String + internal final fun component2(): kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/deprecated/functionUsage.kt b/compiler/testData/diagnostics/tests/deprecated/functionUsage.kt new file mode 100644 index 00000000000..79a174abf47 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/functionUsage.kt @@ -0,0 +1,49 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION, -REFLECTION_TYPES_NOT_LOADED + +class UsefulClass(val param: Int = 2) { + fun get(instance: Any, property: PropertyMetadata) : Int = 1 + fun set(instance: Any, property: PropertyMetadata, value: Int) {} + + deprecated("message") + fun member() {} +} + +deprecated("message") +fun Obsolete(param: Int = 1): UsefulClass = UsefulClass(param) + +class Invocable { + deprecated("message") + fun invoke() {} +} + +object InvocableHolder { + val invocable = Invocable() +} + +fun invoker() { + val invocable = Invocable() + invocable() + InvocableHolder.invocable() +} + +fun block() { + Obsolete() + Obsolete(2) +} + +fun expression() = Obsolete() + +fun reflection() = ::Obsolete +fun reflection2() = UsefulClass::member + +class Initializer { + val x = Obsolete() +} + +deprecated("does nothing good") +fun Any.doNothing() = this.toString() // "this" should not be marked as deprecated despite it referes to deprecated function + +class Delegation { + val x by Obsolete() + var y by Obsolete() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/functionUsage.txt b/compiler/testData/diagnostics/tests/deprecated/functionUsage.txt new file mode 100644 index 00000000000..82555499bd9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/functionUsage.txt @@ -0,0 +1,53 @@ +package + +kotlin.deprecated(value = "message": kotlin.String) internal fun Obsolete(/*0*/ param: kotlin.Int = ...): UsefulClass +internal fun block(): kotlin.Unit +internal fun expression(): UsefulClass +internal fun invoker(): kotlin.Unit +internal fun reflection(): [ERROR : Error function type] +internal fun reflection2(): [ERROR : Error function type] +kotlin.deprecated(value = "does nothing good": kotlin.String) internal fun kotlin.Any.doNothing(): kotlin.String + +internal final class Delegation { + public constructor Delegation() + internal final val x: kotlin.Int + internal final var y: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class Initializer { + public constructor Initializer() + internal final val x: UsefulClass + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class Invocable { + public constructor Invocable() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + kotlin.deprecated(value = "message": kotlin.String) internal final fun invoke(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal object InvocableHolder { + private constructor InvocableHolder() + internal final val invocable: Invocable + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class UsefulClass { + public constructor UsefulClass(/*0*/ param: kotlin.Int = ...) + internal final val param: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal final fun get(/*0*/ instance: kotlin.Any, /*1*/ property: kotlin.PropertyMetadata): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + kotlin.deprecated(value = "message": kotlin.String) internal final fun member(): kotlin.Unit + internal final fun set(/*0*/ instance: kotlin.Any, /*1*/ property: kotlin.PropertyMetadata, /*2*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/deprecated/imports.kt b/compiler/testData/diagnostics/tests/deprecated/imports.kt new file mode 100644 index 00000000000..03ddee7041d --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/imports.kt @@ -0,0 +1,8 @@ +import C as C2 + +deprecated("obsolete") +class C { + fun use() {} +} + +fun useAlias(c : C2) { c.use() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/imports.txt b/compiler/testData/diagnostics/tests/deprecated/imports.txt new file mode 100644 index 00000000000..4475e9ca7b8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/imports.txt @@ -0,0 +1,11 @@ +package + +internal fun useAlias(/*0*/ c: C): kotlin.Unit + +kotlin.deprecated(value = "obsolete": kotlin.String) internal final class C { + public constructor C() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal final fun use(): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/deprecated/iteratorUsage.kt b/compiler/testData/diagnostics/tests/deprecated/iteratorUsage.kt new file mode 100644 index 00000000000..a964e695947 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/iteratorUsage.kt @@ -0,0 +1,24 @@ +class Iter { + deprecated("text") + fun iterator() : IterIterator = throw Exception() + + class IterIterator { + fun hasNext(): Boolean = throw UnsupportedOperationException() + fun next(): String = throw UnsupportedOperationException() + } +} + +class Iter2 { + fun iterator() : Iter2Iterator = throw Exception() + class Iter2Iterator { + deprecated("text") + fun hasNext(): Boolean = throw UnsupportedOperationException() + deprecated("text") + fun next(): String = throw UnsupportedOperationException() + } +} + +fun use() { + for (x in Iter()) {} + for (x in Iter2()) {} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/iteratorUsage.txt b/compiler/testData/diagnostics/tests/deprecated/iteratorUsage.txt new file mode 100644 index 00000000000..153a8b1c5ea --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/iteratorUsage.txt @@ -0,0 +1,37 @@ +package + +internal fun use(): kotlin.Unit + +internal final class Iter { + public constructor Iter() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + kotlin.deprecated(value = "text": kotlin.String) internal final fun iterator(): Iter.IterIterator + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + internal final class IterIterator { + public constructor IterIterator() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal final fun hasNext(): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + internal final fun next(): kotlin.String + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +internal final class Iter2 { + public constructor Iter2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + internal final fun iterator(): Iter2.Iter2Iterator + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + internal final class Iter2Iterator { + public constructor Iter2Iterator() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + kotlin.deprecated(value = "text": kotlin.String) internal final fun hasNext(): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + kotlin.deprecated(value = "text": kotlin.String) internal final fun next(): kotlin.String + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/deprecated/javaDeprecated.kt b/compiler/testData/diagnostics/tests/deprecated/javaDeprecated.kt new file mode 100644 index 00000000000..4ff1e8152ca --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/javaDeprecated.kt @@ -0,0 +1,16 @@ +// !DIAGNOSTICS: -NO_VALUE_FOR_PARAMETER +// FILE: A.java + +@Deprecated +public class A { + @Deprecated + public String getFoo(String text) { + return text; + } +} + +// FILE: B.kt + +class B(private [deprecated] val foo: String) : A() { + override fun getFoo(text: String): String = super.getFoo(text + foo) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/javaDeprecated.txt b/compiler/testData/diagnostics/tests/deprecated/javaDeprecated.txt new file mode 100644 index 00000000000..2cc812d515d --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/javaDeprecated.txt @@ -0,0 +1,18 @@ +package + +kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + kotlin.deprecated(value = "Deprecated in Java": kotlin.String) public open fun getFoo(/*0*/ text: kotlin.String!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class B : A { + public constructor B(/*0*/ kotlin.deprecated() foo: kotlin.String) + kotlin.deprecated() private final val foo: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun getFoo(/*0*/ text: kotlin.String): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/deprecated/nestedTypesUsage.kt b/compiler/testData/diagnostics/tests/deprecated/nestedTypesUsage.kt new file mode 100644 index 00000000000..9c10341ad81 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/nestedTypesUsage.kt @@ -0,0 +1,18 @@ +class TopLevel { + deprecated("Nested") + class Nested { + companion object { + fun use() {} + + class CompanionNested2 + } + + class Nested2 + } +} + +fun useNested() { + val d = TopLevel.Nested.use() + TopLevel.Nested.Nested2() + TopLevel.Nested.CompanionNested2() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/nestedTypesUsage.txt b/compiler/testData/diagnostics/tests/deprecated/nestedTypesUsage.txt new file mode 100644 index 00000000000..931136ddaa2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/nestedTypesUsage.txt @@ -0,0 +1,39 @@ +package + +internal fun useNested(): kotlin.Unit + +internal final class TopLevel { + public constructor TopLevel() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + kotlin.deprecated(value = "Nested": kotlin.String) internal final class Nested { + public constructor Nested() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + internal companion object Companion { + private constructor Companion() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal final fun use(): kotlin.Unit + + internal final class CompanionNested2 { + public constructor CompanionNested2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + internal final class Nested2 { + public constructor Nested2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } +} diff --git a/compiler/testData/diagnostics/tests/deprecated/objectUsage.kt b/compiler/testData/diagnostics/tests/deprecated/objectUsage.kt new file mode 100644 index 00000000000..0a6d0423e30 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/objectUsage.kt @@ -0,0 +1,27 @@ +deprecated("Object") +object Obsolete { + fun use() {} +} + +class Another { + deprecated("Object") + companion object { + fun use() {} + } +} + +fun first() { + Another.use() +} + +fun useObject() { + Obsolete.use() + val x = Obsolete +} + +fun useCompanion() { + val d = Another + val x = Another.Companion + Another.Companion.use() + Another.use() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/objectUsage.txt b/compiler/testData/diagnostics/tests/deprecated/objectUsage.txt new file mode 100644 index 00000000000..b519a08f6a5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/objectUsage.txt @@ -0,0 +1,28 @@ +package + +internal fun first(): kotlin.Unit +internal fun useCompanion(): kotlin.Unit +internal fun useObject(): kotlin.Unit + +internal final class Another { + public constructor Another() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + kotlin.deprecated(value = "Object": kotlin.String) internal companion object Companion { + private constructor Companion() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal final fun use(): kotlin.Unit + } +} + +kotlin.deprecated(value = "Object": kotlin.String) internal object Obsolete { + private constructor Obsolete() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal final fun use(): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/deprecated/propertyUsage.kt b/compiler/testData/diagnostics/tests/deprecated/propertyUsage.kt new file mode 100644 index 00000000000..6b4b08cd225 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/propertyUsage.kt @@ -0,0 +1,64 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION, -REFLECTION_TYPES_NOT_LOADED + +class Delegate() { + deprecated("text") + fun get(instance: Any, property: PropertyMetadata) : Int = 1 + + deprecated("text") + fun set(instance: Any, property: PropertyMetadata, value: Int) {} +} + +class PropertyHolder { + deprecated("text") + val x = 1 + + deprecated("text") + var name = "String" + + val valDelegate by Delegate() + var varDelegate by Delegate() + + public val test1: String = "" + [deprecated("val-getter")] get + + public var test2: String = "" + [deprecated("var-getter")] get + [deprecated("var-setter")] set + + public var test3: String = "" + [deprecated("var-getter")] get + set + + public var test4: String = "" + get + [deprecated("var-setter")] set +} + +fun PropertyHolder.extFunction() { + test2 = "ext" + test1 +} + +fun fn() { + PropertyHolder().test1 + PropertyHolder().test2 + PropertyHolder().test2 = "" + + PropertyHolder().test3 + PropertyHolder().test3 = "" + + PropertyHolder().test4 + PropertyHolder().test4 = "" + + val a = PropertyHolder().x + val b = PropertyHolder().name + PropertyHolder().name = "value" + + val d = PropertyHolder().valDelegate + PropertyHolder().varDelegate = 1 +} + +fun literals() { + PropertyHolder::test1 + PropertyHolder::name +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/propertyUsage.txt b/compiler/testData/diagnostics/tests/deprecated/propertyUsage.txt new file mode 100644 index 00000000000..a51da5efb3e --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/propertyUsage.txt @@ -0,0 +1,29 @@ +package + +internal fun fn(): kotlin.Unit +internal fun literals(): kotlin.Unit +internal fun PropertyHolder.extFunction(): kotlin.Unit + +internal final class Delegate { + public constructor Delegate() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + kotlin.deprecated(value = "text": kotlin.String) internal final fun get(/*0*/ instance: kotlin.Any, /*1*/ property: kotlin.PropertyMetadata): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + kotlin.deprecated(value = "text": kotlin.String) internal final fun set(/*0*/ instance: kotlin.Any, /*1*/ property: kotlin.PropertyMetadata, /*2*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class PropertyHolder { + public constructor PropertyHolder() + kotlin.deprecated(value = "text": kotlin.String) internal final var name: kotlin.String + public final val test1: kotlin.String = "" + public final var test2: kotlin.String + public final var test3: kotlin.String + public final var test4: kotlin.String + internal final val valDelegate: kotlin.Int + internal final var varDelegate: kotlin.Int + kotlin.deprecated(value = "text": kotlin.String) internal final val x: kotlin.Int = 1 + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/deprecated/typeUsage.kt b/compiler/testData/diagnostics/tests/deprecated/typeUsage.kt new file mode 100644 index 00000000000..a53c3b48d9e --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/typeUsage.kt @@ -0,0 +1,42 @@ +deprecated("Class") +open class Obsolete { + fun use() {} +} + +deprecated("Class") +open class Obsolete2 [deprecated("Constructor")]() { + fun use() {} +} + +trait Generic + +open class Derived() : Obsolete() + +class Derived2() : Derived() + +class TypeParam : Generic<Obsolete> + +object Object : Obsolete() + +class Properties { + val x : Obsolete = Obsolete() + var y : Obsolete = Obsolete() + + var n : Obsolete + get() = Obsolete() + set(value) {} +} + +fun param(param: Obsolete) { param.use() } + +fun funcParamReceiver(param: Obsolete.()->Unit) { Obsolete().param() } +fun funcParamParam(param: (Obsolete)->Unit) { param(Obsolete()) } +fun funcParamRetVal(param: ()->Obsolete) { param() } + +fun constraintObsolete>() {} + +fun Obsolete.receiver() {} + +fun retVal(): Obsolete = Obsolete() + +fun nullableRetVal(): Obsolete? = null \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/typeUsage.txt b/compiler/testData/diagnostics/tests/deprecated/typeUsage.txt new file mode 100644 index 00000000000..05823c4d785 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/typeUsage.txt @@ -0,0 +1,73 @@ +package + +internal fun constraint(): kotlin.Unit +internal fun funcParamParam(/*0*/ param: (Obsolete) -> kotlin.Unit): kotlin.Unit +internal fun funcParamReceiver(/*0*/ param: Obsolete.() -> kotlin.Unit): kotlin.Unit +internal fun funcParamRetVal(/*0*/ param: () -> Obsolete): kotlin.Unit +internal fun nullableRetVal(): Obsolete? +internal fun param(/*0*/ param: Obsolete): kotlin.Unit +internal fun retVal(): Obsolete +internal fun Obsolete.receiver(): kotlin.Unit + +internal open class Derived : Obsolete { + public constructor Derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal final override /*1*/ /*fake_override*/ fun use(): kotlin.Unit +} + +internal final class Derived2 : Derived { + public constructor Derived2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal final override /*1*/ /*fake_override*/ fun use(): kotlin.Unit +} + +internal trait Generic { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal object Object : Obsolete { + private constructor Object() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal final override /*1*/ /*fake_override*/ fun use(): kotlin.Unit +} + +kotlin.deprecated(value = "Class": kotlin.String) internal open class Obsolete { + public constructor Obsolete() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal final fun use(): kotlin.Unit +} + +kotlin.deprecated(value = "Class": kotlin.String) internal open class Obsolete2 { + kotlin.deprecated(value = "Constructor": kotlin.String) public constructor Obsolete2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal final fun use(): kotlin.Unit +} + +internal final class Properties { + public constructor Properties() + internal final var n: Obsolete + internal final val x: Obsolete + internal final var y: Obsolete + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class TypeParam : Generic { + public constructor TypeParam() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/spreadOperator.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/spreadOperator.kt index 5df9a2e7f84..14973af327e 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/spreadOperator.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/spreadOperator.kt @@ -1,5 +1,5 @@ fun test(d: dynamic) { - val a = array(1, 2, 3) + val a = arrayOf(1, 2, 3) d.foo(*d) d.foo(*a) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.kt index 5e0d0cd767b..230be569b65 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.kt @@ -1,10 +1,10 @@ annotation class Ann(val i: IntArray) -Ann(intArray(i)) -Ann(intArray(i2)) -Ann(intArray(i3)) -Ann(intArray(i, i2, i3)) -Ann(intArray(intArray(i, i2, i3))) +Ann(intArrayOf(i)) +Ann(intArrayOf(i2)) +Ann(intArrayOf(i3)) +Ann(intArrayOf(i, i2, i3)) +Ann(intArrayOf(intArrayOf(i, i2, i3))) class Test var i = 1 @@ -14,13 +14,13 @@ val i3 = foo() fun foo(): Int = 1 annotation class AnnJC(val i: Array>) -AnnJC(array(javaClass())) -AnnJC(array(iJC)) +AnnJC(arrayOf(javaClass())) +AnnJC(arrayOf(iJC)) class TestJC val iJC = javaClass() annotation class AnnAnn(val i: Array) -AnnAnn(array(Ann(intArray(1)))) -AnnAnn(array(iAnn)) +AnnAnn(arrayOf(Ann(intArrayOf(1)))) +AnnAnn(arrayOf(iAnn)) class TestAnn -val iAnn = Ann(intArray(1)) \ No newline at end of file +val iAnn = Ann(intArrayOf(1)) \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt index 33cd20e8a2d..356f62aac1e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt @@ -21,7 +21,7 @@ class MyClass { val i = 1 } -val ia: IntArray = intArray(1, 2) -val sa: Array = array("a", "b") +val ia: IntArray = intArrayOf(1, 2) +val sa: Array = arrayOf("a", "b") annotation class Ann2 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.kt index d2666588b81..26f8646b57b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.kt @@ -4,10 +4,10 @@ Ann(i) Ann(i2) Ann(i3) Ann(i, i2, i3) -Ann(*intArray(i)) -Ann(*intArray(i2)) -Ann(*intArray(i3)) -Ann(*intArray(i, i2, i3)) +Ann(*intArrayOf(i)) +Ann(*intArrayOf(i2)) +Ann(*intArrayOf(i3)) +Ann(*intArrayOf(i, i2, i3)) class Test var i = 1 @@ -17,13 +17,13 @@ val i3 = foo() fun foo(): Int = 1 annotation class AnnJC(vararg val i: Class<*>) -AnnJC(*array(javaClass())) -AnnJC(*array(iJC)) +AnnJC(*arrayOf(javaClass())) +AnnJC(*arrayOf(iJC)) class TestJC val iJC = javaClass() annotation class AnnAnn(vararg val i: Ann) -AnnAnn(*array(Ann(1))) -AnnAnn(*array(iAnn)) +AnnAnn(*arrayOf(Ann(1))) +AnnAnn(*arrayOf(iAnn)) class TestAnn val iAnn = Ann(1) \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/javaClassArrayInAnnotations.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/javaClassArrayInAnnotations.kt index ab3eab07cbc..c13add5e5bf 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/javaClassArrayInAnnotations.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/javaClassArrayInAnnotations.kt @@ -7,20 +7,20 @@ public @interface A { // FILE: b.kt A(javaClass(), javaClass(), -arg = array(javaClass(), javaClass())) +arg = arrayOf(javaClass(), javaClass())) class MyClass1 A(javaClass(), javaClass()) class MyClass2 -A(arg = array(javaClass(), javaClass())) +A(arg = arrayOf(javaClass(), javaClass())) class MyClass3 A class MyClass4 -A(value = *array(javaClass(), javaClass()), -arg = array(javaClass(), javaClass())) +A(value = *arrayOf(javaClass(), javaClass()), +arg = arrayOf(javaClass(), javaClass())) class MyClass5 -A(value = *array(javaClass(), javaClass())) +A(value = *arrayOf(javaClass(), javaClass())) class MyClass6 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.kt index f577a8a8276..0534715242f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.kt @@ -10,13 +10,13 @@ public @interface A { [A("4", y = 2)] fun test2() {} -[A(*array("5", "6"), "7", y = 3)] fun test3() {} +[A(*arrayOf("5", "6"), "7", y = 3)] fun test3() {} [A("1", "2", "3", x = String::class, y = 4)] fun test4() {} [A("4", y = 5)] fun test5() {} -[A(*array("5", "6"), "7", x = Any::class, y = 6)] fun test6() {} +[A(*arrayOf("5", "6"), "7", x = Any::class, y = 6)] fun test6() {} [A(y = 7)] fun test7() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.kt index 6849ebe61e8..0ba7da64a84 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.kt @@ -10,18 +10,18 @@ public @interface A { [A("4")] fun test2() {} -[A(*array("5", "6"), "7")] fun test3() {} +[A(*arrayOf("5", "6"), "7")] fun test3() {} [A("1", "2", "3", x = String::class)] fun test4() {} [A("4", y = 2)] fun test5() {} -[A(*array("5", "6"), "7", x = Any::class, y = 3)] fun test6() {} +[A(*arrayOf("5", "6"), "7", x = Any::class, y = 3)] fun test6() {} [A()] fun test7() {} [A] fun test8() {} -[A(x = Any::class, *array("5", "6"), "7", y = 3)] fun test9() {} -[A(x = Any::class, value = *array("5", "6"), "7", y = 3)] fun test10() {} -[A(x = Any::class, value = *array("5", "6", "7"), y = 3)] fun test11() {} +[A(x = Any::class, *arrayOf("5", "6"), "7", y = 3)] fun test9() {} +[A(x = Any::class, value = *arrayOf("5", "6"), "7", y = 3)] fun test10() {} +[A(x = Any::class, value = *arrayOf("5", "6", "7"), y = 3)] fun test11() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayOnly.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayOnly.kt index a0d9dbeb350..821108cb093 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayOnly.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayOnly.kt @@ -8,7 +8,7 @@ public @interface A { [A("4")] fun test2() {} -[A(*array("5", "6"), "7")] fun test3() {} +[A(*arrayOf("5", "6"), "7")] fun test3() {} [A()] fun test4() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayWithDefault.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayWithDefault.kt index 4c4f1297b8d..838cfc73f3a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayWithDefault.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayWithDefault.kt @@ -8,7 +8,7 @@ public @interface A { [A("4")] fun test2() {} -[A(*array("5", "6"), "7")] fun test3() {} +[A(*arrayOf("5", "6"), "7")] fun test3() {} [A()] fun test4() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt index b8e7bcc6938..6417c8e6dd5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt @@ -4,6 +4,6 @@ public @interface A { } // FILE: b.kt -[A(*; IGNORE)!>array(1, "b"))] +[A(*; IGNORE)!>arrayOf(1, "b"))] fun test() { } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt index a72671f5871..62b21774167 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt @@ -1,5 +1,5 @@ annotation class B(vararg val args: String) -[B(*; IGNORE)!>array(1, "b"))] +[B(*; IGNORE)!>arrayOf(1, "b"))] fun test() { } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.kt index cee01593203..ebb85dc60c4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.kt @@ -6,7 +6,7 @@ public @interface A { // FILE: b.kt -A(arg = array(javaClass(), javaClass())) class MyClass1 +A(arg = arrayOf(javaClass(), javaClass())) class MyClass1 -A(arg = array(javaClass(), Int::class)) class MyClass2 -A(arg = array(String::class, javaClass())) class MyClass3 +A(arg = arrayOf(javaClass(), Int::class)) class MyClass2 +A(arg = arrayOf(String::class, javaClass())) class MyClass3 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.kt index 9f8f2fc41eb..a3fda678725 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.kt @@ -7,9 +7,9 @@ public @interface A { // FILE: b.kt A(javaClass(), javaClass()) class MyClass1 -A(*array(javaClass(), javaClass())) class MyClass2 +A(*arrayOf(javaClass(), javaClass())) class MyClass2 -A(value = *array(javaClass(), javaClass())) class MyClass3 +A(value = *arrayOf(javaClass(), javaClass())) class MyClass3 A(javaClass(), Int::class) class MyClass4 A(String::class, javaClass()) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.kt index daa0894b1f7..13d59e70e01 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.kt @@ -4,4 +4,4 @@ public @interface A { } // FILE: b.kt -A(arg = array(String::class, Int::class)) class MyClass +A(arg = arrayOf(String::class, Int::class)) class MyClass diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.kt index 68d6931f2f9..e2c02010f11 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.kt @@ -5,5 +5,5 @@ public @interface A { // FILE: b.kt A(String::class, Int::class) class MyClass1 -A(*array(String::class, Int::class)) class MyClass2 -A(value = *array(String::class, Int::class)) class MyClass3 +A(*arrayOf(String::class, Int::class)) class MyClass2 +A(value = *arrayOf(String::class, Int::class)) class MyClass3 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt index fe6eb6cf697..3c135ad0b86 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt @@ -6,22 +6,22 @@ class B2 : A() annotation class Ann1(val arg: Array>) -Ann1(array(A::class)) +Ann1(arrayOf(A::class)) class MyClass1 -Ann1(array(Any::class)) +Ann1(arrayOf(Any::class)) class MyClass1a -Ann1(array(B1::class)) +Ann1(arrayOf(B1::class)) class MyClass2 annotation class Ann2(val arg: Array>) -Ann2(array(A::class)) +Ann2(arrayOf(A::class)) class MyClass3 -Ann2(array(B1::class)) +Ann2(arrayOf(B1::class)) class MyClass4 -Ann2(array(B2::class)) +Ann2(arrayOf(B2::class)) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt index 69443c27db0..63778eb04ad 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt @@ -6,22 +6,22 @@ class B2 : A() annotation class Ann1(val arg: Array>) -Ann1(array(A::class)) +Ann1(arrayOf(A::class)) class MyClass1 -Ann1(array(Any::class)) +Ann1(arrayOf(Any::class)) class MyClass1a -Ann1(array(B1::class)) +Ann1(arrayOf(B1::class)) class MyClass2 annotation class Ann2(val arg: Array>) -Ann2(array(A::class)) +Ann2(arrayOf(A::class)) class MyClass3 -Ann2(array(B1::class)) +Ann2(arrayOf(B1::class)) class MyClass4 -Ann2(array(B2::class)) +Ann2(arrayOf(B2::class)) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.kt index db6c4816cd7..2290d310525 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.kt @@ -9,7 +9,7 @@ class A2 Ann1(A1::class) Ann2(A1::class, A2::class) -Ann3(array(A1::class, A2::class)) +Ann3(arrayOf(A1::class, A2::class)) class MyClass1 Ann1(A3::class) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.kt index c2d0db1787f..0ada662ebd6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.kt @@ -14,7 +14,7 @@ ann3(a.b.c.A.IAnn()) annJavaClass(kotlin.javaClass()) -annArray(kotlin.array("a")) +annArray(kotlin.arrayOf("a")) fun test() = 1 annotation class ann1(val p: deprecated = kotlin.deprecated("aaa")) @@ -23,7 +23,7 @@ annotation class ann3(val p: A.IAnn = A.IAnn(), val p2: A.IAnn = a.b.c.A.IAnn()) annotation class annJavaClass(val p: Class<*> = kotlin.javaClass()) -annotation class annArray(val p: Array = kotlin.array("a")) +annotation class annArray(val p: Array = kotlin.arrayOf("a")) class A { annotation class IAnn diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromTopLevel.kt index 3fcedb39072..245d870afad 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/property/extensionFromTopLevel.kt @@ -1,7 +1,7 @@ import kotlin.reflect.* val String.countCharacters: Int - get() = length + get() = length() var Int.meaning: Long get() = 42L diff --git a/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt b/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt index 791c1aee9f7..e137ae8a6ca 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt @@ -8,10 +8,10 @@ fun fail2(): Array = ok1 { Array(1) { fun ok3(block: () -> Array): Array = ok1 { block() } inline fun ok4(): Array = ok1 { Array(1) { null!! } } -fun fail3(block: () -> T): Pair, Array> = Pair(array( - block()), array() +fun fail3(block: () -> T): Pair, Array> = Pair(arrayOf( + block()), arrayOf() ) inline fun ok5(block: () -> T): Pair, Array> = Pair( - array(block()), array() + arrayOf(block()), arrayOf() ) diff --git a/compiler/testData/diagnostics/testsWithStdLib/reified/nonCallableReiefied.kt b/compiler/testData/diagnostics/testsWithStdLib/reified/nonCallableReiefied.kt index df17f0fad3e..7eea23c14d3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/reified/nonCallableReiefied.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/reified/nonCallableReiefied.kt @@ -1,11 +1,11 @@ class A(val x: Array) { - val y: Int = x[0].toString().length + val y: Int = x[0].toString().length() fun foo(a: T) { x[0] = a } - fun bar(a: Array): Int = a[0].toString().length + fun bar(a: Array): Int = a[0].toString().length() } fun baz(a: Array): String = a[0].toString() diff --git a/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt b/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt index 076a03f79cf..19e7415e9b9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt @@ -3,7 +3,7 @@ inline fun foo(block: () -> T): String = block().toString() fun box() { - val a = array(null!!) + val a = arrayOf(null!!) val b = Array(5) { null!! } val c = foo() { null!! } val d = foo { null!! } diff --git a/compiler/testData/diagnostics/testsWithStdLib/varargs/kt4172j.kt b/compiler/testData/diagnostics/testsWithStdLib/varargs/kt4172j.kt index 096039ce60e..305a8a6ff7d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/varargs/kt4172j.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/varargs/kt4172j.kt @@ -5,5 +5,5 @@ public class A { // FILE: 1.kt fun main(args: Array) { - A.main(array()) + A.main(arrayOf()) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/varargs/kt5534.kt b/compiler/testData/diagnostics/testsWithStdLib/varargs/kt5534.kt index 4445b3de3eb..dbd93e1b8b5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/varargs/kt5534.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/varargs/kt5534.kt @@ -1,5 +1,5 @@ fun test() { - val p: Array = array("a") + val p: Array = arrayOf("a") foo(*p) } diff --git a/compiler/testData/integration/ant/jvm/externalAnnotations/root1/hello.kt b/compiler/testData/integration/ant/jvm/externalAnnotations/root1/hello.kt index 75434833e46..97065421b25 100644 --- a/compiler/testData/integration/ant/jvm/externalAnnotations/root1/hello.kt +++ b/compiler/testData/integration/ant/jvm/externalAnnotations/root1/hello.kt @@ -1,7 +1,7 @@ package hello fun main(args : Array) { - for (s in arrayList("a")) + for (s in arrayListOf("a")) println("Hello, $s!") val java: String = j.Java().f() val hello: String = j.Java().f2() diff --git a/compiler/testData/integration/ant/jvm/helloWorld/hello.kt b/compiler/testData/integration/ant/jvm/helloWorld/hello.kt index 5a1704e14e7..3ec4e92d7e8 100644 --- a/compiler/testData/integration/ant/jvm/helloWorld/hello.kt +++ b/compiler/testData/integration/ant/jvm/helloWorld/hello.kt @@ -1,7 +1,7 @@ package hello fun main(args : Array) { - for (s in arrayList("a")) + for (s in arrayListOf("a")) println("Hello, $s!") } diff --git a/compiler/testData/integration/ant/jvm/javacCompiler/root1/hello.kt b/compiler/testData/integration/ant/jvm/javacCompiler/root1/hello.kt index e2007e5880e..2976267a1d5 100644 --- a/compiler/testData/integration/ant/jvm/javacCompiler/root1/hello.kt +++ b/compiler/testData/integration/ant/jvm/javacCompiler/root1/hello.kt @@ -1,7 +1,7 @@ package hello fun main(args : Array) { - for (s in arrayList("a")) + for (s in arrayListOf("a")) println("Hello, $s!") j.Java().f(); } diff --git a/compiler/testData/integration/ant/jvm/kotlinCompiler/root1/hello.kt b/compiler/testData/integration/ant/jvm/kotlinCompiler/root1/hello.kt index 75434833e46..97065421b25 100644 --- a/compiler/testData/integration/ant/jvm/kotlinCompiler/root1/hello.kt +++ b/compiler/testData/integration/ant/jvm/kotlinCompiler/root1/hello.kt @@ -1,7 +1,7 @@ package hello fun main(args : Array) { - for (s in arrayList("a")) + for (s in arrayListOf("a")) println("Hello, $s!") val java: String = j.Java().f() val hello: String = j.Java().f2() diff --git a/compiler/testData/integration/ant/jvm/manySourceRoots/root1/hello.kt b/compiler/testData/integration/ant/jvm/manySourceRoots/root1/hello.kt index f1ed7bd2137..0fce73d03ce 100644 --- a/compiler/testData/integration/ant/jvm/manySourceRoots/root1/hello.kt +++ b/compiler/testData/integration/ant/jvm/manySourceRoots/root1/hello.kt @@ -1,7 +1,7 @@ package hello fun main(args : Array) { - for (s in arrayList("a")) + for (s in arrayListOf("a")) println("Hello, $s!") foo() } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 0924020d1c6..a99b4e6f200 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -3490,6 +3490,75 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { } } + @TestMetadata("compiler/testData/diagnostics/tests/deprecated") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Deprecated extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInDeprecated() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/deprecated"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("annotationUsage.kt") + public void testAnnotationUsage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/annotationUsage.kt"); + doTest(fileName); + } + + @TestMetadata("componentUsage.kt") + public void testComponentUsage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/componentUsage.kt"); + doTest(fileName); + } + + @TestMetadata("functionUsage.kt") + public void testFunctionUsage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/functionUsage.kt"); + doTest(fileName); + } + + @TestMetadata("imports.kt") + public void testImports() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/imports.kt"); + doTest(fileName); + } + + @TestMetadata("iteratorUsage.kt") + public void testIteratorUsage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/iteratorUsage.kt"); + doTest(fileName); + } + + @TestMetadata("javaDeprecated.kt") + public void testJavaDeprecated() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/javaDeprecated.kt"); + doTest(fileName); + } + + @TestMetadata("nestedTypesUsage.kt") + public void testNestedTypesUsage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/nestedTypesUsage.kt"); + doTest(fileName); + } + + @TestMetadata("objectUsage.kt") + public void testObjectUsage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/objectUsage.kt"); + doTest(fileName); + } + + @TestMetadata("propertyUsage.kt") + public void testPropertyUsage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/propertyUsage.kt"); + doTest(fileName); + } + + @TestMetadata("typeUsage.kt") + public void testTypeUsage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/typeUsage.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/tests/duplicateJvmSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.java b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.java index 088c2202b90..7c119e05ffe 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.java +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.java @@ -91,6 +91,19 @@ public interface DescriptorRenderer extends Renderer { .setNameShortness(NameShortness.SHORT) .setTextFormat(TextFormat.HTML).build(); + DescriptorRenderer DEPRECATION = new DescriptorRendererBuilder() + .setWithDefinedIn(false) + .setModifiers() + .setNameShortness(NameShortness.SHORT) + .setWithoutTypeParameters(false) + .setParameterNameRenderingPolicy(ParameterNameRenderingPolicy.NONE) + .setReceiverAfterName(false) + .setRenderCompanionObjectName(true) + .setRenderAccessors(true) + .setWithoutSuperTypes(true) + .setRenderDefaultValues(false) + .setStartFromName(true).build(); + @NotNull String renderType(@NotNull JetType type); diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt index e8caaca90c4..8edb28fd0e7 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt @@ -35,18 +35,18 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.diagnostics.Severity import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages +import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode +import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult +import org.jetbrains.kotlin.idea.kdoc.KDocHighlightingVisitor +import org.jetbrains.kotlin.idea.quickfix.QuickFixes +import org.jetbrains.kotlin.idea.util.ProjectRootsUtil import org.jetbrains.kotlin.psi.JetCodeFragment import org.jetbrains.kotlin.psi.JetFile +import org.jetbrains.kotlin.psi.JetParameter import org.jetbrains.kotlin.psi.JetReferenceExpression import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics -import org.jetbrains.kotlin.idea.util.ProjectRootsUtil -import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode -import org.jetbrains.kotlin.idea.caches.resolve.* -import org.jetbrains.kotlin.idea.quickfix.QuickFixes import kotlin.platform.platformStatic -import org.jetbrains.kotlin.idea.kdoc.KDocHighlightingVisitor -import org.jetbrains.kotlin.psi.JetParameter public open class JetPsiChecker : Annotator, HighlightRangeExtension { @@ -149,7 +149,12 @@ public open class JetPsiChecker : Annotator, HighlightRangeExtension { for (textRange in textRanges) { val annotation = holder.createWarningAnnotation(textRange, getDefaultMessage(diagnostic)) - if (factory == Errors.DEPRECATED_CLASS_OBJECT_SYNTAX) annotation.setTextAttributes(CodeInsightColors.DEPRECATED_ATTRIBUTES) + when (factory) { + Errors.DEPRECATED_CLASS_OBJECT_SYNTAX, + Errors.DEPRECATED_SYMBOL, + Errors.DEPRECATED_SYMBOL_WITH_MESSAGE + -> annotation.setTextAttributes(CodeInsightColors.DEPRECATED_ATTRIBUTES) + } setUpAnnotation(diagnostic, annotation, if (factory in Errors.UNUSED_ELEMENT_DIAGNOSTICS) ProblemHighlightType.LIKE_UNUSED_SYMBOL @@ -242,8 +247,8 @@ public open class JetPsiChecker : Annotator, HighlightRangeExtension { PropertiesHighlightingVisitor(holder, bindingContext), FunctionsHighlightingVisitor(holder, bindingContext), VariablesHighlightingVisitor(holder, bindingContext), - TypeKindHighlightingVisitor(holder, bindingContext), - DeprecatedAnnotationVisitor(holder, bindingContext) + TypeKindHighlightingVisitor(holder, bindingContext)//, + //DeprecatedAnnotationVisitor(holder, bindingContext) ) }