[FIR] KT-54260: Fix the compiler crash
AllOpen plugin makes the properties all-open, but the annotation class is left closed, because allopen for k2 literally checks `classKind == CLASS`. Since the properties are open, a `NON_FINAL_MEMBER_IN_FINAL_CLASS` diagnostic is reported for them. It's positioning strategy seeks for the explicit `open` modifier which is not present. The added test should not crash the compiler. ^KT-54260 Fixed
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.allopen
|
||||
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
|
||||
import org.jetbrains.kotlin.test.runners.AbstractFirDiagnosticTest
|
||||
import org.jetbrains.kotlin.test.runners.configurationForClassicAndFirTestsAlongside
|
||||
|
||||
abstract class AbstractFirDiagnosticTestForAllOpen : AbstractFirDiagnosticTest() {
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
|
||||
with(builder) {
|
||||
useConfigurators(::AllOpenEnvironmentConfigurator)
|
||||
configurationForClassicAndFirTestsAlongside()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractFirDiagnosticsWithLightTreeTestForAllOpen : AbstractFirDiagnosticTestForAllOpen() {
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
|
||||
with(builder) {
|
||||
defaultDirectives {
|
||||
+FirDiagnosticsDirectives.USE_LIGHT_TREE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
|
||||
annotation class AllOpen
|
||||
|
||||
@AllOpen
|
||||
annotation class ConsoleCommands(
|
||||
val <!NON_FINAL_MEMBER_IN_FINAL_CLASS!>value<!>: String = "",
|
||||
val <!NON_FINAL_MEMBER_IN_FINAL_CLASS!>scope<!>: String
|
||||
)
|
||||
Generated
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.allopen;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateTestsKt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("plugins/allopen/testData/diagnostics")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FirDiagnosticTestForAllOpenGenerated extends AbstractFirDiagnosticTestForAllOpen {
|
||||
@Test
|
||||
public void testAllFilesPresentInDiagnostics() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/allopen/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt54260.kt")
|
||||
public void testKt54260() throws Exception {
|
||||
runTest("plugins/allopen/testData/diagnostics/kt54260.kt");
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.allopen;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateTestsKt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("plugins/allopen/testData/diagnostics")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FirDiagnosticsWithLightTreeTestForAllOpenGenerated extends AbstractFirDiagnosticsWithLightTreeTestForAllOpen {
|
||||
@Test
|
||||
public void testAllFilesPresentInDiagnostics() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/allopen/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt54260.kt")
|
||||
public void testKt54260() throws Exception {
|
||||
runTest("plugins/allopen/testData/diagnostics/kt54260.kt");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user