Compiler&plugin deprecations cleanup: withIndices -> withIndex or mapIndexed

This commit is contained in:
Ilya Gorbunov
2015-06-25 21:25:59 +03:00
parent f4651f22ca
commit 765733b791
5 changed files with 6 additions and 7 deletions
@@ -265,8 +265,7 @@ public class TypeResolver(
} }
private fun resolveTypeProjections(c: TypeResolutionContext, constructor: TypeConstructor, argumentElements: List<JetTypeProjection>): List<TypeProjection> { private fun resolveTypeProjections(c: TypeResolutionContext, constructor: TypeConstructor, argumentElements: List<JetTypeProjection>): List<TypeProjection> {
return argumentElements.withIndices().map { return argumentElements.mapIndexed { i, argumentElement ->
val (i, argumentElement) = it
val projectionKind = argumentElement.getProjectionKind() val projectionKind = argumentElement.getProjectionKind()
ModifiersChecker.checkIncompatibleVarianceModifiers(argumentElement.getModifierList(), c.trace) ModifiersChecker.checkIncompatibleVarianceModifiers(argumentElement.getModifierList(), c.trace)
@@ -172,7 +172,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
private fun valueParameters(callable: Callable, kind: AnnotatedCallableKind): List<ValueParameterDescriptor> { private fun valueParameters(callable: Callable, kind: AnnotatedCallableKind): List<ValueParameterDescriptor> {
val containerOfCallable = c.containingDeclaration.getContainingDeclaration().asProtoContainer() val containerOfCallable = c.containingDeclaration.getContainingDeclaration().asProtoContainer()
return callable.getValueParameterList().withIndices().map { val (i, proto) = it return callable.getValueParameterList().mapIndexed { i, proto ->
ValueParameterDescriptorImpl( ValueParameterDescriptorImpl(
c.containingDeclaration, null, i, c.containingDeclaration, null, i,
getParameterAnnotations(containerOfCallable, callable, kind, proto), getParameterAnnotations(containerOfCallable, callable, kind, proto),
@@ -41,7 +41,7 @@ public class TypeDeserializer(
} }
else { else {
val result = LinkedHashMap<Int, TypeParameterDescriptor>() val result = LinkedHashMap<Int, TypeParameterDescriptor>()
for ((index, proto) in typeParameterProtos.withIndices()) { for ((index, proto) in typeParameterProtos.withIndex()) {
result[proto.getId()] = DeserializedTypeParameterDescriptor(c, proto, index) result[proto.getId()] = DeserializedTypeParameterDescriptor(c, proto, index)
} }
result result
@@ -352,7 +352,7 @@ fun Class<Any>.findConstructor(methodDesc: MethodDescription): Constructor<Any?>
fun MethodDescription.matches(ctor: Constructor<*>): Boolean { fun MethodDescription.matches(ctor: Constructor<*>): Boolean {
val methodParams = ctor.getParameterTypes()!! val methodParams = ctor.getParameterTypes()!!
if (parameterTypes.size() != methodParams.size()) return false if (parameterTypes.size() != methodParams.size()) return false
for ((i, p) in parameterTypes.withIndices()) { for ((i, p) in parameterTypes.withIndex()) {
if (!p.matches(methodParams[i])) return false if (!p.matches(methodParams[i])) return false
} }
@@ -364,7 +364,7 @@ fun MethodDescription.matches(method: Method): Boolean {
val methodParams = method.getParameterTypes()!! val methodParams = method.getParameterTypes()!!
if (parameterTypes.size() != methodParams.size()) return false if (parameterTypes.size() != methodParams.size()) return false
for ((i, p) in parameterTypes.withIndices()) { for ((i, p) in parameterTypes.withIndex()) {
if (!p.matches(methodParams[i])) return false if (!p.matches(methodParams[i])) return false
} }
@@ -30,7 +30,7 @@ public object JetPsiPrecedences {
private val precedence: Map<IElementType, Int> private val precedence: Map<IElementType, Int>
init { init {
val builder = HashMap<IElementType, Int>() val builder = HashMap<IElementType, Int>()
for ((i, record) in JetExpressionParsing.Precedence.values().withIndices()) { for ((i, record) in JetExpressionParsing.Precedence.values().withIndex()) {
for (elementType in record.getOperations().getTypes()) { for (elementType in record.getOperations().getTypes()) {
builder[elementType] = i builder[elementType] = i
} }