From a3fdce8131582874ef61879eb8a9da815b5f15d7 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Fri, 28 Nov 2014 21:33:52 +0300 Subject: [PATCH] Highlighting "as Foo" for useless casts in gray. #KT-6070 fixed --- .../org/jetbrains/jet/lang/diagnostics/Errors.java | 6 +++--- .../jet/lang/diagnostics/PositioningStrategies.kt | 6 ++++++ .../expressions/BasicExpressionTypingVisitor.java | 4 ++-- compiler/testData/diagnostics/tests/Casts.kt | 12 ++++++------ compiler/testData/diagnostics/tests/Constants.kt | 2 +- .../testData/diagnostics/tests/LValueAssignment.kt | 2 +- .../diagnostics/tests/cast/bare/FromErrorType.kt | 2 +- .../diagnostics/tests/cast/bare/ToErrorType.kt | 2 +- .../testData/diagnostics/tests/cast/constants.kt | 12 ++++++------ .../diagnostics/tests/classObjects/kt3866.kt | 2 +- .../testData/diagnostics/tests/dataFlow/EmptyIf.kt | 2 +- .../tests/nullabilityAndSmartCasts/kt2176.kt | 2 +- .../testData/diagnostics/tests/smartCasts/kt5455.kt | 8 ++++---- .../diagnostics/tests/suppress/manyWarnings/mixed.kt | 2 +- .../tests/suppress/manyWarnings/onClass.kt | 2 +- .../tests/suppress/manyWarnings/onClassObject.kt | 2 +- .../tests/suppress/manyWarnings/onExpression.kt | 2 +- .../tests/suppress/manyWarnings/onFunction.kt | 2 +- .../tests/suppress/manyWarnings/onObject.kt | 2 +- .../tests/suppress/manyWarnings/onParameter.kt | 2 +- .../tests/suppress/manyWarnings/onProperty.kt | 2 +- .../suppress/manyWarnings/onPropertyAccessor.kt | 2 +- .../diagnostics/tests/suppress/oneWarning/onClass.kt | 2 +- .../tests/suppress/oneWarning/onClassObject.kt | 2 +- .../tests/suppress/oneWarning/onExpression.kt | 2 +- .../tests/suppress/oneWarning/onFunction.kt | 2 +- .../tests/suppress/oneWarning/onLocalVariable.kt | 2 +- .../tests/suppress/oneWarning/onObject.kt | 2 +- .../tests/suppress/oneWarning/onParameter.kt | 2 +- .../tests/suppress/oneWarning/onProperty.kt | 2 +- .../tests/suppress/oneWarning/onPropertyAccessor.kt | 2 +- .../jet/plugin/highlighter/JetPsiChecker.kt | 1 + idea/testData/checker/Casts.kt | 12 ++++++------ idea/testData/checker/Constants.kt | 2 +- 34 files changed, 60 insertions(+), 53 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java index 245c707c559..1571aa579da 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java @@ -530,8 +530,8 @@ public interface Errors { DiagnosticFactory1 CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR); DiagnosticFactory2 UNCHECKED_CAST = DiagnosticFactory2.create(WARNING); - DiagnosticFactory0 USELESS_CAST_STATIC_ASSERT_IS_FINE = DiagnosticFactory0.create(WARNING); - DiagnosticFactory0 USELESS_CAST = DiagnosticFactory0.create(WARNING); + DiagnosticFactory0 USELESS_CAST_STATIC_ASSERT_IS_FINE = DiagnosticFactory0.create(WARNING, AS_TYPE); + DiagnosticFactory0 USELESS_CAST = DiagnosticFactory0.create(WARNING, AS_TYPE); DiagnosticFactory0 CAST_NEVER_SUCCEEDS = DiagnosticFactory0.create(WARNING); DiagnosticFactory0 DYNAMIC_NOT_ALLOWED = DiagnosticFactory0.create(ERROR); @@ -631,7 +631,7 @@ public interface Errors { INVISIBLE_MEMBER, INVISIBLE_MEMBER_FROM_INLINE, INVISIBLE_REFERENCE, INVISIBLE_SETTER); ImmutableSet> UNUSED_ELEMENT_DIAGNOSTICS = ImmutableSet.of( UNUSED_VARIABLE, UNUSED_PARAMETER, ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE, VARIABLE_WITH_REDUNDANT_INITIALIZER, - UNUSED_FUNCTION_LITERAL); + UNUSED_FUNCTION_LITERAL, USELESS_CAST, USELESS_CAST_STATIC_ASSERT_IS_FINE); ImmutableSet> TYPE_INFERENCE_ERRORS = ImmutableSet.of( TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS, TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH, TYPE_INFERENCE_UPPER_BOUND_VIOLATED, TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategies.kt b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategies.kt index 6cdc5d46b39..b382c7b0d4e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategies.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategies.kt @@ -365,4 +365,10 @@ public object PositioningStrategies { return Errors.UNREACHABLE_CODE.cast(diagnostic).getA() } } + + public val AS_TYPE: PositioningStrategy = object : PositioningStrategy() { + override fun mark(element: JetBinaryExpressionWithTypeRHS): List { + return markRange(element.getOperationReference(), element) + } + } } \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index e075454c8c5..606e6e79602 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -223,14 +223,14 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { JetTypeChecker typeChecker = JetTypeChecker.DEFAULT; if (actualType.equals(targetType)) { // cast to itself: String as String - context.trace.report(USELESS_CAST.on(expression.getOperationReference())); + context.trace.report(USELESS_CAST.on(expression)); return; } Collection possibleTypes = DataFlowUtils.getAllPossibleTypes( expression.getLeft(), context.dataFlowInfo, actualType, context.trace.getBindingContext()); for (JetType possibleType : possibleTypes) { if (typeChecker.isSubtypeOf(possibleType, targetType)) { - context.trace.report(USELESS_CAST_STATIC_ASSERT_IS_FINE.on(expression.getOperationReference())); + context.trace.report(USELESS_CAST_STATIC_ASSERT_IS_FINE.on(expression)); return; } } diff --git a/compiler/testData/diagnostics/tests/Casts.kt b/compiler/testData/diagnostics/tests/Casts.kt index 5c9ea9fb549..3811dfe4cfa 100644 --- a/compiler/testData/diagnostics/tests/Casts.kt +++ b/compiler/testData/diagnostics/tests/Casts.kt @@ -5,12 +5,12 @@ fun test() : Unit { x : Int? y : Int x as Int : Int - y as Int : Int - x as Int? : Int? - y as Int? : Int? + y as Int : Int + x as Int? : Int? + y as Int? : Int? x as? Int : Int? - y as? Int : Int? - x as? Int? : Int? - y as? Int? : Int? + y as? Int : Int? + x as? Int? : Int? + y as? Int? : Int? Unit } diff --git a/compiler/testData/diagnostics/tests/Constants.kt b/compiler/testData/diagnostics/tests/Constants.kt index f0ecb9e116c..f7a469b2944 100644 --- a/compiler/testData/diagnostics/tests/Constants.kt +++ b/compiler/testData/diagnostics/tests/Constants.kt @@ -31,7 +31,7 @@ fun test() { 1: Float 1 as Byte - 1 as Int + 1 as Int 0xff as Long 1.1 as Int diff --git a/compiler/testData/diagnostics/tests/LValueAssignment.kt b/compiler/testData/diagnostics/tests/LValueAssignment.kt index 14318e92be3..c5bd66ba5c9 100644 --- a/compiler/testData/diagnostics/tests/LValueAssignment.kt +++ b/compiler/testData/diagnostics/tests/LValueAssignment.kt @@ -45,7 +45,7 @@ fun cannotBe() { "" = ""; foo() = Unit; - (i as Int) = 34 + (i as Int) = 34 (i is Int) = false A() = A() 5 = 34 diff --git a/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.kt b/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.kt index 7842cd15494..2bf731e5a27 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.kt @@ -1,6 +1,6 @@ class G fun foo(p: P) { - val v = p as G? + val v = p as G? v!!: G<*> } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/ToErrorType.kt b/compiler/testData/diagnostics/tests/cast/bare/ToErrorType.kt index 0d7d75f6fb3..e4ce74bd120 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/ToErrorType.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/ToErrorType.kt @@ -1,6 +1,6 @@ class P fun foo(p: P): Any { - val v = p as G + val v = p as G return v } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/constants.kt b/compiler/testData/diagnostics/tests/cast/constants.kt index 53540e9843b..66ae58f153f 100644 --- a/compiler/testData/diagnostics/tests/cast/constants.kt +++ b/compiler/testData/diagnostics/tests/cast/constants.kt @@ -1,5 +1,5 @@ fun asCall() { - 1 as Int + 1 as Int 1 as Byte 1 as Short 1 as Long @@ -12,7 +12,7 @@ fun asCall() { 1.0 as Short 1.0 as Long 1.0 as Char - 1.0 as Double + 1.0 as Double 1.0 as Float 1f as Int @@ -21,11 +21,11 @@ fun asCall() { 1f as Long 1f as Char 1f as Double - 1f as Float + 1f as Float } fun asSafe() { - 1 as? Int + 1 as? Int 1 as? Byte 1 as? Short 1 as? Long @@ -38,7 +38,7 @@ fun asSafe() { 1.0 as? Short 1.0 as? Long 1.0 as? Char - 1.0 as? Double + 1.0 as? Double 1.0 as? Float 1f as? Int @@ -47,5 +47,5 @@ fun asSafe() { 1f as? Long 1f as? Char 1f as? Double - 1f as? Float + 1f as? Float } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/classObjects/kt3866.kt b/compiler/testData/diagnostics/tests/classObjects/kt3866.kt index 22a3a34a9e0..cb65fb86312 100644 --- a/compiler/testData/diagnostics/tests/classObjects/kt3866.kt +++ b/compiler/testData/diagnostics/tests/classObjects/kt3866.kt @@ -16,6 +16,6 @@ fun bar() { x.foo() X.foo() (X : C).foo() - (X as C).foo() + (X as C).foo() ((if (1<2) X else Y) : C).foo() } diff --git a/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt b/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt index 04ef93280a0..577933a818e 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt @@ -11,7 +11,7 @@ fun f2(s: Number?) { } fun f3(s: Number?) { - if (s is Int && s as Int == 42); + if (s is Int && s as Int == 42); s : Int } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt index 6ff935fdb6e..379fa66225f 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2176.kt @@ -22,6 +22,6 @@ fun f4(a: Any) { } fun f5(a: String) { - a as Any? + a as Any? a: String } diff --git a/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt b/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt index 449ee5e84c4..2c3e2a06d33 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/kt5455.kt @@ -1,7 +1,7 @@ //KT-5455 Need warning about redundant type cast fun foo(o: Any): Int { if (o is String) { - return (o as String).length() + return (o as String).length() } return -1 } @@ -13,16 +13,16 @@ class B: A() fun test(a: Any?) { if (a is B) { - (a as A).foo() + (a as A).foo() } } fun test1(a: B) { - (a as A?)?.foo() + (a as A?)?.foo() } fun test2(b: B?) { if (b != null) { - (b as A).foo() + (b as A).foo() } } diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/mixed.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/mixed.kt index 96534d2ab02..9cdd00f8df1 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/mixed.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/mixed.kt @@ -1,5 +1,5 @@ suppress("REDUNDANT_NULLABLE") class C { suppress("UNNECESSARY_NOT_NULL_ASSERTION") - fun foo(): String?? = ""!! as String?? + fun foo(): String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClass.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClass.kt index d303b6ca905..9861434d5fe 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClass.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClass.kt @@ -1,4 +1,4 @@ suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") class C { - fun foo(): String?? = ""!! as String?? + fun foo(): String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClassObject.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClassObject.kt index a3b1a583be1..996a4c5df29 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClassObject.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onClassObject.kt @@ -1,6 +1,6 @@ class C { suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") class object { - val foo: String?? = ""!! as String?? + val foo: String?? = ""!! as String?? } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onExpression.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onExpression.kt index df970125c19..01097f7e450 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onExpression.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onExpression.kt @@ -1,4 +1,4 @@ fun foo(): Any? { [suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION")] - return ""!! as String?? + return ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onFunction.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onFunction.kt index 78c97cb932a..a8105aa7466 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onFunction.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onFunction.kt @@ -1,4 +1,4 @@ class C { suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") - fun foo(): String?? = ""!! as String?? + fun foo(): String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onObject.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onObject.kt index 7335b7c1b2d..46b417e7005 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onObject.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onObject.kt @@ -1,4 +1,4 @@ suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") object C { - fun foo(): String?? = ""!! as String?? + fun foo(): String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onParameter.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onParameter.kt index eba1a988f96..e068b5ba5e5 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onParameter.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onParameter.kt @@ -1,3 +1,3 @@ class C { - fun foo(suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") p: String?? = ""!! as String??) = p + fun foo(suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") p: String?? = ""!! as String??) = p } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onProperty.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onProperty.kt index 13340a896d7..4e733c514c7 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onProperty.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onProperty.kt @@ -1,4 +1,4 @@ class C { suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION") - val foo: String?? = ""!! as String?? + val foo: String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onPropertyAccessor.kt b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onPropertyAccessor.kt index 3524ef0d9d7..481e56456b2 100644 --- a/compiler/testData/diagnostics/tests/suppress/manyWarnings/onPropertyAccessor.kt +++ b/compiler/testData/diagnostics/tests/suppress/manyWarnings/onPropertyAccessor.kt @@ -1,5 +1,5 @@ class C { val foo: String? [suppress("REDUNDANT_NULLABLE", "UNNECESSARY_NOT_NULL_ASSERTION")] - get(): String?? = ""!! as String?? + get(): String?? = ""!! as String?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/onClass.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/onClass.kt index 2d9e2827205..809739a6ace 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/onClass.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/onClass.kt @@ -1,4 +1,4 @@ suppress("REDUNDANT_NULLABLE") class C { - fun foo(): String?? = null as Nothing?? + fun foo(): String?? = null as Nothing?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/onClassObject.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/onClassObject.kt index 22981944670..b2e80c66388 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/onClassObject.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/onClassObject.kt @@ -1,6 +1,6 @@ class C { suppress("REDUNDANT_NULLABLE") class object { - val foo: String?? = null as Nothing?? + val foo: String?? = null as Nothing?? } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/onExpression.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/onExpression.kt index 2735e70a695..67a90726834 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/onExpression.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/onExpression.kt @@ -1,4 +1,4 @@ fun foo(): Any? { [suppress("REDUNDANT_NULLABLE")] - return null as Nothing?? + return null as Nothing?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/onFunction.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/onFunction.kt index 082840860de..707c40c1612 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/onFunction.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/onFunction.kt @@ -1,4 +1,4 @@ class C { suppress("REDUNDANT_NULLABLE") - fun foo(): String?? = null as Nothing?? + fun foo(): String?? = null as Nothing?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/onLocalVariable.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/onLocalVariable.kt index ead9e5f01c2..0047969f4f1 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/onLocalVariable.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/onLocalVariable.kt @@ -1,7 +1,7 @@ class C { fun foo(): Any? { [suppress("REDUNDANT_NULLABLE")] - val v: String?? = null as Nothing?? + val v: String?? = null as Nothing?? return v } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/onObject.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/onObject.kt index 6a68f9634bd..c513f624be3 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/onObject.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/onObject.kt @@ -1,4 +1,4 @@ suppress("REDUNDANT_NULLABLE") object C { - fun foo(): String?? = null as Nothing?? + fun foo(): String?? = null as Nothing?? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/onParameter.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/onParameter.kt index 50930a07a02..b91c1b68ef3 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/onParameter.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/onParameter.kt @@ -1,3 +1,3 @@ class C { - fun foo(suppress("REDUNDANT_NULLABLE") p: String?? = null as Nothing??) = p + fun foo(suppress("REDUNDANT_NULLABLE") p: String?? = null as Nothing??) = p } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/onProperty.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/onProperty.kt index 9d3788b8c94..e2011b19aab 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/onProperty.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/onProperty.kt @@ -1,4 +1,4 @@ class C { suppress("REDUNDANT_NULLABLE") - val foo: String?? = null as Nothing? + val foo: String?? = null as Nothing? } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/onPropertyAccessor.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/onPropertyAccessor.kt index 0dcdb3c5a0f..f51bae07550 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/onPropertyAccessor.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/onPropertyAccessor.kt @@ -1,5 +1,5 @@ class C { val foo: String? [suppress("REDUNDANT_NULLABLE")] - get(): String?? = null as Nothing?? + get(): String?? = null as Nothing?? } \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.kt b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.kt index 415763f0119..c148f463390 100644 --- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.kt +++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.kt @@ -49,6 +49,7 @@ import org.jetbrains.jet.plugin.caches.resolve.* import org.jetbrains.jet.plugin.quickfix.JetIntentionActionsFactory import org.jetbrains.jet.plugin.quickfix.QuickFixes import kotlin.platform.platformStatic +import org.jetbrains.jet.lang.psi.JetBinaryExpressionWithTypeRHS public open class JetPsiChecker : Annotator, HighlightRangeExtension { diff --git a/idea/testData/checker/Casts.kt b/idea/testData/checker/Casts.kt index b67ec918273..cecca770f78 100644 --- a/idea/testData/checker/Casts.kt +++ b/idea/testData/checker/Casts.kt @@ -5,12 +5,12 @@ fun test() : Unit { x : Int? y : Int x as Int : Int - y as Int : Int - x as Int? : Int? - y as Int? : Int? + y as Int : Int + x as Int? : Int? + y as Int? : Int? x as? Int : Int? - y as? Int : Int? - x as? Int? : Int? - y as? Int? : Int? + y as? Int : Int? + x as? Int? : Int? + y as? Int? : Int? Unit } diff --git a/idea/testData/checker/Constants.kt b/idea/testData/checker/Constants.kt index d1b647b8fa3..453cffee895 100644 --- a/idea/testData/checker/Constants.kt +++ b/idea/testData/checker/Constants.kt @@ -3,6 +3,6 @@ fun test() { 1 : Int 1 : Double 1 as Byte - 1 as Int + 1 as Int 1 as Double } \ No newline at end of file