Added language feature check for inline properties
This commit is contained in:
@@ -27,6 +27,7 @@ enum class LanguageFeature(val sinceVersion: LanguageVersion) {
|
|||||||
Coroutines(KOTLIN_1_1),
|
Coroutines(KOTLIN_1_1),
|
||||||
AdditionalBuiltInsMembers(KOTLIN_1_1),
|
AdditionalBuiltInsMembers(KOTLIN_1_1),
|
||||||
DataClassInheritance(KOTLIN_1_1),
|
DataClassInheritance(KOTLIN_1_1),
|
||||||
|
InlineProperties(KOTLIN_1_1)
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ object ModifierCheckerCore {
|
|||||||
|
|
||||||
val featureDependencies = mapOf(
|
val featureDependencies = mapOf(
|
||||||
COROUTINE_KEYWORD to LanguageFeature.Coroutines,
|
COROUTINE_KEYWORD to LanguageFeature.Coroutines,
|
||||||
SUSPEND_KEYWORD to LanguageFeature.Coroutines
|
SUSPEND_KEYWORD to LanguageFeature.Coroutines,
|
||||||
|
INLINE_KEYWORD to LanguageFeature.InlineProperties
|
||||||
)
|
)
|
||||||
|
|
||||||
// NOTE: deprecated targets must be possible!
|
// NOTE: deprecated targets must be possible!
|
||||||
@@ -252,12 +253,17 @@ object ModifierCheckerCore {
|
|||||||
private fun checkLanguageLevelSupport(
|
private fun checkLanguageLevelSupport(
|
||||||
trace: BindingTrace,
|
trace: BindingTrace,
|
||||||
node: ASTNode,
|
node: ASTNode,
|
||||||
languageFeatureSettings: LanguageFeatureSettings
|
languageFeatureSettings: LanguageFeatureSettings,
|
||||||
|
actualTargets: List<KotlinTarget>
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val modifier = node.elementType as KtModifierKeywordToken
|
val modifier = node.elementType as KtModifierKeywordToken
|
||||||
|
|
||||||
val dependency = featureDependencies[modifier] ?: return true
|
val dependency = featureDependencies[modifier] ?: return true
|
||||||
|
|
||||||
if (!languageFeatureSettings.supportsFeature(dependency)) {
|
if (!languageFeatureSettings.supportsFeature(dependency)) {
|
||||||
|
if (dependency == LanguageFeature.InlineProperties && actualTargets.size == 1 && actualTargets.contains(FUNCTION)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
trace.report(Errors.UNSUPPORTED_FEATURE.on(node.psi, dependency))
|
trace.report(Errors.UNSUPPORTED_FEATURE.on(node.psi, dependency))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -313,7 +319,7 @@ object ModifierCheckerCore {
|
|||||||
else if (!checkParent(trace, second, parentDescriptor)) {
|
else if (!checkParent(trace, second, parentDescriptor)) {
|
||||||
incorrectNodes += second
|
incorrectNodes += second
|
||||||
}
|
}
|
||||||
else if (!checkLanguageLevelSupport(trace, second, languageFeatureSettings)) {
|
else if (!checkLanguageLevelSupport(trace, second, languageFeatureSettings, actualTargets)) {
|
||||||
incorrectNodes += second
|
incorrectNodes += second
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// !LANGUAGE: -InlineProperties
|
||||||
|
var value: Int = 0
|
||||||
|
|
||||||
|
<!UNSUPPORTED_FEATURE!>inline<!> var z: Int
|
||||||
|
get() = ++value
|
||||||
|
set(p: Int) { value = p }
|
||||||
|
|
||||||
|
|
||||||
|
var z2: Int
|
||||||
|
<!UNSUPPORTED_FEATURE!>inline<!> get() = ++value
|
||||||
|
<!UNSUPPORTED_FEATURE!>inline<!> set(p: Int) { value = p }
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public var value: kotlin.Int
|
||||||
|
public var z: kotlin.Int
|
||||||
|
public var z2: kotlin.Int
|
||||||
@@ -18660,6 +18660,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noInlineProperty.kt")
|
||||||
|
public void testNoInlineProperty() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/sourceCompatibility/noInlineProperty.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noLocalDelegatedProperty.kt")
|
@TestMetadata("noLocalDelegatedProperty.kt")
|
||||||
public void testNoLocalDelegatedProperty() throws Exception {
|
public void testNoLocalDelegatedProperty() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/sourceCompatibility/noLocalDelegatedProperty.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/sourceCompatibility/noLocalDelegatedProperty.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user