Fix wrong "InlineProperties are unsupported at this language level" error on inline functions when inline properties are disabled

This commit is contained in:
Michael Bogdanov
2016-09-07 15:47:21 +03:00
parent 3ad451e33e
commit 8d2ffb2dab
4 changed files with 41 additions and 1 deletions
@@ -98,6 +98,10 @@ object ModifierCheckerCore {
INLINE_KEYWORD to LanguageFeature.InlineProperties
)
val featureDependenciesTargets = mapOf(
LanguageFeature.InlineProperties to setOf(PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER)
)
// NOTE: deprecated targets must be possible!
private val deprecatedTargetMap = mapOf<KtModifierKeywordToken, Set<KotlinTarget>>()
@@ -261,7 +265,8 @@ object ModifierCheckerCore {
val dependency = featureDependencies[modifier] ?: return true
if (!languageFeatureSettings.supportsFeature(dependency)) {
if (dependency == LanguageFeature.InlineProperties && actualTargets.size == 1 && actualTargets.contains(FUNCTION)) {
val restrictedTargets = featureDependenciesTargets[dependency]
if (restrictedTargets != null && actualTargets.intersect(restrictedTargets).isEmpty()) {
return true
}
trace.report(Errors.UNSUPPORTED_FEATURE.on(node.psi, dependency))
@@ -0,0 +1,16 @@
// !DIAGNOSTICS: -NOTHING_TO_INLINE
// !LANGUAGE: -InlineProperties
inline fun String.test() {
}
inline fun test() {
}
class A {
inline fun String.test() {
}
inline fun test() {
}
}
@@ -0,0 +1,13 @@
package
public inline fun test(): kotlin.Unit
public inline fun kotlin.String.test(): kotlin.Unit
public final class A {
public constructor A()
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 final inline fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final inline fun kotlin.String.test(): kotlin.Unit
}
@@ -19077,6 +19077,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/sourceCompatibility"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("inlineFunctionAlways.kt")
public void testInlineFunctionAlways() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/sourceCompatibility/inlineFunctionAlways.kt");
doTest(fileName);
}
@TestMetadata("noDataClassInheritance.kt")
public void testNoDataClassInheritance() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/sourceCompatibility/noDataClassInheritance.kt");