Validate JvmPackageName annotation value and placement
- do not allow it to be used together with JvmMultifileClass (otherwise implementation becomes complex) - do not allow to declare classes in a JvmPackageName-annotated file (similarly, the implementation of this would be much harder in the compiler, and there would need to be special support in the IDE) - check that the value is a valid FQ name - do not allow root package just in case
This commit is contained in:
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE
|
||||
// !API_VERSION: 1.2
|
||||
|
||||
// FILE: a.kt
|
||||
<!JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_MULTIFILE_CLASSES!>@file:JvmPackageName("a")<!>
|
||||
@file:JvmMultifileClass
|
||||
package a
|
||||
fun a() {}
|
||||
|
||||
// FILE: b.kt
|
||||
<!JVM_PACKAGE_NAME_CANNOT_BE_EMPTY!>@file:JvmPackageName("")<!>
|
||||
package b
|
||||
fun b() {}
|
||||
|
||||
// FILE: c.kt
|
||||
<!JVM_PACKAGE_NAME_MUST_BE_VALID_NAME!>@file:JvmPackageName("invalid-fq-name")<!>
|
||||
package c
|
||||
fun c() {}
|
||||
|
||||
// FILE: d.kt
|
||||
<!JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_FILES_WITH_CLASSES!>@file:JvmPackageName("d")<!>
|
||||
package d
|
||||
class D
|
||||
fun d() {}
|
||||
|
||||
// FILE: e.kt
|
||||
@file:JvmPackageName(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!>)
|
||||
package e
|
||||
fun e() {}
|
||||
|
||||
// FILE: f.kt
|
||||
@file:JvmPackageName(<!EXPRESSION_EXPECTED_PACKAGE_FOUND!>f<!>)
|
||||
package f
|
||||
const val name = "f"
|
||||
compiler/testData/diagnostics/testsWithStdLib/annotations/jvmPackageName/incorrectJvmPackageName.txt
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
package
|
||||
|
||||
package a {
|
||||
public fun a(): kotlin.Unit
|
||||
}
|
||||
|
||||
package b {
|
||||
public fun b(): kotlin.Unit
|
||||
}
|
||||
|
||||
package c {
|
||||
public fun c(): kotlin.Unit
|
||||
}
|
||||
|
||||
package d {
|
||||
public fun d(): kotlin.Unit
|
||||
|
||||
public final 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
|
||||
}
|
||||
}
|
||||
|
||||
package e {
|
||||
public fun e(): kotlin.Unit
|
||||
}
|
||||
|
||||
package f {
|
||||
public const val name: kotlin.String = "f"
|
||||
}
|
||||
Reference in New Issue
Block a user