Skip to content

misc cleanups and upgrades #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jdk:
- oraclejdk8
notifications:
email:
- jason.zaugg@typesafe.com
- jason.zaugg@lightbend.com
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright (c) 2002-2013 EPFL
Copyright (c) 2011-2013 Typesafe, Inc.
Copyright (c) 2002-2017 EPFL
Copyright (c) 2011-2017 Lightbend, Inc.

All rights reserved.

Expand Down
28 changes: 16 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ScalaModulePlugin._

scalaVersionsByJvm in ThisBuild := Map(
8 -> List("2.12.0", "2.11.8", "2.13.0-M1").map(_ -> true)
8 -> List("2.12.2", "2.11.11", "2.13.0-M1").map(_ -> true)
)

val disableDocs = sys.props("nodocs") == "true"
Expand All @@ -23,7 +23,8 @@ def osgiExport(scalaVersion: String, version: String) = {

lazy val commonSettings = Seq(
organization := "org.scala-lang.modules",
version := "0.9.0-SNAPSHOT"
version := "0.9.0-SNAPSHOT",
scalacOptions ++= Seq("-feature", "-deprecation", "-unchecked")
)

lazy val fnGen = (project in file("fnGen")).
Expand Down Expand Up @@ -68,9 +69,10 @@ lazy val root = (project in file(".")).
(out ** "*.scala").get
}.taskValue,

