diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index a4f171ba7f9a..b7f67903e3c4 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -111,21 +111,21 @@ class Definitions { val decls = newScope val arity = name.functionArity val paramNamePrefix = tpnme.scala_ ++ str.NAME_JOIN ++ name ++ str.EXPAND_SEPARATOR - val argParams = - for (i <- List.range(1, arity + 1)) yield - enterTypeParam(cls, paramNamePrefix ++ "T" ++ i.toString, Contravariant, decls) + val argParamRefs = List.tabulate(arity) { i => + enterTypeParam(cls, paramNamePrefix ++ "T" ++ (i + 1).toString, Contravariant, decls).typeRef + } val resParam = enterTypeParam(cls, paramNamePrefix ++ "R", Covariant, decls) val (methodType, parentTraits) = if (name.firstPart.startsWith(str.ImplicitFunction)) { val superTrait = - FunctionType(arity).appliedTo(argParams.map(_.typeRef) ::: resParam.typeRef :: Nil) + FunctionType(arity).appliedTo(argParamRefs ::: resParam.typeRef :: Nil) (ImplicitMethodType, superTrait :: Nil) } else (MethodType, Nil) val applyMeth = decls.enter( newMethod(cls, nme.apply, - methodType(argParams.map(_.typeRef), resParam.typeRef), Deferred)) + methodType(argParamRefs, resParam.typeRef), Deferred)) denot.info = ClassInfo(ScalaPackageClass.thisType, cls, ObjectType :: parentTraits, decls) } diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index bedacafef837..27d40d65522c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -690,7 +690,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit val MethodTpe(_, formals, restpe) = meth.info (formals, restpe) case _ => - (List.range(0, defaultArity) map alwaysWildcardType, WildcardType) + (List.tabulate(defaultArity)(alwaysWildcardType), WildcardType) } def typedFunction(tree: untpd.Function, pt: Type)(implicit ctx: Context) = track("typedFunction") { diff --git a/compiler/src/dotty/tools/dotc/util/SourcePosition.scala b/compiler/src/dotty/tools/dotc/util/SourcePosition.scala index af9ab537e11d..89aa413f6308 100644 --- a/compiler/src/dotty/tools/dotc/util/SourcePosition.scala +++ b/compiler/src/dotty/tools/dotc/util/SourcePosition.scala @@ -26,11 +26,12 @@ extends interfaces.SourcePosition { source.content.slice(source.startOfLine(start), source.nextLine(end)) /** The lines of the position */ - def lines: List[Int] = - List.range(source.offsetToLine(start), source.offsetToLine(end + 1)) match { - case Nil => line :: Nil - case xs => xs - } + def lines: List[Int] = { + val startOffset = source.offsetToLine(start) + val endOffset = source.offsetToLine(end + 1) + if (startOffset >= endOffset) line :: Nil + else (startOffset until endOffset).toList + } def lineOffsets: List[Int] = lines.map(source.lineToOffset(_))