Skip to content

Commit 19fad7a

Browse files
committed
Remove uses of Collections from scala-reflect
1 parent ad4a6f4 commit 19fad7a

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import dotty.tools.dotc.util.SourceFile
2626
import util.Positions._
2727
import annotation.switch
2828
import scala.collection.mutable.ListBuffer
29-
import scala.reflect.internal.util.Collections._
3029

3130
object JavaParsers {
3231

@@ -136,7 +135,7 @@ object JavaParsers {
136135
ValDef(name, tpt, EmptyTree).withMods(Modifiers(Flags.JavaDefined | Flags.ParamAccessor))
137136

138137
def makeConstructor(formals: List[Tree], tparams: List[TypeDef], flags: FlagSet = Flags.JavaDefined) = {
139-
val vparams = mapWithIndex(formals)((p, i) => makeSyntheticParam(i + 1, p))
138+
val vparams = formals.zipWithIndex.map { case (p, i) => makeSyntheticParam(i + 1, p) }
140139
DefDef(nme.CONSTRUCTOR, tparams, List(vparams), TypeTree(), EmptyTree).withMods(Modifiers(flags))
141140
}
142141

compiler/src/dotty/tools/dotc/transform/FullParameterization.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import NameOps._
1212
import ast._
1313
import ast.Trees._
1414

15-
import scala.reflect.internal.util.Collections
16-
1715
/** Provides methods to produce fully parameterized versions of instance methods,
1816
* where the `this` of the enclosing class is abstracted out in an extra leading
1917
* `$this` parameter and type parameters of the class become additional type
@@ -234,8 +232,8 @@ trait FullParameterization {
234232
fun.appliedToArgss(originalDef.vparamss.nestedMap(vparam => ref(vparam.symbol)))
235233
else {
236234
// this type could have changed on forwarding. Need to insert a cast.
237-
val args = Collections.map2(originalDef.vparamss, fun.tpe.paramTypess)((vparams, paramTypes) =>
238-
Collections.map2(vparams, paramTypes)((vparam, paramType) => {
235+
val args = (originalDef.vparamss, fun.tpe.paramTypess).zipped.map((vparams, paramTypes) =>
236+
(vparams, paramTypes).zipped.map((vparam, paramType) => {
239237
assert(vparam.tpe <:< paramType.widen) // type should still conform to widened type
240238
ref(vparam.symbol).ensureConforms(paramType)
241239
})

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import dotty.tools.dotc.util.Positions.Position
3030
import dotty.tools.dotc.core.Decorators._
3131
import dotty.tools.dotc.core.Flags
3232

33-
import scala.reflect.internal.util.Collections
34-
3533
/** This transform eliminates patterns. Right now it's a dummy.
3634
* Awaiting the real pattern matcher.
3735
* elimRepeated is required
@@ -166,7 +164,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
166164
}
167165

168166
def emitValDefs: List[ValDef] = {
169-
Collections.map2(lhs, rhs)((symbol, tree) => ValDef(symbol.asTerm, tree.ensureConforms(symbol.info)))
167+
(lhs, rhs).zipped.map((symbol, tree) => ValDef(symbol.asTerm, tree.ensureConforms(symbol.info)))
170168
}
171169
}
172170
object NoRebindings extends Rebindings(Nil, Nil)
@@ -609,7 +607,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
609607
// only store binders actually used
610608
val (subPatBindersStored, subPatRefsStored) = stored.filter{case (b, _) => usedBinders(b)}.unzip
611609

612-
Block(Collections.map2(subPatBindersStored.toList, subPatRefsStored.toList)((bind, ref) => {
610+
Block((subPatBindersStored.toList, subPatRefsStored.toList).zipped.map((bind, ref) => {
613611
// required in case original pattern had a more precise type
614612
// eg case s@"foo" => would be otherwise translated to s with type String instead of String("foo")
615613
def refTpeWiden = ref.tpe.widen

0 commit comments

Comments
 (0)