diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt index d62b7f9532b..68620f9e696 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt @@ -354,7 +354,7 @@ class KtPsiFactory @JvmOverloads constructor(private val project: Project, val m } fun createModifierList(@NonNls text: String): KtModifierList { - return createProperty("$text val x").modifierList!! + return createClass("$text interface x").modifierList!! } fun createEmptyModifierList() = createModifierList(KtTokens.PRIVATE_KEYWORD).apply { firstChild.delete() } diff --git a/compiler/tests/org/jetbrains/kotlin/psi/KtPsiFactoryTest.kt b/compiler/tests/org/jetbrains/kotlin/psi/KtPsiFactoryTest.kt new file mode 100644 index 00000000000..533c8316a01 --- /dev/null +++ b/compiler/tests/org/jetbrains/kotlin/psi/KtPsiFactoryTest.kt @@ -0,0 +1,29 @@ +/* + * 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.psi + +import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles +import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment +import org.jetbrains.kotlin.lexer.KtTokens +import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.test.KotlinTestWithEnvironment +import org.junit.Assert + +class KtPsiFactoryTest : KotlinTestWithEnvironment() { + fun testCreateModifierList() { + val psiFactory = KtPsiFactory(project) + KtTokens.MODIFIER_KEYWORDS_ARRAY.forEach { + val modifier = psiFactory.createModifierList(it) + Assert.assertTrue(modifier.hasModifier(it)) + } + } + + override fun createEnvironment(): KotlinCoreEnvironment { + return KotlinCoreEnvironment.createForTests( + testRootDisposable, KotlinTestUtils.newConfiguration(), EnvironmentConfigFiles.JVM_CONFIG_FILES + ) + } +}