From c581ec6dd6b5e608deae55bb46b522c18bee3ca3 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Wed, 23 Nov 2016 19:08:15 +0300 Subject: [PATCH] JS: fixes after code review --- .../kotlin/types/expressions/PatternMatchingTypingVisitor.kt | 2 +- .../testsWithJsStdLib/native/rtti/castToNativeInterface.txt | 2 +- .../testsWithJsStdLib/native/rtti/checkForNativeInterface.txt | 2 +- .../native/rtti/nativeInterfaceAsReifiedTypeArgument.kt | 4 ++-- .../native/rtti/nativeInterfaceAsReifiedTypeArgument.txt | 4 ++-- .../testsWithJsStdLib/native/rtti/whenIsNativeInterface.txt | 4 ++-- .../kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt | 2 +- .../kotlin/js/resolve/diagnostics/JsReifiedNativeChecker.kt | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.kt index 214037b92af..6479a07f337 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.kt @@ -64,7 +64,7 @@ class PatternMatchingTypingVisitor internal constructor(facade: ExpressionTyping subject = leftHandSide, sourceType = knownType, targetType = rhsType, - operation = RttiOperation.IS + operation = if (expression.isNegated) RttiOperation.NOT_IS else RttiOperation.IS ) components.rttiExpressionCheckers.forEach { it.check(rttiInformation, expression, context.trace) diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/castToNativeInterface.txt b/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/castToNativeInterface.txt index af836f5c2b3..7504f06221c 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/castToNativeInterface.txt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/castToNativeInterface.txt @@ -2,7 +2,7 @@ package public fun box(/*0*/ a: kotlin.Any, /*1*/ b: kotlin.Any): kotlin.Pair -@kotlin.js.native() public interface I { +@kotlin.js.native public interface I { 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/native/rtti/checkForNativeInterface.txt b/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/checkForNativeInterface.txt index dcf110c32d2..6487bca95bf 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/checkForNativeInterface.txt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/checkForNativeInterface.txt @@ -2,7 +2,7 @@ package public fun box(/*0*/ a: kotlin.Any, /*1*/ b: kotlin.Any): kotlin.Boolean -@kotlin.js.native() public interface I { +@kotlin.js.native public interface I { 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/native/rtti/nativeInterfaceAsReifiedTypeArgument.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/nativeInterfaceAsReifiedTypeArgument.kt index e913ef8db8b..ca608e42ce9 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/nativeInterfaceAsReifiedTypeArgument.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/nativeInterfaceAsReifiedTypeArgument.kt @@ -14,8 +14,8 @@ fun bar() { foo(C()) val c: I = C() - foo(c) + foo(c) foo<I>(C()) - C() + c + C() + c } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/nativeInterfaceAsReifiedTypeArgument.txt b/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/nativeInterfaceAsReifiedTypeArgument.txt index 67e498a167e..a804797a640 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/nativeInterfaceAsReifiedTypeArgument.txt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/nativeInterfaceAsReifiedTypeArgument.txt @@ -4,14 +4,14 @@ public fun bar(): kotlin.Unit public inline fun foo(/*0*/ x: T): kotlin.Unit public operator inline fun C.plus(/*0*/ other: T): C -@kotlin.js.native() public final class C : I { +@kotlin.js.native public final class C : I { 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 } -@kotlin.js.native() public interface I { +@kotlin.js.native public interface I { 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/native/rtti/whenIsNativeInterface.txt b/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/whenIsNativeInterface.txt index 2790ab5f5a2..9e1136325b5 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/whenIsNativeInterface.txt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/rtti/whenIsNativeInterface.txt @@ -2,13 +2,13 @@ package public fun box(/*0*/ a: kotlin.Any): kotlin.Int -@kotlin.js.native() public interface I { +@kotlin.js.native public interface I { 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.js.native() public interface J { +@kotlin.js.native public interface J { 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/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt index dfe250002ce..dd6b2b060ab 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt @@ -50,7 +50,7 @@ private val DIAGNOSTIC_FACTORY_TO_RENDERER by lazy { put(ErrorsJs.JS_NAME_PROHIBITED_FOR_NAMED_NATIVE, "@JsName is prohibited for @native declaration with explicit name") put(ErrorsJs.CANNOT_CHECK_FOR_NATIVE_INTERFACE, "Cannot check for native interface: {0}", RENDER_TYPE) put(ErrorsJs.UNCHECKED_CAST_TO_NATIVE_INTERFACE, "Unchecked cast to native interface: {0} to {1}", RENDER_TYPE, RENDER_TYPE) - put(ErrorsJs.NATIVE_INTERFACE_AS_REIFIED_TYPE_ARGUMENT, "Cannot pass native interface {0} to reified type parameter", RENDER_TYPE) + put(ErrorsJs.NATIVE_INTERFACE_AS_REIFIED_TYPE_ARGUMENT, "Cannot pass native interface {0} for reified type parameter", RENDER_TYPE) this } diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsReifiedNativeChecker.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsReifiedNativeChecker.kt index 167860771f2..4625e013047 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsReifiedNativeChecker.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsReifiedNativeChecker.kt @@ -34,7 +34,7 @@ class JsReifiedNativeChecker : CallChecker { typeArgumentList[typeParam.index].typeReference } else { - resolvedCall.call.valueArguments[typeParam.index].getArgumentExpression() + resolvedCall.call.callElement } context.trace.report(ErrorsJs.NATIVE_INTERFACE_AS_REIFIED_TYPE_ARGUMENT.on(typeArgumentPsi!!, typeArg))