diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/DeprecatedClassifierUsageChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/DeprecatedClassifierUsageChecker.kt
index bd697c264d8..69575ed226f 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/DeprecatedClassifierUsageChecker.kt
+++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/DeprecatedClassifierUsageChecker.kt
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.checkers
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
+import org.jetbrains.kotlin.psi.KtThisExpression
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.createDeprecationDiagnostic
import org.jetbrains.kotlin.resolve.getDeprecations
@@ -30,6 +31,7 @@ class DeprecatedClassifierUsageChecker : ClassifierUsageChecker {
element: PsiElement,
languageVersionSettings: LanguageVersionSettings
) {
+ if (element.parent is KtThisExpression) return
for (deprecation in targetDescriptor.getDeprecations(languageVersionSettings)) {
trace.report(createDeprecationDiagnostic(element, deprecation, languageVersionSettings))
}
diff --git a/compiler/testData/diagnostics/tests/deprecated/thisUsage.kt b/compiler/testData/diagnostics/tests/deprecated/thisUsage.kt
new file mode 100644
index 00000000000..cc5148216ae
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/deprecated/thisUsage.kt
@@ -0,0 +1,7 @@
+// !DIAGNOSTICS: -UNUSED_VARIABLE
+
+@Deprecated("Use A instead") open class MyClass {
+ fun foo() {
+ val test = this
+ }
+}
diff --git a/compiler/testData/diagnostics/tests/deprecated/thisUsage.txt b/compiler/testData/diagnostics/tests/deprecated/thisUsage.txt
new file mode 100644
index 00000000000..a8e4e84a496
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/deprecated/thisUsage.txt
@@ -0,0 +1,9 @@
+package
+
+@kotlin.Deprecated(message = "Use A instead") public open class MyClass {
+ public constructor MyClass()
+ public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
+ public final fun foo(): kotlin.Unit
+ public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
+ public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
+}
diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java
index 22de66cf3e8..21f28fd4b2c 100644
--- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java
+++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java
@@ -6589,6 +6589,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
+ @TestMetadata("thisUsage.kt")
+ public void testThisUsage() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/thisUsage.kt");
+ doTest(fileName);
+ }
+
@TestMetadata("typeUsage.kt")
public void testTypeUsage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/typeUsage.kt");
diff --git a/idea/testData/highlighter/deprecated/Class.kt b/idea/testData/highlighter/deprecated/Class.kt
index 4463629e476..94a426d3836 100644
--- a/idea/testData/highlighter/deprecated/Class.kt
+++ b/idea/testData/highlighter/deprecated/Class.kt
@@ -2,7 +2,9 @@ package test
import java.util.ArrayList
-@Deprecated("Use A instead") open class MyClass {}
+@Deprecated("Use A instead") open class MyClass {
+ val test = this
+}
fun test() {
val a : MyClass? = null
diff --git a/idea/testData/highlighter/deprecated/Constructor.kt b/idea/testData/highlighter/deprecated/Constructor.kt
new file mode 100644
index 00000000000..cdd1d87ede4
--- /dev/null
+++ b/idea/testData/highlighter/deprecated/Constructor.kt
@@ -0,0 +1,14 @@
+package test
+
+class A {
+ constructor(x: Int) : this(x, 0) {
+ }
+
+ @Deprecated("use one-arg overload")
+ constructor(x: Int, y: Int) {
+ x + y
+ }
+}
+
+// NO_CHECK_INFOS
+// NO_CHECK_WEAK_WARNINGS
diff --git a/idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingTestGenerated.java
index c31eb27176f..e9956703625 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingTestGenerated.java
+++ b/idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingTestGenerated.java
@@ -158,6 +158,12 @@ public class HighlightingTestGenerated extends AbstractHighlightingTest {
doTest(fileName);
}
+ @TestMetadata("Constructor.kt")
+ public void testConstructor() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/highlighter/deprecated/Constructor.kt");
+ doTest(fileName);
+ }
+
@TestMetadata("ExtensionFunction.kt")
public void testExtensionFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/highlighter/deprecated/ExtensionFunction.kt");