Add test about platform static checks in ide

This commit is contained in:
Nikolay Krasko
2014-11-25 01:30:44 +03:00
committed by Nikolay Krasko
parent 700187cce6
commit 722624f0a4
3 changed files with 65 additions and 2 deletions
@@ -44,8 +44,8 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
static {
MAP.put(ErrorsJvm.CONFLICTING_JVM_DECLARATIONS, "Platform declaration clash: {0}", CONFLICTING_JVM_DECLARATIONS_DATA);
MAP.put(ErrorsJvm.ACCIDENTAL_OVERRIDE, "Accidental override: {0}", CONFLICTING_JVM_DECLARATIONS_DATA);
MAP.put(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and class objects of classes can be annotated with ''platformStatic''");
MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override cannot be ''platformStatic'' in object");
MAP.put(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and class objects of classes can be annotated with 'platformStatic'");
MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override cannot be 'platformStatic' in object");
MAP.put(ErrorsJvm.PLATFORM_STATIC_ILLEGAL_USAGE, "This declaration does not support ''platformStatic''", DescriptorRenderer.SHORT_NAMES_IN_TYPES);
}
@@ -0,0 +1,57 @@
import kotlin.platform.platformStatic
platformStatic
class <error descr="[PLATFORM_STATIC_ILLEGAL_USAGE] This declaration does not support 'platformStatic'">A</error> {
platformStatic
<error descr="[PLATFORM_STATIC_ILLEGAL_USAGE] This declaration does not support 'platformStatic'">class object</error> {
platformStatic fun a1() {
}
}
platformStatic
<error descr="[PLATFORM_STATIC_ILLEGAL_USAGE] This declaration does not support 'platformStatic'">object A</error> {
platformStatic fun a2() {
}
}
fun test() {
val <warning descr="[UNUSED_VARIABLE] Variable 's' is never used">s</warning> = object {
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and class objects of classes can be annotated with 'platformStatic'">platformStatic fun a3()</error> {
}
}
}
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and class objects of classes can be annotated with 'platformStatic'">platformStatic fun a4()</error> {
}
}
platformStatic
trait <error descr="[PLATFORM_STATIC_ILLEGAL_USAGE] This declaration does not support 'platformStatic'">B</error> {
class object {
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and class objects of classes can be annotated with 'platformStatic'">platformStatic fun a1()</error> {
}
}
object A {
platformStatic fun a2() {
}
}
fun test() {
val <warning descr="[UNUSED_VARIABLE] Variable 's' is never used">s</warning> = object {
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and class objects of classes can be annotated with 'platformStatic'">platformStatic fun a3()</error> {
}
}
}
<error descr="[PLATFORM_STATIC_NOT_IN_OBJECT] Only functions in named objects and class objects of classes can be annotated with 'platformStatic'">platformStatic fun a4()</error> {
}
}
@@ -225,6 +225,12 @@ public class JetPsiCheckerTestGenerated extends AbstractJetPsiCheckerTest {
doTest(fileName);
}
@TestMetadata("PlatformStaticUsagesRuntime.kt")
public void testPlatformStaticUsagesRuntime() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/checker/PlatformStaticUsagesRuntime.kt");
doTest(fileName);
}
@TestMetadata("PrimaryConstructors.kt")
public void testPrimaryConstructors() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/checker/PrimaryConstructors.kt");