JS: add restrictions to external modifier according to KT-13893
This commit is contained in:
Vendored
-45
@@ -1,45 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {
|
||||
external class A {
|
||||
@nativeGetter
|
||||
fun get(a: String): Any? = null
|
||||
|
||||
@nativeGetter
|
||||
fun take(a: Number): String? = null
|
||||
|
||||
@nativeGetter
|
||||
fun foo(a: Double): String? = null
|
||||
}
|
||||
|
||||
external class B {
|
||||
<!WRONG_ANNOTATION_TARGET!>@nativeGetter<!>
|
||||
val foo = 0
|
||||
}
|
||||
|
||||
external class C {
|
||||
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>@nativeGetter
|
||||
fun Int.get(a: String): Int?<!> = 1
|
||||
|
||||
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>@nativeGetter
|
||||
fun Int.get2(a: Number): String?<!> = "OK"
|
||||
|
||||
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>@nativeGetter
|
||||
fun Int.get3(a: Int): String?<!> = "OK"
|
||||
|
||||
<!NATIVE_INDEXER_WRONG_PARAMETER_COUNT!>@nativeGetter
|
||||
fun get(): Any?<!> = null
|
||||
|
||||
@nativeGetter
|
||||
fun get(<!NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER!>a: A<!>): Any? = null
|
||||
|
||||
@nativeGetter
|
||||
fun <!NATIVE_GETTER_RETURN_TYPE_SHOULD_BE_NULLABLE!>foo<!>(a: Int) {}
|
||||
|
||||
@nativeGetter
|
||||
fun bar(a: String): <!NATIVE_GETTER_RETURN_TYPE_SHOULD_BE_NULLABLE!>Int<!> = 0
|
||||
|
||||
@nativeGetter
|
||||
fun baz(<!NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS!>a: String = "foo"<!>): Int? = 0
|
||||
}
|
||||
}
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
package
|
||||
|
||||
public fun foo(): kotlin.Unit
|
||||
Vendored
-25
@@ -1,25 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {
|
||||
external class A {
|
||||
@nativeInvoke
|
||||
fun foo() {}
|
||||
|
||||
@nativeInvoke
|
||||
fun invoke(a: String): Int = 0
|
||||
|
||||
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>@nativeInvoke
|
||||
fun Int.ext()<!> = 1
|
||||
|
||||
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>@nativeInvoke
|
||||
fun Int.invoke(a: String, b: Int)<!> = "OK"
|
||||
|
||||
val anonymous = object {
|
||||
@nativeInvoke
|
||||
fun foo() {}
|
||||
|
||||
@nativeInvoke
|
||||
fun invoke(a: String): Int = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
package
|
||||
|
||||
public fun foo(): kotlin.Unit
|
||||
Vendored
-60
@@ -1,60 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION
|
||||
|
||||
fun foo() {
|
||||
@native
|
||||
class A {
|
||||
@nativeSetter
|
||||
fun set(a: String, v: Any?): Any? = null
|
||||
|
||||
@nativeSetter
|
||||
fun put(a: Number, v: String) {}
|
||||
|
||||
@nativeSetter
|
||||
fun foo(a: Int, v: String) {}
|
||||
|
||||
@nativeSetter
|
||||
fun set4(a: Double, v: String): Any = 1
|
||||
|
||||
@nativeSetter
|
||||
fun set5(a: Double, v: String): CharSequence = "OK"
|
||||
}
|
||||
|
||||
@native
|
||||
class B {
|
||||
<!WRONG_ANNOTATION_TARGET!>@nativeSetter<!>
|
||||
val foo = 0
|
||||
}
|
||||
|
||||
@native
|
||||
class C {
|
||||
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>@nativeSetter
|
||||
fun Int.set(a: String, v: Int)<!> {}
|
||||
|
||||
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>@nativeSetter
|
||||
fun Int.<!NATIVE_SETTER_WRONG_RETURN_TYPE!>set2<!>(a: Number, v: String?)<!> = "OK"
|
||||
|
||||
<!NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN!>@nativeSetter
|
||||
fun Int.<!NATIVE_SETTER_WRONG_RETURN_TYPE!>set3<!>(a: Double, v: String?)<!> = "OK"
|
||||
|
||||
@nativeSetter
|
||||
fun set6(a: Double, v: String): <!NATIVE_SETTER_WRONG_RETURN_TYPE!>Number<!> = 1
|
||||
|
||||
<!NATIVE_INDEXER_WRONG_PARAMETER_COUNT!>@nativeSetter
|
||||
fun set(): Any?<!> = null
|
||||
|
||||
<!NATIVE_INDEXER_WRONG_PARAMETER_COUNT!>@nativeSetter
|
||||
fun set(<!NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER!>a: A<!>): Any?<!> = null
|
||||
|
||||
<!NATIVE_INDEXER_WRONG_PARAMETER_COUNT!>@nativeSetter
|
||||
fun set(a: String, v: Any, v2: Any)<!> {}
|
||||
|
||||
@nativeSetter
|
||||
fun set(<!NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER!>a: A<!>, v: Any?) {}
|
||||
|
||||
@nativeSetter
|
||||
fun foo(<!NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS!>a: Number = 0.0<!>, v: String) = "OK"
|
||||
|
||||
@nativeSetter
|
||||
fun boo(a: Number, <!NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS!>v: String = "str"<!>) = "OK"
|
||||
}
|
||||
}
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
package
|
||||
|
||||
public fun foo(): kotlin.Unit
|
||||
@@ -0,0 +1,51 @@
|
||||
// !DIAGNOSTICS: -DEPRECATION
|
||||
object O
|
||||
|
||||
class TopLevel {
|
||||
external class <!NESTED_EXTERNAL_DECLARATION!>A<!>
|
||||
|
||||
class B
|
||||
|
||||
fun foo() = 23
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external fun bar(): Int<!>
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>@native fun baz(): Int<!>
|
||||
|
||||
val x = "a"
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external val y: String<!>
|
||||
|
||||
val O.u: String get() = "O.u"
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external val O.v: String<!> get() = noImpl
|
||||
}
|
||||
|
||||
external class TopLevelNative {
|
||||
external class <!NESTED_EXTERNAL_DECLARATION!>A<!>
|
||||
|
||||
class B
|
||||
|
||||
fun foo() = 23
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external fun bar(): Int<!>
|
||||
|
||||
val x = "a"
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external val y: String<!>
|
||||
|
||||
val O.u: String get() = "O.u"
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external val O.v: String<!> get() = noImpl
|
||||
}
|
||||
|
||||
fun topLevelFun() {
|
||||
external class <!NESTED_EXTERNAL_DECLARATION!>A<!>
|
||||
|
||||
class B
|
||||
|
||||
fun foo() = 23
|
||||
|
||||
<!NESTED_EXTERNAL_DECLARATION!>external fun bar(): Int<!>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package
|
||||
|
||||
public fun topLevelFun(): kotlin.Unit
|
||||
|
||||
public object O {
|
||||
private constructor O()
|
||||
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
|
||||
}
|
||||
|
||||
public final class TopLevel {
|
||||
public constructor TopLevel()
|
||||
public final val x: kotlin.String = "a"
|
||||
public final val y: kotlin.String
|
||||
public final val O.u: kotlin.String
|
||||
public final val O.v: kotlin.String
|
||||
public final external fun bar(): kotlin.Int
|
||||
@kotlin.js.native public final fun baz(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
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
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor B()
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
public final class TopLevelNative {
|
||||
public constructor TopLevelNative()
|
||||
public final val x: kotlin.String = "a"
|
||||
public final val y: kotlin.String
|
||||
public final val O.u: kotlin.String
|
||||
public final val O.v: kotlin.String
|
||||
public final external fun bar(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
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
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor B()
|
||||
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
|
||||
}
|
||||
}
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
class A {
|
||||
<!NATIVE_INNER_CLASS_PROHIBITED!>external inner class B<!>
|
||||
}
|
||||
|
||||
external class C {
|
||||
inner external class D
|
||||
}
|
||||
Vendored
-29
@@ -1,29 +0,0 @@
|
||||
package
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
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
|
||||
|
||||
public final inner class B {
|
||||
public constructor B()
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
public 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
|
||||
|
||||
public final inner class D {
|
||||
public constructor D()
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -51,13 +51,4 @@ external object O {
|
||||
fun bar(s: String): String = noImpl
|
||||
}
|
||||
|
||||
fun test() {
|
||||
external class Local {
|
||||
val baz: Int
|
||||
val boo: Int = noImpl
|
||||
|
||||
fun foo()
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ public val boo: kotlin.Int
|
||||
public val kotlin.Int.baz: kotlin.Int
|
||||
public external fun bar(): kotlin.Unit
|
||||
public external fun foo(): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
public external fun kotlin.String.bar(): kotlin.Int
|
||||
public external fun kotlin.String.foo(): kotlin.Int
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<!WRONG_MODIFIER_TARGET!>external annotation class A<!>
|
||||
|
||||
val x: Int
|
||||
<!WRONG_MODIFIER_TARGET!>external get() = noImpl<!>
|
||||
|
||||
class B
|
||||
|
||||
val B.x: Int
|
||||
<!WRONG_MODIFIER_TARGET!>external get() = noImpl<!>
|
||||
|
||||
class C {
|
||||
val a: Int
|
||||
<!WRONG_MODIFIER_TARGET!>external get() = noImpl<!>
|
||||
}
|
||||
|
||||
external class D {
|
||||
val a: Int
|
||||
<!WRONG_MODIFIER_TARGET!>external get() = noImpl<!>
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package
|
||||
|
||||
public val x: kotlin.Int
|
||||
public val B.x: kotlin.Int
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A()
|
||||
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
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor B()
|
||||
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
|
||||
}
|
||||
|
||||
public final class C {
|
||||
public constructor C()
|
||||
public final val a: 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
|
||||
}
|
||||
|
||||
public external final class D {
|
||||
public constructor D()
|
||||
public final val a: 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
|
||||
}
|
||||
+12
-33
@@ -515,6 +515,18 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib/native"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("nested.kt")
|
||||
public void testNested() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nested.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("wrongTarget.kt")
|
||||
public void testWrongTarget() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/wrongTarget.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@@ -529,12 +541,6 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("onLocalNativeClassMembers.kt")
|
||||
public void testOnLocalNativeClassMembers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalNativeClassMembers.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("onLocalNonNativeClassMembers.kt")
|
||||
public void testOnLocalNonNativeClassMembers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalNonNativeClassMembers.kt");
|
||||
@@ -598,12 +604,6 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("onLocalNativeClassMembers.kt")
|
||||
public void testOnLocalNativeClassMembers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalNativeClassMembers.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("onLocalNonNativeClassMembers.kt")
|
||||
public void testOnLocalNonNativeClassMembers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalNonNativeClassMembers.kt");
|
||||
@@ -667,12 +667,6 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("onLocalNativeClassMembers.kt")
|
||||
public void testOnLocalNativeClassMembers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalNativeClassMembers.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("onLocalNonNativeClassMembers.kt")
|
||||
public void testOnLocalNonNativeClassMembers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalNonNativeClassMembers.kt");
|
||||
@@ -722,21 +716,6 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nested")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Nested extends AbstractDiagnosticsTestWithJsStdLib {
|
||||
public void testAllFilesPresentInNested() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib/native/nested"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("nativeInnerClassProhibited.kt")
|
||||
public void testNativeInnerClassProhibited() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nested/nativeInnerClassProhibited.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/optionlBody")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -33,9 +33,10 @@ import org.jetbrains.kotlin.types.DynamicTypesAllowed
|
||||
object JsPlatformConfigurator : PlatformConfigurator(
|
||||
DynamicTypesAllowed(),
|
||||
additionalDeclarationCheckers = listOf(
|
||||
NativeInvokeChecker(), NativeGetterChecker(), NativeSetterChecker(), NativeInnerClassChecker(),
|
||||
NativeInvokeChecker(), NativeGetterChecker(), NativeSetterChecker(),
|
||||
JsNameChecker, JsModuleChecker,
|
||||
PlatformImplDeclarationChecker()
|
||||
PlatformImplDeclarationChecker(),
|
||||
JsExternalChecker()
|
||||
),
|
||||
additionalCallCheckers = listOf(ReifiedTypeParameterSubstitutionChecker(), JsModuleCallChecker),
|
||||
additionalTypeCheckers = listOf(),
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ private val DIAGNOSTIC_FACTORY_TO_RENDERER by lazy {
|
||||
put(ErrorsJs.NOT_SUPPORTED, "Cannot translate (not supported yet): ''{0}''", RenderFirstLineOfElementText)
|
||||
put(ErrorsJs.REFERENCE_TO_BUILTIN_MEMBERS_NOT_SUPPORTED, "Callable references for builtin members are not supported yet: ''{0}''", RenderFirstLineOfElementText)
|
||||
put(ErrorsJs.JSCODE_NO_JAVASCRIPT_PRODUCED, "Argument must be non-empty JavaScript code")
|
||||
put(ErrorsJs.NATIVE_INNER_CLASS_PROHIBITED, "Native inner classes are prohibited")
|
||||
put(ErrorsJs.NESTED_EXTERNAL_DECLARATION, "Non top-level `external` declaration")
|
||||
put(ErrorsJs.JS_NAME_CLASH, "JavaScript name ({0}) generated for this declaration clashes with another declaration: {1}",
|
||||
Renderers.STRING, Renderers.COMPACT)
|
||||
put(ErrorsJs.JS_FAKE_NAME_CLASH, "JavaScript name {0} is generated for different inherited members: {1} and {2}",
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface ErrorsJs {
|
||||
DiagnosticFactory1<KtElement, KtElement> NOT_SUPPORTED = DiagnosticFactory1.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory1<KtElement, KtElement> REFERENCE_TO_BUILTIN_MEMBERS_NOT_SUPPORTED = DiagnosticFactory1.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory0<KtExpression> JSCODE_NO_JAVASCRIPT_PRODUCED = DiagnosticFactory0.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory0<KtExpression> NATIVE_INNER_CLASS_PROHIBITED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> NESTED_EXTERNAL_DECLARATION = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
|
||||
DiagnosticFactory2<KtElement, String, DeclarationDescriptor> JS_NAME_CLASH = DiagnosticFactory2.create(
|
||||
ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
|
||||
DiagnosticFactory3<KtElement, String, DeclarationDescriptor, DeclarationDescriptor> JS_FAKE_NAME_CLASH =
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.js.resolve.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.js.PredefinedAnnotation
|
||||
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.checkers.SimpleDeclarationChecker
|
||||
|
||||
class JsExternalChecker : SimpleDeclarationChecker {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext) {
|
||||
if (!AnnotationsUtils.isNativeObject(descriptor)) return
|
||||
|
||||
if (!DescriptorUtils.isTopLevelDeclaration(descriptor)) {
|
||||
if (isDirectlyExternal(declaration, descriptor) && descriptor !is PropertyAccessorDescriptor) {
|
||||
diagnosticHolder.report(ErrorsJs.NESTED_EXTERNAL_DECLARATION.on(declaration))
|
||||
}
|
||||
}
|
||||
|
||||
if (DescriptorUtils.isAnnotationClass(descriptor)) {
|
||||
diagnosticHolder.report(Errors.WRONG_MODIFIER_TARGET.on(declaration, KtTokens.EXTERNAL_KEYWORD, "annotation class"))
|
||||
}
|
||||
else if (descriptor is PropertyAccessorDescriptor && isDirectlyExternal(declaration, descriptor)) {
|
||||
diagnosticHolder.report(Errors.WRONG_MODIFIER_TARGET.on(declaration, KtTokens.EXTERNAL_KEYWORD, "property accessor"))
|
||||
}
|
||||
}
|
||||
|
||||
private fun isDirectlyExternal(declaration: KtDeclaration, descriptor: DeclarationDescriptor): Boolean {
|
||||
if (declaration is KtProperty && descriptor is PropertyAccessorDescriptor) return false
|
||||
|
||||
return declaration.hasModifier(KtTokens.EXTERNAL_KEYWORD) ||
|
||||
AnnotationsUtils.hasAnnotation(descriptor, PredefinedAnnotation.NATIVE)
|
||||
}
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.js.resolve.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.checkers.SimpleDeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
|
||||
class NativeInnerClassChecker : SimpleDeclarationChecker {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext) {
|
||||
if (descriptor !is ClassDescriptor || !AnnotationsUtils.isNativeObject(descriptor)) return
|
||||
|
||||
if (descriptor.isInner && !AnnotationsUtils.isNativeObject(DescriptorUtils.getContainingClass(descriptor)!!)) {
|
||||
diagnosticHolder.report(ErrorsJs.NATIVE_INNER_CLASS_PROHIBITED.on(declaration))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("WRONG_MODIFIER_TARGET")
|
||||
package kotlin.js
|
||||
|
||||
import kotlin.annotation.AnnotationTarget.*
|
||||
|
||||
@@ -20,28 +20,28 @@ import kotlin.annotation.AnnotationTarget.*
|
||||
|
||||
@Target(CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, VALUE_PARAMETER, PROPERTY_GETTER, PROPERTY_SETTER)
|
||||
@Deprecated("Use `external` modifier instead")
|
||||
public external annotation class native(@Deprecated public val name: String = "")
|
||||
public annotation class native(@Deprecated public val name: String = "")
|
||||
|
||||
@Target(FUNCTION)
|
||||
@Deprecated("Use inline extension function with body using dynamic")
|
||||
public external annotation class nativeGetter
|
||||
public annotation class nativeGetter
|
||||
|
||||
@Target(FUNCTION)
|
||||
@Deprecated("Use inline extension function with body using dynamic")
|
||||
public external annotation class nativeSetter
|
||||
public annotation class nativeSetter
|
||||
|
||||
@Target(FUNCTION)
|
||||
@Deprecated("Use inline extension function with body using dynamic")
|
||||
public external annotation class nativeInvoke
|
||||
public annotation class nativeInvoke
|
||||
|
||||
@Target(CLASS, FUNCTION, PROPERTY)
|
||||
internal external annotation class library(public val name: String = "")
|
||||
internal annotation class library(public val name: String = "")
|
||||
|
||||
@Target(PROPERTY)
|
||||
public external annotation class enumerable()
|
||||
public annotation class enumerable()
|
||||
|
||||
@Target(CLASS)
|
||||
internal external annotation class marker
|
||||
internal annotation class marker
|
||||
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@Target(CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, PROPERTY_GETTER, PROPERTY_SETTER)
|
||||
|
||||
@@ -29,10 +29,10 @@ package kotlin
|
||||
|
||||
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FIELD)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
public external annotation class Volatile
|
||||
public annotation class Volatile
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
public external annotation class Synchronized
|
||||
public annotation class Synchronized
|
||||
|
||||
public external inline fun <R> synchronized(lock: Any, crossinline block: () -> R): R = block()
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package org.junit
|
||||
|
||||
public external annotation class Test(val name: String = "")
|
||||
public annotation class Test(val name: String = "")
|
||||
|
||||
+42
-18
@@ -23,17 +23,22 @@ private external fun private_baz(a: String) {
|
||||
public class PublicClass {
|
||||
public fun public_baz(i: Int) {
|
||||
}
|
||||
public external fun public_baz(a: String) {
|
||||
@JsName("public_baz")
|
||||
public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
internal external fun internal_baz(a: String) {
|
||||
|
||||
@JsName("internal_baz")
|
||||
internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
}
|
||||
private external fun private_baz(a: String) {
|
||||
|
||||
@JsName("private_baz")
|
||||
private fun private_baz(a: String) {
|
||||
}
|
||||
|
||||
val call_private_baz = { private_baz(0) }
|
||||
@@ -43,17 +48,23 @@ public class PublicClass {
|
||||
internal class InternalClass {
|
||||
public fun public_baz(i: Int) {
|
||||
}
|
||||
public external fun public_baz(a: String) {
|
||||
|
||||
@JsName("public_baz")
|
||||
public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
internal external fun internal_baz(a: String) {
|
||||
|
||||
@JsName("internal_baz")
|
||||
internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
}
|
||||
private external fun private_baz(a: String) {
|
||||
|
||||
@JsName("private_baz")
|
||||
private fun private_baz(a: String) {
|
||||
}
|
||||
|
||||
val call_private_baz = { private_baz(0) }
|
||||
@@ -63,17 +74,21 @@ internal class InternalClass {
|
||||
private class PrivateClass {
|
||||
public fun public_baz(i: Int) {
|
||||
}
|
||||
public external fun public_baz(a: String) {
|
||||
|
||||
@JsName("public_baz")
|
||||
public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
internal external fun internal_baz(a: String) {
|
||||
@JsName("internal_baz")
|
||||
internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
}
|
||||
private external fun private_baz(a: String) {
|
||||
@JsName("private_baz")
|
||||
private fun private_baz(a: String) {
|
||||
}
|
||||
|
||||
val call_private_baz = { private_baz(0) }
|
||||
@@ -83,17 +98,20 @@ private class PrivateClass {
|
||||
open public class OpenPublicClass {
|
||||
public fun public_baz(i: Int) {
|
||||
}
|
||||
public external fun public_baz(a: String) {
|
||||
@JsName("public_baz")
|
||||
public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
internal external fun internal_baz(a: String) {
|
||||
@JsName("internal_baz")
|
||||
internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
}
|
||||
private external fun private_baz(a: String) {
|
||||
@JsName("private_baz")
|
||||
private fun private_baz(a: String) {
|
||||
}
|
||||
|
||||
val call_private_baz = { private_baz(0) }
|
||||
@@ -103,17 +121,20 @@ open public class OpenPublicClass {
|
||||
internal open class OpenInternalClass {
|
||||
public fun public_baz(i: Int) {
|
||||
}
|
||||
public external fun public_baz(a: String) {
|
||||
@JsName("public_baz")
|
||||
public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
internal external fun internal_baz(a: String) {
|
||||
@JsName("internal_baz")
|
||||
internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
}
|
||||
private external fun private_baz(a: String) {
|
||||
@JsName("private_baz")
|
||||
private fun private_baz(a: String) {
|
||||
}
|
||||
|
||||
val call_private_baz = { private_baz(0) }
|
||||
@@ -123,17 +144,20 @@ internal open class OpenInternalClass {
|
||||
open private class OpenPrivateClass {
|
||||
public fun public_baz(i: Int) {
|
||||
}
|
||||
public external fun public_baz(a: String) {
|
||||
@JsName("public_baz")
|
||||
public fun public_baz(a: String) {
|
||||
}
|
||||
|
||||
internal fun internal_baz(i: Int) {
|
||||
}
|
||||
internal external fun internal_baz(a: String) {
|
||||
@JsName("internal_baz")
|
||||
internal fun internal_baz(a: String) {
|
||||
}
|
||||
|
||||
private fun private_baz(i: Int) {
|
||||
}
|
||||
private external fun private_baz(a: String) {
|
||||
@JsName("private_baz")
|
||||
private fun private_baz(a: String) {
|
||||
}
|
||||
|
||||
val call_private_baz = { private_baz(0) }
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package foo
|
||||
|
||||
external class A(val c: Int) {
|
||||
external companion object {
|
||||
val g: Int = noImpl
|
||||
companion object {
|
||||
val g: Int
|
||||
val c: String = noImpl
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user