sourceGenerators in Compile <+= (sourceManaged in Compile, scalaVersion) map { (dir, v) =>
sourceGenerators in Compile += Def.task {
val dir = (sourceManaged in Compile).value
val write = jwrite(dir) _
if(v.startsWith("2.11.")) {
if(scalaVersion.value.startsWith("2.11.")) {
Seq(write("JFunction", CodeGen.factory)) ++
(0 to 22).map(n => write("JFunction" + n, CodeGen.fN(n))) ++
(0 to 22).map(n => write("JProcedure" + n, CodeGen.pN(n))) ++
Expand All @@ -79,11 +81,11 @@ lazy val root = (project in file(".")).
CodeGen.specializedF2.map(write.tupled) ++
CodeGen.packageDummy.map((jwrite(dir, "java/runtime/java8") _).tupled)
} else CodeGen.create212.map(write.tupled)
},
}.taskValue,

sourceGenerators in Test <+= sourceManaged in Test map { dir =>
Seq(jwrite(dir)("TestApi", CodeGen.testApi))
},
sourceGenerators in Test += Def.task {
Seq(jwrite((sourceManaged in Test).value)("TestApi", CodeGen.testApi))
}.taskValue,

initialize := {
// Run previously configured inialization...
Expand All @@ -103,14 +105,16 @@ lazy val root = (project in file(".")).
).
settings(
(inConfig(JavaDoc)(Defaults.configSettings) ++ (if (disableDocs) Nil else Seq(
packageDoc in Compile <<= packageDoc in JavaDoc,
sources in JavaDoc <<= (target, compile in Compile, sources in Compile) map {(t, c, s) =>
val allJavaSources = (t / "java" ** "*.java").get ++ s.filter(_.getName.endsWith(".java"))
packageDoc in Compile := (packageDoc in JavaDoc).value,
sources in JavaDoc := {
val allJavaSources =
(target.value / "java" ** "*.java").get ++
(sources in Compile).value.filter(_.getName.endsWith(".java"))
allJavaSources.filterNot(_.getName.contains("FuturesConvertersImpl.java")) // this file triggers bugs in genjavadoc
},
javacOptions in JavaDoc := Seq(),
artifactName in packageDoc in JavaDoc := ((sv, mod, art) => "" + mod.name + "_" + sv.binary + "-" + mod.revision + "-javadoc.jar"),
libraryDependencies += compilerPlugin("com.typesafe.genjavadoc" % "genjavadoc-plugin" % "0.10" cross CrossVersion.fullMapped { case "2.12.0" => "2.12.0-RC1" case x => x}),
libraryDependencies += compilerPlugin("com.typesafe.genjavadoc" % "genjavadoc-plugin" % "0.10" cross CrossVersion.full),
scalacOptions in Compile += "-P:genjavadoc:out=" + (target.value / "java")
))): _*
).
Expand Down
8 changes: 3 additions & 5 deletions fnGen/WrapFnGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ object WrapFnGen {
val packaging = "package scala.compat.java8"

import scala.tools.nsc._
import scala.reflect.internal._
val settings = new Settings(msg => sys.error(msg))
settings.usejavacp.value = true
val compiler = new Global(settings)
Expand Down Expand Up @@ -59,12 +58,12 @@ object WrapFnGen {
}

implicit class SplitMyLinesAndStuff(s: String) {
def toVec = s.linesIterator.toVector
def toVec = s.lines.toVector
def nonBlank = s.trim.length > 0
}

implicit class TreeToText(t: Tree) {
def text = showCode(t).replace("$", "").linesIterator.toVector
def text = showCode(t).replace("$", "").lines.toVector
}

case class Prioritized(lines: Vector[String], priority: Int) {
Expand Down Expand Up @@ -253,7 +252,6 @@ object WrapFnGen {
q"""@inline implicit def $s2jImpN[..$scalafnTdefs](sf: $scalaType[..$scalafnTnames])(implicit ..$evs): $s2jValCN[..$tnParams] =
new $s2jValCN[..$tnParams](sf.asInstanceOf[$scalaType[..$scalaTargs]])
"""
val depth = numberedA.size
(tree, tdParams.length)
}

Expand Down Expand Up @@ -290,7 +288,7 @@ object WrapFnGen {
def sameText(f: java.io.File, text: String): Boolean = {
val x = scala.io.Source.fromFile(f)
val lines = try { x.getLines.toVector } finally { x.close }
lines.iterator.filter(_.nonBlank) == text.linesIterator.filter(_.nonBlank)
lines.iterator.filter(_.nonBlank) == text.lines.filter(_.nonBlank)
}

def write(f: java.io.File, text: String) {
Expand Down
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
scalacOptions += "-Xfatal-warnings"

addSbtPlugin("org.scala-lang.modules" % "scala-module-plugin" % "1.0.8")
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2015 Typesafe Inc. <http://www.typesafe.com>
* Copyright (C) 2012-2015 Lightbend Inc. <http://www.lightbend.com>
*/
package scala.compat.java8.wrappers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2015 Typesafe Inc. <http://www.typesafe.com>
* Copyright (C) 2012-2015 Lightbend Inc. <http://www.lightbend.com>
*/
package scala.compat.java8.wrappers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2015 Typesafe Inc. <http://www.typesafe.com>
* Copyright (C) 2012-2015 Lightbend Inc. <http://www.lightbend.com>
*/
package scala.compat.java8.wrappers;

Expand Down
11 changes: 6 additions & 5 deletions src/main/scala/scala/compat/java8/FutureConverters.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/*
* Copyright (C) 2012-2015 Typesafe Inc. <http://www.typesafe.com>
* Copyright (C) 2012-2015 Lightbend Inc. <http://www.lightbend.com>
*/
package scala.compat.java8

import scala.language.implicitConversions

import scala.concurrent.java8.FuturesConvertersImpl._
import scala.concurrent.{ Future, Promise, ExecutionContext, ExecutionContextExecutorService, ExecutionContextExecutor, impl }
import java.util.concurrent.{ CompletionStage, Executor, ExecutorService, CompletableFuture }
import scala.util.{ Try, Success, Failure }
import java.util.function.{ BiConsumer, Function ⇒ JF, Consumer, BiFunction }
import scala.concurrent.{ Future, Promise, ExecutionContext, ExecutionContextExecutorService, ExecutionContextExecutor }
import java.util.concurrent.{ CompletionStage, Executor, ExecutorService }
import java.util.function.Consumer

/**
* This class contains static methods which convert between Java CompletionStage
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/scala/compat/java8/OptionConverters.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/*
* Copyright (C) 2012-2015 Typesafe Inc. <http://www.typesafe.com>
* Copyright (C) 2012-2015 Lightbend Inc. <http://www.lightbend.com>
*/
package scala.compat.java8

import language.implicitConversions
import java.util.{Optional, OptionalDouble, OptionalInt, OptionalLong}

/** This class enables bidirectional conversion between `scala.Option` and the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/*
* Copyright (C) 2012-2015 Typesafe Inc. <http://www.typesafe.com>
* Copyright (C) 2012-2015 Lightbend Inc. <http://www.lightbend.com>
*/
package scala.compat.java8

import language.implicitConversions
import java.util.{ Iterator => JIterator, PrimitiveIterator }

/** This class enables conversion from `scala.Iterator` to the set of
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/scala/compat/java8/StreamConverters.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scala.compat.java8

import language.implicitConversions
import scala.language.higherKinds

import java.util.stream._
import scala.compat.java8.collectionImpl._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scala.compat.java8.collectionImpl

import scala.language.higherKinds

/** An `Accumulator` is a low-level collection specialized for gathering
* elements in parallel and then joining them in order by merging Accumulators.
* Accumulators can contain more than `Int.MaxValue` elements.
Expand Down Expand Up @@ -232,7 +234,7 @@ private[java8] class AccumulatorStepper[A](private val acc: Accumulator[A]) exte
private var n = if (acc.hIndex > 0) acc.cumulative(0) else acc.index
private var N = acc.totalSize

private def duplicateSelf(limit: Long = N): AccumulatorStepper[A] = {
private def duplicateSelf(limit: Long): AccumulatorStepper[A] = {
val ans = new AccumulatorStepper(acc)
ans.h = h
ans.i = i
Expand All @@ -249,7 +251,7 @@ private[java8] class AccumulatorStepper[A](private val acc: Accumulator[A]) exte
i = 0
}

def characteristics = ORDERED | SIZED | SUBSIZED
def characteristics() = ORDERED | SIZED | SUBSIZED

def estimateSize = N

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scala.compat.java8.collectionImpl

import scala.language.higherKinds

/** A `DoubleAccumulator` is a low-level collection specialized for gathering
* elements in parallel and then joining them in order by merging them.
* This is a manually specialized variant of `Accumulator` with no actual
Expand Down Expand Up @@ -229,7 +231,7 @@ private[java8] class DoubleAccumulatorStepper(private val acc: DoubleAccumulator
private var n = if (acc.hIndex > 0) acc.cumulative(0) else acc.index
private var N = acc.totalSize

private def duplicateSelf(limit: Long = N): DoubleAccumulatorStepper = {
private def duplicateSelf(limit: Long): DoubleAccumulatorStepper = {
val ans = new DoubleAccumulatorStepper(acc)
ans.h = h
ans.i = i
Expand All @@ -246,7 +248,7 @@ private[java8] class DoubleAccumulatorStepper(private val acc: DoubleAccumulator
i = 0
}

def characteristics = ORDERED | SIZED | SUBSIZED | NONNULL
def characteristics() = ORDERED | SIZED | SUBSIZED | NONNULL

def estimateSize = N

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scala.compat.java8.collectionImpl

import scala.language.higherKinds

/** A `IntAccumulator` is a low-level collection specialized for gathering
* elements in parallel and then joining them in order by merging them.
* This is a manually specialized variant of `Accumulator` with no actual
Expand Down Expand Up @@ -236,7 +238,7 @@ private[java8] class IntAccumulatorStepper(private val acc: IntAccumulator) exte
private var n = if (acc.hIndex > 0) acc.cumulative(0) else acc.index
private var N = acc.totalSize

private def duplicateSelf(limit: Long = N): IntAccumulatorStepper = {
private def duplicateSelf(limit: Long): IntAccumulatorStepper = {
val ans = new IntAccumulatorStepper(acc)
ans.h = h
ans.i = i
Expand All @@ -253,7 +255,7 @@ private[java8] class IntAccumulatorStepper(private val acc: IntAccumulator) exte
i = 0
}

def characteristics = ORDERED | SIZED | SUBSIZED | NONNULL
def characteristics() = ORDERED | SIZED | SUBSIZED | NONNULL

def estimateSize = N

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scala.compat.java8.collectionImpl

import scala.language.higherKinds

/** A `LongAccumulator` is a low-level collection specialized for gathering
* elements in parallel and then joining them in order by merging them.
* This is a manually specialized variant of `Accumulator` with no actual
Expand Down Expand Up @@ -230,7 +232,7 @@ private[java8] class LongAccumulatorStepper(private val acc: LongAccumulator) ex
private var n = if (acc.hIndex > 0) acc.cumulative(0) else acc.index
private var N = acc.totalSize

private def duplicateSelf(limit: Long = N): LongAccumulatorStepper = {
private def duplicateSelf(limit: Long): LongAccumulatorStepper = {
val ans = new LongAccumulatorStepper(acc)
ans.h = h
ans.i = i
Expand All @@ -247,7 +249,7 @@ private[java8] class LongAccumulatorStepper(private val acc: LongAccumulator) ex
i = 0
}

def characteristics = ORDERED | SIZED | SUBSIZED | NONNULL
def characteristics() = ORDERED | SIZED | SUBSIZED | NONNULL

def estimateSize = N

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scala.compat.java8.collectionImpl

import scala.language.higherKinds

import java.util.Spliterator

/** A Stepper is a specialized collection that can step through its
Expand Down Expand Up @@ -66,7 +68,7 @@ trait StepperLike[@specialized(Double, Int, Long) A, +CC] { self: CC =>
* guaranteed to be any safer than modification of any generic mutable collection, and if the underlying collection is ordered by
* virtue of sorting, `Stepper` will not keep track of that fact.
*/
def characteristics: Int
def characteristics(): Int

/** Returns the size of the collection, if known exactly, or `-1` if not. */
def knownSize: Long
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package scala.compat.java8.converterImpl

import language.implicitConversions

import scala.compat.java8.collectionImpl._
import scala.compat.java8.runtime._

trait AccumulatesFromStepper[@specialized(Double, Int, Long) A, Acc <: AccumulatorLike[A, Acc]] {
def apply(stepper: Stepper[A]): Acc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package scala.compat.java8.converterImpl

import language.implicitConversions

import scala.compat.java8.collectionImpl._
import scala.compat.java8.runtime._

trait MakesStepper[T, +Extra] extends Any {
/** Generates a fresh stepper of type `S` for element type `T` */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ package scala.compat.java8.converterImpl

import language.implicitConversions

import scala.compat.java8.collectionImpl._
import scala.compat.java8.runtime._

import Stepper._

trait Priority3StepConverters {
implicit def richIterableCanStep[A](underlying: Iterable[A]) = new RichIterableCanStep(underlying)
implicit def richMapCanStep[K, V](underlying: collection.Map[K, V]) = new RichMapCanStep[K, V](underlying)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package scala.compat.java8.converterImpl

import language.implicitConversions
import scala.annotation.switch

import scala.compat.java8.collectionImpl._
import scala.compat.java8.runtime._

import Stepper._

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package scala.compat.java8.converterImpl

import language.implicitConversions

import scala.compat.java8.collectionImpl._
import scala.compat.java8.runtime._

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package scala.compat.java8.converterImpl

import language.implicitConversions
import scala.annotation.switch

import scala.compat.java8.collectionImpl._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package scala.compat.java8.converterImpl

import language.implicitConversions
import scala.annotation.switch

import scala.compat.java8.collectionImpl._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package scala.compat.java8.converterImpl

import language.implicitConversions
import scala.annotation.switch

import scala.compat.java8.collectionImpl._
import scala.compat.java8.runtime._

import Stepper._

Expand Down
Loading