[FE 1.0] Introduce "range until operator" language feature, and report errors on its usages till 1.8
This commit is contained in:
committed by
teamcity
parent
de9d1dc536
commit
c266303197
+12
@@ -22359,6 +22359,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/custom.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("customDefault.kt")
|
||||
public void testCustomDefault() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/customDefault.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("customDisabled.kt")
|
||||
public void testCustomDisabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/customDisabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
|
||||
+12
@@ -22359,6 +22359,18 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/custom.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("customDefault.kt")
|
||||
public void testCustomDefault() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/customDefault.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("customDisabled.kt")
|
||||
public void testCustomDisabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/customDisabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
|
||||
+12
@@ -22359,6 +22359,18 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/custom.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("customDefault.kt")
|
||||
public void testCustomDefault() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/customDefault.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("customDisabled.kt")
|
||||
public void testCustomDisabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/customDisabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
|
||||
@@ -68,8 +68,7 @@ private val DEFAULT_CALL_CHECKERS = listOf(
|
||||
UnitConversionCallChecker, FunInterfaceConstructorReferenceChecker, NullableExtensionOperatorWithSafeCallChecker,
|
||||
ReferencingToUnderscoreNamedParameterOfCatchBlockChecker, VarargWrongExecutionOrderChecker, SelfCallInNestedObjectConstructorChecker,
|
||||
NewSchemeOfIntegerOperatorResolutionChecker, EnumEntryVsCompanionPriorityCallChecker, CompanionInParenthesesLHSCallChecker,
|
||||
ResolutionToPrivateConstructorOfSealedClassChecker,
|
||||
EqualityCallChecker,
|
||||
ResolutionToPrivateConstructorOfSealedClassChecker, EqualityCallChecker, UnsupportedUntilOperatorChecker
|
||||
)
|
||||
private val DEFAULT_TYPE_CHECKERS = emptyList<AdditionalTypeChecker>()
|
||||
private val DEFAULT_CLASSIFIER_USAGE_CHECKERS = listOf(
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.resolve.calls.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.UNSUPPORTED_FEATURE
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtOperationReferenceExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
|
||||
object UnsupportedUntilOperatorChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val calleeExpression = resolvedCall.call.calleeExpression as? KtOperationReferenceExpression ?: return
|
||||
val isRangeUntilOperatorSupported = context.languageVersionSettings.supportsFeature(LanguageFeature.RangeUntilOperator)
|
||||
|
||||
if (calleeExpression.operationSignTokenType == KtTokens.RANGE_UNTIL && !isRangeUntilOperatorSupported) {
|
||||
context.trace.report(
|
||||
UNSUPPORTED_FEATURE.on(reportOn, LanguageFeature.RangeUntilOperator to context.languageVersionSettings)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +RangeUntilOperator
|
||||
|
||||
class A {
|
||||
operator fun rangeUntil(other: A): Iterable<A> = TODO()
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class A {
|
||||
operator fun rangeUntil(other: A): Iterable<A> = TODO()
|
||||
}
|
||||
|
||||
fun main(n: A, f: A) {
|
||||
for (i in f<!UNSUPPORTED_FEATURE("The feature "range until operator" is only available since language version 1.8")!>..<<!>n) {
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public fun main(/*0*/ n: A, /*1*/ f: A): 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 operator fun rangeUntil(/*0*/ other: A): kotlin.collections.Iterable<A>
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: -RangeUntilOperator
|
||||
|
||||
class A {
|
||||
operator fun rangeUntil(other: A): Iterable<A> = TODO()
|
||||
}
|
||||
|
||||
fun main(n: A, f: A) {
|
||||
for (i in f..<n) {
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: -RangeUntilOperator
|
||||
|
||||
class A {
|
||||
operator fun rangeUntil(other: A): Iterable<A> = TODO()
|
||||
}
|
||||
|
||||
fun main(n: A, f: A) {
|
||||
for (i in f<!UNSUPPORTED_FEATURE("The feature "range until operator" is only available since language version 1.8")!>..<<!>n) {
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public fun main(/*0*/ n: A, /*1*/ f: A): 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 operator fun rangeUntil(/*0*/ other: A): kotlin.collections.Iterable<A>
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// !LANGUAGE: +RangeUntilOperator
|
||||
|
||||
fun main(n: Int) {
|
||||
for (i in <!ITERATOR_MISSING!>0<!UNRESOLVED_REFERENCE!>..<<!>n<!>) {
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// !LANGUAGE: +RangeUntilOperator
|
||||
|
||||
fun main(n: Int) {
|
||||
for (i in 0<!UNRESOLVED_REFERENCE!>..<<!>n) {
|
||||
|
||||
|
||||
Generated
+12
@@ -22365,6 +22365,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/custom.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("customDefault.kt")
|
||||
public void testCustomDefault() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/customDefault.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("customDisabled.kt")
|
||||
public void testCustomDisabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/until/customDisabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
|
||||
@@ -262,6 +262,7 @@ enum class LanguageFeature(
|
||||
ReportNonVarargSpreadOnGenericCalls(KOTLIN_1_8, kind = BUG_FIX), // KT-48162
|
||||
AllowExpressionAfterTypeReferenceWithoutSpacing(KOTLIN_1_8, kind = BUG_FIX), // KT-35811
|
||||
RefineTypeCheckingOnAssignmentsToJavaFields(KOTLIN_1_8, kind = BUG_FIX),
|
||||
RangeUntilOperator(KOTLIN_1_8), // KT-15613
|
||||
|
||||
// 1.9
|
||||
|
||||
|
||||
Reference in New Issue
Block a user