Revert "KT-8263: Conditional operators are not parsed correctly"

This reverts commit ec8da2033c.

For the reason for the revert see KT-53719

^KT-8263 Open
^KT-53719 Fixed
This commit is contained in:
Denis.Zharkov
2022-08-25 18:13:21 +02:00
committed by teamcity
parent 154e53c701
commit 211d662708
37 changed files with 220 additions and 4849 deletions
@@ -235,7 +235,6 @@ public interface Errors {
DiagnosticFactoryForDeprecation1<PsiElement, CallableDescriptor> PROGRESSIONS_CHANGING_RESOLVE = DiagnosticFactoryForDeprecation1.create(LanguageFeature.ProgressionsChangingResolve);
DiagnosticFactory0<PsiElement> EXPRESSION_AFTER_TYPE_REFERENCE_WITHOUT_SPACING_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> TYPE_ARGUMENT_LIST_LIKE_EXPRESSION = DiagnosticFactory0.create(ERROR);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -629,7 +629,6 @@ public class DefaultErrorMessages {
"See https://youtrack.jetbrains.com/issue/KT-49276 for more details. " +
"Please specify a progression type of argument explicitly through explicit cast to resolve to a proper declaration", COMPACT);
MAP.put(EXPRESSION_AFTER_TYPE_REFERENCE_WITHOUT_SPACING_NOT_ALLOWED, "Expression body directly after type without a whitespace in-between the '>=' is only allowed since version 1.8");
MAP.put(TYPE_ARGUMENT_LIST_LIKE_EXPRESSION, "Type argument list like expressions are only allowed since version 1.8");
MAP.put(TOO_MANY_ARGUMENTS, "Too many arguments for {0}", FQ_NAMES_IN_TYPES);
@@ -54,7 +54,6 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf(
UnsupportedUntilRangeDeclarationChecker,
DataObjectContentChecker,
ExpressionAfterTypeParameterWithoutSpacingChecker,
TypeArgumentListLikeExpressionsChecker,
)
private val DEFAULT_CALL_CHECKERS = listOf(
@@ -1,50 +0,0 @@
/*
* 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.checkers
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.children
object TypeArgumentListLikeExpressionsChecker : DeclarationChecker {
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
if (context.languageVersionSettings.supportsFeature(LanguageFeature.AllowTypeArgumentListLikeExpressions)) return
if (declaration.parent !is KtFile) return
val visitor = object : KtTreeVisitorVoid() {
override fun visitBinaryExpression(expression: KtBinaryExpression) {
super.visitBinaryExpression(expression)
if (wasTypeArgumentListLikeExpression(expression)) {
context.trace.report(Errors.TYPE_ARGUMENT_LIST_LIKE_EXPRESSION.on(expression.operationReference))
}
}
override fun visitUserType(type: KtUserType) {
super.visitUserType(type)
if (wasTypeArgumentListLikeExpression(type)) {
var parent = type.parent ?: return
while (parent !is KtBinaryExpression) {
parent = parent.parent ?: return
}
context.trace.report(Errors.TYPE_ARGUMENT_LIST_LIKE_EXPRESSION.on(parent.operationReference))
}
}
private fun wasTypeArgumentListLikeExpression(element: KtElement): Boolean {
return element.node.children().any { it.elementType == KtNodeTypes.TYPE_ARGUMENT_LIST_LIKE_EXPRESSION }
}
}
declaration.accept(visitor)
}
}