From f69e96b2402e92db6ccc5445f0dd5d49c4110812 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 21 Jul 2017 14:30:14 +0300 Subject: [PATCH] Fix IAE at protoDifferenceUtils.kt on new metadata field The class_local_variable/package_local_variable JVM extensions were added in 616d575fb6c #KT-19155 Fixed --- .../kotlin/incremental/protoDifferenceUtils.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/build-common/src/org/jetbrains/kotlin/incremental/protoDifferenceUtils.kt b/build-common/src/org/jetbrains/kotlin/incremental/protoDifferenceUtils.kt index c33f64b8489..912ac97f107 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/protoDifferenceUtils.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/protoDifferenceUtils.kt @@ -186,7 +186,8 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot } for (kind in diff) { - when (kind!!) { + @Suppress("UNUSED_VARIABLE") // To make this 'when' exhaustive + val unused: Any = when (kind!!) { ProtoBufClassKind.COMPANION_OBJECT_NAME -> { if (oldProto.hasCompanionObjectName()) oldProto.companionObjectName.oldToNames() if (newProto.hasCompanionObjectName()) newProto.companionObjectName.newToNames() @@ -203,10 +204,7 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot } ProtoBufClassKind.CONSTRUCTOR_LIST -> { val differentNonPrivateConstructors = calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getConstructorList) - - if (differentNonPrivateConstructors.isNotEmpty()) { - isClassAffected = true - } + isClassAffected = isClassAffected || differentNonPrivateConstructors.isNotEmpty() } ProtoBufClassKind.FUNCTION_LIST -> names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Class::getFunctionList)) @@ -238,6 +236,9 @@ private class DifferenceCalculatorForClass(oldData: ProtoMapValue, newData: Prot ProtoBufClassKind.CLASS_MODULE_NAME -> { // TODO } + ProtoBufClassKind.CLASS_LOCAL_VARIABLE_LIST -> { + // Not affected, local variables are not accessible outside of a file + } } } @@ -267,7 +268,8 @@ private class DifferenceCalculatorForPackageFacade(oldData: ProtoMapValue, newDa } for (kind in diff) { - when (kind!!) { + @Suppress("UNUSED_VARIABLE") // To make this 'when' exhaustive + val unused: Any = when (kind!!) { ProtoBufPackageKind.FUNCTION_LIST -> names.addAll(calcDifferenceForNonPrivateMembers(ProtoBuf.Package::getFunctionList)) ProtoBufPackageKind.PROPERTY_LIST -> @@ -279,7 +281,9 @@ private class DifferenceCalculatorForPackageFacade(oldData: ProtoMapValue, newDa ProtoBufPackageKind.PACKAGE_MODULE_NAME -> { // TODO } - else -> throw IllegalArgumentException("Unsupported kind: $kind") + ProtoBufPackageKind.PACKAGE_LOCAL_VARIABLE_LIST -> { + // Not affected, local variables are not accessible outside of a file + } } }