COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT is an ERROR now.
Migrated code. Updated test data in IDE tests. Dropped whenWithRangeTestsAndMultiConditions.kt: "Introduce subject" is not applicable to 'when' with ||-ed conditions.
This commit is contained in:
@@ -706,7 +706,7 @@ public interface Errors {
|
|||||||
DiagnosticFactory0<KtWhenEntry> ELSE_MISPLACED_IN_WHEN = DiagnosticFactory0.create(ERROR, ELSE_ENTRY);
|
DiagnosticFactory0<KtWhenEntry> ELSE_MISPLACED_IN_WHEN = DiagnosticFactory0.create(ERROR, ELSE_ENTRY);
|
||||||
DiagnosticFactory0<KtWhenExpression> NO_ELSE_IN_WHEN = DiagnosticFactory0.create(ERROR, WHEN_EXPRESSION);
|
DiagnosticFactory0<KtWhenExpression> NO_ELSE_IN_WHEN = DiagnosticFactory0.create(ERROR, WHEN_EXPRESSION);
|
||||||
DiagnosticFactory0<KtWhenExpression> NON_EXHAUSTIVE_WHEN = DiagnosticFactory0.create(WARNING, WHEN_EXPRESSION);
|
DiagnosticFactory0<KtWhenExpression> NON_EXHAUSTIVE_WHEN = DiagnosticFactory0.create(WARNING, WHEN_EXPRESSION);
|
||||||
DiagnosticFactory0<PsiElement> COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT = DiagnosticFactory0.create(WARNING);
|
DiagnosticFactory0<PsiElement> COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
// Type mismatch
|
// Type mismatch
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ public abstract class ReflectJavaType : JavaType {
|
|||||||
fun create(type: Type): ReflectJavaType {
|
fun create(type: Type): ReflectJavaType {
|
||||||
return when {
|
return when {
|
||||||
type is Class<*> && type.isPrimitive() -> ReflectJavaPrimitiveType(type)
|
type is Class<*> && type.isPrimitive() -> ReflectJavaPrimitiveType(type)
|
||||||
type is GenericArrayType, type is Class<*> && type.isArray() -> ReflectJavaArrayType(type)
|
type is GenericArrayType || type is Class<*> && type.isArray() -> ReflectJavaArrayType(type)
|
||||||
type is WildcardType -> ReflectJavaWildcardType(type)
|
type is WildcardType -> ReflectJavaWildcardType(type)
|
||||||
else -> ReflectJavaClassifierType(type)
|
else -> ReflectJavaClassifierType(type)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ public val Class<*>.classId: ClassId
|
|||||||
get() = when {
|
get() = when {
|
||||||
isPrimitive() -> throw IllegalArgumentException("Can't compute ClassId for primitive type: $this")
|
isPrimitive() -> throw IllegalArgumentException("Can't compute ClassId for primitive type: $this")
|
||||||
isArray() -> throw IllegalArgumentException("Can't compute ClassId for array type: $this")
|
isArray() -> throw IllegalArgumentException("Can't compute ClassId for array type: $this")
|
||||||
getEnclosingMethod() != null, getEnclosingConstructor() != null, getSimpleName().isEmpty() -> {
|
getEnclosingMethod() != null || getEnclosingConstructor() != null || getSimpleName().isEmpty() -> {
|
||||||
val fqName = FqName(getName())
|
val fqName = FqName(getName())
|
||||||
ClassId(fqName.parent(), FqName.topLevel(fqName.shortName()), /* local = */ true)
|
ClassId(fqName.parent(), FqName.topLevel(fqName.shortName()), /* local = */ true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ class GenerateProtoBufCompare {
|
|||||||
|
|
||||||
private fun Printer.printlnIfWithComparison(field: Descriptors.FieldDescriptor, expr: String, statement: String = "return false") {
|
private fun Printer.printlnIfWithComparison(field: Descriptors.FieldDescriptor, expr: String, statement: String = "return false") {
|
||||||
val line = when {
|
val line = when {
|
||||||
field.options.getExtension(DebugExtOptionsProtoBuf.stringIdInTable),
|
field.options.getExtension(DebugExtOptionsProtoBuf.stringIdInTable) ||
|
||||||
field.options.getExtension(DebugExtOptionsProtoBuf.nameIdInTable) ->
|
field.options.getExtension(DebugExtOptionsProtoBuf.nameIdInTable) ->
|
||||||
"if (!$CHECK_STRING_EQAULS_NAME(old.$expr, new.$expr)) $statement"
|
"if (!$CHECK_STRING_EQAULS_NAME(old.$expr, new.$expr)) $statement"
|
||||||
field.options.getExtension(DebugExtOptionsProtoBuf.fqNameIdInTable) ->
|
field.options.getExtension(DebugExtOptionsProtoBuf.fqNameIdInTable) ->
|
||||||
@@ -408,7 +408,7 @@ class GenerateProtoBufCompare {
|
|||||||
|
|
||||||
private fun fieldToHashCode(field: Descriptors.FieldDescriptor, expr: String): String =
|
private fun fieldToHashCode(field: Descriptors.FieldDescriptor, expr: String): String =
|
||||||
when {
|
when {
|
||||||
field.options.getExtension(DebugExtOptionsProtoBuf.stringIdInTable),
|
field.options.getExtension(DebugExtOptionsProtoBuf.stringIdInTable) ||
|
||||||
field.options.getExtension(DebugExtOptionsProtoBuf.nameIdInTable) ->
|
field.options.getExtension(DebugExtOptionsProtoBuf.nameIdInTable) ->
|
||||||
"stringIndexes($expr)"
|
"stringIndexes($expr)"
|
||||||
field.options.getExtension(DebugExtOptionsProtoBuf.fqNameIdInTable) ->
|
field.options.getExtension(DebugExtOptionsProtoBuf.fqNameIdInTable) ->
|
||||||
|
|||||||
@@ -170,8 +170,8 @@ public object UsageTypeUtils {
|
|||||||
} ->
|
} ->
|
||||||
if (descriptor is ConstructorDescriptor) CLASS_NEW_OPERATOR else FUNCTION_CALL
|
if (descriptor is ConstructorDescriptor) CLASS_NEW_OPERATOR else FUNCTION_CALL
|
||||||
|
|
||||||
refExpr.getParentOfTypeAndBranch<KtBinaryExpression>(){ getOperationReference() } != null,
|
refExpr.getParentOfTypeAndBranch<KtBinaryExpression>(){ getOperationReference() } != null ||
|
||||||
refExpr.getParentOfTypeAndBranch<KtUnaryExpression>(){ getOperationReference() } != null,
|
refExpr.getParentOfTypeAndBranch<KtUnaryExpression>(){ getOperationReference() } != null ||
|
||||||
refExpr.getParentOfTypeAndBranch<KtWhenConditionInRange>(){ getOperationReference() } != null ->
|
refExpr.getParentOfTypeAndBranch<KtWhenConditionInRange>(){ getOperationReference() } != null ->
|
||||||
FUNCTION_CALL
|
FUNCTION_CALL
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ public object UsageTypeUtils {
|
|||||||
return when (descriptor) {
|
return when (descriptor) {
|
||||||
is ClassifierDescriptor -> when {
|
is ClassifierDescriptor -> when {
|
||||||
// Treat object accesses as variables to simulate the old behaviour (when variables were created for objects)
|
// Treat object accesses as variables to simulate the old behaviour (when variables were created for objects)
|
||||||
DescriptorUtils.isNonCompanionObject(descriptor), DescriptorUtils.isEnumEntry(descriptor) -> getVariableUsageType()
|
DescriptorUtils.isNonCompanionObject(descriptor) || DescriptorUtils.isEnumEntry(descriptor) -> getVariableUsageType()
|
||||||
DescriptorUtils.isCompanionObject(descriptor) -> COMPANION_OBJECT_ACCESS
|
DescriptorUtils.isCompanionObject(descriptor) -> COMPANION_OBJECT_ACCESS
|
||||||
else -> getClassUsageType()
|
else -> getClassUsageType()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -83,7 +83,7 @@ public class KotlinFindClassUsagesHandler(
|
|||||||
public override fun execute(element: PsiClass): Boolean {
|
public override fun execute(element: PsiClass): Boolean {
|
||||||
val isInterface = element.isInterface()
|
val isInterface = element.isInterface()
|
||||||
return when {
|
return when {
|
||||||
isInterface && options.isDerivedInterfaces, !isInterface && options.isDerivedClasses ->
|
isInterface && options.isDerivedInterfaces || !isInterface && options.isDerivedClasses ->
|
||||||
KotlinFindUsagesHandler.processUsage(processor, element.getNavigationElement())
|
KotlinFindUsagesHandler.processUsage(processor, element.getNavigationElement())
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ internal fun getPsiMethod(element: PsiElement?): PsiMethod? {
|
|||||||
return when {
|
return when {
|
||||||
element == null -> null
|
element == null -> null
|
||||||
element is PsiMethod -> element
|
element is PsiMethod -> element
|
||||||
parent is KtNamedFunction, parent is KtSecondaryConstructor -> LightClassUtil.getLightClassMethod(parent as KtFunction)
|
parent is KtNamedFunction || parent is KtSecondaryConstructor -> LightClassUtil.getLightClassMethod(parent as KtFunction)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -529,7 +529,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
|||||||
|
|
||||||
val neighborType = neighbor?.getNode()?.getElementType()
|
val neighborType = neighbor?.getNode()?.getElementType()
|
||||||
val lineBreaksNeeded = when {
|
val lineBreaksNeeded = when {
|
||||||
neighborType == KtTokens.LBRACE, neighborType == KtTokens.RBRACE -> 1
|
neighborType == KtTokens.LBRACE || neighborType == KtTokens.RBRACE -> 1
|
||||||
neighbor is KtDeclaration && (neighbor !is KtProperty || decl !is KtProperty) -> 2
|
neighbor is KtDeclaration && (neighbor !is KtProperty || decl !is KtProperty) -> 2
|
||||||
else -> 1
|
else -> 1
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -86,7 +86,7 @@ object CreateParameterByRefActionFactory : CreateParameterFromUsageFactory<KtSim
|
|||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
?.let {
|
?.let {
|
||||||
when {
|
when {
|
||||||
(it is KtNamedFunction || it is KtSecondaryConstructor) && varExpected,
|
(it is KtNamedFunction || it is KtSecondaryConstructor) && varExpected ||
|
||||||
it is KtPropertyAccessor -> chooseContainingClass(it)
|
it is KtPropertyAccessor -> chooseContainingClass(it)
|
||||||
it is KtAnonymousInitializer -> it.parent?.parent as? KtClass
|
it is KtAnonymousInitializer -> it.parent?.parent as? KtClass
|
||||||
it is KtSuperTypeListEntry -> {
|
it is KtSuperTypeListEntry -> {
|
||||||
|
|||||||
+1
-1
@@ -153,7 +153,7 @@ class KotlinFunctionCallUsage(
|
|||||||
|
|
||||||
private fun needSeparateVariable(element: PsiElement): Boolean {
|
private fun needSeparateVariable(element: PsiElement): Boolean {
|
||||||
return when {
|
return when {
|
||||||
element is KtConstantExpression, element is KtThisExpression, element is KtSimpleNameExpression -> false
|
element is KtConstantExpression || element is KtThisExpression || element is KtSimpleNameExpression -> false
|
||||||
element is KtBinaryExpression && OperatorConventions.ASSIGNMENT_OPERATIONS.contains(element.operationToken) -> true
|
element is KtBinaryExpression && OperatorConventions.ASSIGNMENT_OPERATIONS.contains(element.operationToken) -> true
|
||||||
element is KtUnaryExpression && OperatorConventions.INCREMENT_OPERATIONS.contains(element.operationToken) -> true
|
element is KtUnaryExpression && OperatorConventions.INCREMENT_OPERATIONS.contains(element.operationToken) -> true
|
||||||
element is KtCallExpression -> element.getResolvedCall(context)?.resultingDescriptor is ConstructorDescriptor
|
element is KtCallExpression -> element.getResolvedCall(context)?.resultingDescriptor is ConstructorDescriptor
|
||||||
|
|||||||
+1
-1
@@ -333,7 +333,7 @@ val ControlFlow.possibleReturnTypes: List<KotlinType>
|
|||||||
return when {
|
return when {
|
||||||
!returnType.isNullabilityFlexible() ->
|
!returnType.isNullabilityFlexible() ->
|
||||||
listOf(returnType)
|
listOf(returnType)
|
||||||
returnType.isAnnotatedNotNull(), returnType.isAnnotatedNullable() ->
|
returnType.isAnnotatedNotNull() || returnType.isAnnotatedNullable() ->
|
||||||
listOf(approximateFlexibleTypes(returnType))
|
listOf(approximateFlexibleTypes(returnType))
|
||||||
else ->
|
else ->
|
||||||
returnType.getCapability(javaClass<Flexibility>()).let { listOf(it!!.upperBound, it.lowerBound) }
|
returnType.getCapability(javaClass<Flexibility>()).let { listOf(it!!.upperBound, it.lowerBound) }
|
||||||
|
|||||||
+1
-1
@@ -87,7 +87,7 @@ internal fun ExtractionData.inferParametersInfo(
|
|||||||
val resolvedCall = refInfo.resolveResult.resolvedCall
|
val resolvedCall = refInfo.resolveResult.resolvedCall
|
||||||
val extensionReceiver = resolvedCall?.extensionReceiver
|
val extensionReceiver = resolvedCall?.extensionReceiver
|
||||||
val receiverToExtract = (when {
|
val receiverToExtract = (when {
|
||||||
extensionReceiver == ReceiverValue.NO_RECEIVER,
|
extensionReceiver == ReceiverValue.NO_RECEIVER ||
|
||||||
isSynthesizedInvoke(refInfo.resolveResult.descriptor) -> resolvedCall?.dispatchReceiver
|
isSynthesizedInvoke(refInfo.resolveResult.descriptor) -> resolvedCall?.dispatchReceiver
|
||||||
else -> extensionReceiver
|
else -> extensionReceiver
|
||||||
} as? ReceiverValue) ?: ReceiverValue.NO_RECEIVER
|
} as? ReceiverValue) ?: ReceiverValue.NO_RECEIVER
|
||||||
|
|||||||
+1
-1
@@ -368,7 +368,7 @@ object KotlinIntroduceVariableHandler : KotlinIntroduceHandlerBase() {
|
|||||||
for ((place, parent) in parentsWithSelf.zip(parents)) {
|
for ((place, parent) in parentsWithSelf.zip(parents)) {
|
||||||
when {
|
when {
|
||||||
parent is KtContainerNode && place !is KtBlockExpression && !parent.isBadContainerNode(place) -> result = parent
|
parent is KtContainerNode && place !is KtBlockExpression && !parent.isBadContainerNode(place) -> result = parent
|
||||||
parent is KtClassBody, parent is KtFile -> return result
|
parent is KtClassBody || parent is KtFile -> return result
|
||||||
parent is KtBlockExpression -> result = parent
|
parent is KtBlockExpression -> result = parent
|
||||||
parent is KtWhenEntry && place !is KtBlockExpression -> result = parent
|
parent is KtWhenEntry && place !is KtBlockExpression -> result = parent
|
||||||
parent is KtDeclarationWithBody && parent.bodyExpression == place && place !is KtBlockExpression -> result = parent
|
parent is KtDeclarationWithBody && parent.bodyExpression == place && place !is KtBlockExpression -> result = parent
|
||||||
|
|||||||
@@ -436,8 +436,8 @@ public fun PsiElement.canRefactor(): Boolean {
|
|||||||
return when {
|
return when {
|
||||||
this is PsiPackage ->
|
this is PsiPackage ->
|
||||||
getDirectories().any { it.canRefactor() }
|
getDirectories().any { it.canRefactor() }
|
||||||
this is KtElement,
|
this is KtElement ||
|
||||||
this is PsiMember && getLanguage() == JavaLanguage.INSTANCE,
|
this is PsiMember && getLanguage() == JavaLanguage.INSTANCE ||
|
||||||
this is PsiDirectory ->
|
this is PsiDirectory ->
|
||||||
isWritable() && ProjectRootsUtil.isInProjectSource(this)
|
isWritable() && ProjectRootsUtil.isInProjectSource(this)
|
||||||
else ->
|
else ->
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ public class KotlinMemberInfoStorage(
|
|||||||
descriptor1 is FunctionDescriptor && descriptor is FunctionDescriptor -> {
|
descriptor1 is FunctionDescriptor && descriptor is FunctionDescriptor -> {
|
||||||
!OverloadUtil.isOverloadable(descriptor1, descriptor)
|
!OverloadUtil.isOverloadable(descriptor1, descriptor)
|
||||||
}
|
}
|
||||||
descriptor1 is PropertyDescriptor && descriptor is PropertyDescriptor,
|
descriptor1 is PropertyDescriptor && descriptor is PropertyDescriptor ||
|
||||||
descriptor1 is ClassDescriptor && descriptor is ClassDescriptor -> true
|
descriptor1 is ClassDescriptor && descriptor is ClassDescriptor -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ public class KotlinMoveFilesOrDirectoriesHandler : MoveFilesOrDirectoriesHandler
|
|||||||
private fun adjustElements(elements: Array<out PsiElement>): Array<PsiElement>? {
|
private fun adjustElements(elements: Array<out PsiElement>): Array<PsiElement>? {
|
||||||
return elements.map {
|
return elements.map {
|
||||||
when {
|
when {
|
||||||
it is PsiFile, it is PsiDirectory -> it
|
it is PsiFile || it is PsiDirectory -> it
|
||||||
it is PsiClass && it.getContainingClass() == null -> it.getContainingFile()
|
it is PsiClass && it.getContainingClass() == null -> it.getContainingFile()
|
||||||
it is KtClassOrObject && it.getParent() is KtFile -> it.getParent()
|
it is KtClassOrObject && it.getParent() is KtFile -> it.getParent()
|
||||||
else -> return null
|
else -> return null
|
||||||
|
|||||||
@@ -114,9 +114,9 @@ public fun KtElement.getInternalReferencesToUpdateOnPackageNameChange(packageNam
|
|||||||
val oldPackageName = packageNameInfo.oldPackageName
|
val oldPackageName = packageNameInfo.oldPackageName
|
||||||
val newPackageName = packageNameInfo.newPackageName
|
val newPackageName = packageNameInfo.newPackageName
|
||||||
return when {
|
return when {
|
||||||
isExtension,
|
isExtension ||
|
||||||
packageName == oldPackageName,
|
packageName == oldPackageName ||
|
||||||
packageName?.asString() == newPackageName.asString(),
|
packageName?.asString() == newPackageName.asString() ||
|
||||||
isImported(descriptor) -> {
|
isImported(descriptor) -> {
|
||||||
if (isAncestor(declaration, false)) {
|
if (isAncestor(declaration, false)) {
|
||||||
if (descriptor.importableFqName == null) return null
|
if (descriptor.importableFqName == null) return null
|
||||||
|
|||||||
@@ -176,11 +176,11 @@ public class KotlinPsiUnifier(
|
|||||||
return when {
|
return when {
|
||||||
op1 == op2 ->
|
op1 == op2 ->
|
||||||
true
|
true
|
||||||
op1 == KtTokens.NOT_IN, op2 == KtTokens.NOT_IN ->
|
op1 == KtTokens.NOT_IN || op2 == KtTokens.NOT_IN ->
|
||||||
false
|
false
|
||||||
op1 == KtTokens.EXCLEQ, op2 == KtTokens.EXCLEQ ->
|
op1 == KtTokens.EXCLEQ || op2 == KtTokens.EXCLEQ ->
|
||||||
false
|
false
|
||||||
op1 in OperatorConventions.COMPARISON_OPERATIONS, op2 in OperatorConventions.COMPARISON_OPERATIONS ->
|
op1 in OperatorConventions.COMPARISON_OPERATIONS || op2 in OperatorConventions.COMPARISON_OPERATIONS ->
|
||||||
false
|
false
|
||||||
else ->
|
else ->
|
||||||
true
|
true
|
||||||
@@ -662,7 +662,7 @@ public class KotlinPsiUnifier(
|
|||||||
|
|
||||||
private fun matchResolvedInfo(e1: PsiElement, e2: PsiElement): Status? {
|
private fun matchResolvedInfo(e1: PsiElement, e2: PsiElement): Status? {
|
||||||
return when {
|
return when {
|
||||||
e1 !is KtElement, e2 !is KtElement ->
|
e1 !is KtElement || e2 !is KtElement ->
|
||||||
null
|
null
|
||||||
|
|
||||||
e1 is KtDestructuringDeclaration && e2 is KtDestructuringDeclaration ->
|
e1 is KtDestructuringDeclaration && e2 is KtDestructuringDeclaration ->
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
fun test(n: Int): String {
|
fun test(n: Int): String {
|
||||||
return <caret>when {
|
return <caret>when {
|
||||||
n < 0, n > 1000 -> "unknown"
|
n < 0 || n > 1000 -> "unknown"
|
||||||
n <= 10 -> "small"
|
n <= 10 -> "small"
|
||||||
n <= 100 -> "average"
|
n <= 100 -> "average"
|
||||||
else -> "big"
|
else -> "big"
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ fun test(n: Int): String {
|
|||||||
return <caret>when {
|
return <caret>when {
|
||||||
n in 0..10 -> "small"
|
n in 0..10 -> "small"
|
||||||
n >= 10 && n <= 100 -> "average"
|
n >= 10 && n <= 100 -> "average"
|
||||||
n < 0, n > 1000 -> "unknown"
|
n < 0 || n > 1000 -> "unknown"
|
||||||
else -> "big"
|
else -> "big"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vendored
-8
@@ -1,8 +0,0 @@
|
|||||||
fun test(n: Int): String {
|
|
||||||
return <caret>when {
|
|
||||||
n in 0..5, n in 5..10 -> "small"
|
|
||||||
n in 10..50, n in 50..100 -> "average"
|
|
||||||
n in 100..500, n in 500..1000 -> "big"
|
|
||||||
else -> "unknown"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-8
@@ -1,8 +0,0 @@
|
|||||||
fun test(n: Int): String {
|
|
||||||
return <caret>when (n) {
|
|
||||||
in 0..5, in 5..10 -> "small"
|
|
||||||
in 10..50, in 50..100 -> "average"
|
|
||||||
in 100..500, in 500..1000 -> "big"
|
|
||||||
else -> "unknown"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2062,12 +2062,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("whenWithRangeTestsAndMultiConditions.kt")
|
|
||||||
public void testWhenWithRangeTestsAndMultiConditions() throws Exception {
|
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/branched/when/introduceSubject/whenWithRangeTestsAndMultiConditions.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("whenWithSubject.kt")
|
@TestMetadata("whenWithSubject.kt")
|
||||||
public void testWhenWithSubject() throws Exception {
|
public void testWhenWithSubject() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/branched/when/introduceSubject/whenWithSubject.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/branched/when/introduceSubject/whenWithSubject.kt");
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ public abstract class AbstractProtoComparisonTest : UsefulTestCase() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val diff = when {
|
val diff = when {
|
||||||
newClassHeader.isCompatibleClassKind(),
|
newClassHeader.isCompatibleClassKind() ||
|
||||||
newClassHeader.isCompatibleFileFacadeKind(),
|
newClassHeader.isCompatibleFileFacadeKind() ||
|
||||||
newClassHeader.isCompatibleMultifileClassPartKind() ->
|
newClassHeader.isCompatibleMultifileClassPartKind() ->
|
||||||
difference(oldProto, newProto)
|
difference(oldProto, newProto)
|
||||||
else -> {
|
else -> {
|
||||||
|
|||||||
+4
-4
@@ -10,13 +10,13 @@ fun id(s: String, value: Boolean): Boolean {
|
|||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|
||||||
when {
|
when {
|
||||||
id("A", true), id("B", true) -> 10
|
id("A", true) || id("B", true) -> 10
|
||||||
}
|
}
|
||||||
assertEquals("A", global)
|
assertEquals("A", global)
|
||||||
|
|
||||||
global = ""
|
global = ""
|
||||||
when {
|
when {
|
||||||
id("A", false), id("B", true), id("C", true) -> 10
|
id("A", false) || id("B", true) || id("C", true) -> 10
|
||||||
}
|
}
|
||||||
assertEquals("AB", global)
|
assertEquals("AB", global)
|
||||||
|
|
||||||
@@ -39,14 +39,14 @@ fun box(): String {
|
|||||||
global = ""
|
global = ""
|
||||||
b = true
|
b = true
|
||||||
when {
|
when {
|
||||||
b, try { global += "A"; !b } finally {} -> 10
|
b || try { global += "A"; !b } finally {} -> 10
|
||||||
}
|
}
|
||||||
assertEquals("", global)
|
assertEquals("", global)
|
||||||
|
|
||||||
global = ""
|
global = ""
|
||||||
b = false
|
b = false
|
||||||
when {
|
when {
|
||||||
b, try { global += "A"; !b } finally {} -> 10
|
b || try { global += "A"; !b } finally {} -> 10
|
||||||
}
|
}
|
||||||
assertEquals("A", global)
|
assertEquals("A", global)
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ tailrec fun allSuperTypesImpl(roots: List<GenerateTraitOrClass>, all: Map<String
|
|||||||
|
|
||||||
fun standardTypes() = typeMapper.values.map {it.dropNullable()}.toSet()
|
fun standardTypes() = typeMapper.values.map {it.dropNullable()}.toSet()
|
||||||
fun Type.dynamicIfUnknownType(allTypes: Set<String>, standardTypes: Set<Type> = standardTypes()): Type = when {
|
fun Type.dynamicIfUnknownType(allTypes: Set<String>, standardTypes: Set<Type> = standardTypes()): Type = when {
|
||||||
this is DynamicType, this is UnitType -> this
|
this is DynamicType || this is UnitType -> this
|
||||||
|
|
||||||
this is SimpleType && this.type in allTypes -> this
|
this is SimpleType && this.type in allTypes -> this
|
||||||
this.dropNullable() in standardTypes -> this
|
this.dropNullable() in standardTypes -> this
|
||||||
|
|||||||
Reference in New Issue
Block a user