Skip to content

Commit

Permalink
Merge branch '1.0.x' into merge-1.0.x-into-1.x
Browse files Browse the repository at this point in the history
* 1.0.x: (25 commits)
  Add yourkit acknoledgement in the README
  Add header to cached hashing spec
  Add headers to missing files
  Fix sbt#332: Add sbt-header back to the build
  Update sbt-scalafmt to 1.12
  Make classpath hashing more lightweight
  Fix sbt#442: Name hash of value class should include underlying type
  source-dependencies/value-class-underlying: fix test
  Ignore null in generic lambda tparams
  Improve and make scripted parallel
  Fix sbt#436: Remove annoying log4j scripted exception
  Fix sbt#127: Use `unexpanded` name instead of `name`
  Add pending test case for issue/127
  source-dependencies / patMat-scope workaround
  Fixes undercompilation on inheritance on same source
  Add real reproduction case for sbt#417
  Add trait-trait-212 for Scala 2.12.3
  Fix source-dependencies/sealed
  Import statement no longer needed
  Move mima exclusions to its own file
  ...

 Conflicts:
	internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala
	zinc/src/main/scala/sbt/internal/inc/MixedAnalyzingCompiler.scala

The ClassToAPI conflict is due to:
* sbt#393 (a 1.x PR), conflicting with
* sbt#446 (a 1.0.x PR).

The MixedAnalyzingCompiler conflict is due to:
* sbt#427 (a 1.x PR), conflicting with
* sbt#452 (a 1.0.x PR).
  • Loading branch information
dwijnand committed Nov 22, 2017
2 parents b1e7eac + f7e45b4 commit 8aa95a5
Show file tree
Hide file tree
Showing 63 changed files with 848 additions and 86 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,9 @@ active development. For information on how to contribute, please check the
[CONTRIBUTING guide](CONTRIBUTING.md).

This software is released under the following [LICENSE](LICENSE).

## Acknoledgements

| Logo | Acknoledgement |
| ---- | -------------- |
| ![](https://www.yourkit.com/images/yklogo.png) | We thank [Yourkit](https://www.yourkit.com/) for supporting this open-source project with its full-featured profiler. |
3 changes: 2 additions & 1 deletion bin/run-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ sbt -Dfile.encoding=UTF-8 \
-J-XX:ReservedCodeCacheSize=256M \
-J-Xmx3046M -J-Xms3046M -J-server \
+mimaReportBinaryIssues \
scalafmtTest \
scalafmt::test \
test:scalafmt::test \
zincRoot/test:compile \
crossTestBridges \
"publishBridgesAndSet $SCALA_VERSION" \
Expand Down
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Util._
import Dependencies._
import Scripted._
//import com.typesafe.tools.mima.core._, ProblemFilters._

def baseVersion = "1.1.0-SNAPSHOT"
def internalPath = file("internal")
Expand Down Expand Up @@ -157,6 +156,9 @@ lazy val zincRoot: Project = (project in file("."))
homepage := Some(url("https://github.com/sbt/zinc")),
developers +=
Developer("jvican", "Jorge Vicente Cantero", "@jvican", url("https://github.com/jvican")),
scalafmtOnCompile := true,
scalafmtVersion := "1.2.0",
scalafmtOnCompile in Sbt := false,
)),
minimalSettings,
otherRootSettings,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# xsbti Java interfaces must be defined in the compiler interface, not the bridge.
# Bridge implementations are compiled per Zinc, so these are safe to change.
ProblemFilters.exclude[MissingClassProblem]("xsbti.InteractiveConsoleFactory")
ProblemFilters.exclude[MissingClassProblem]("xsbti.InteractiveConsoleResult")
ProblemFilters.exclude[MissingClassProblem]("xsbti.InteractiveConsoleInterface")
ProblemFilters.exclude[MissingClassProblem]("xsbti.InteractiveConsoleResponse")
8 changes: 6 additions & 2 deletions internal/compiler-bridge/src/main/scala/xsbt/ClassName.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,19 @@ trait ClassName extends Compat {
*
* If `s` represents a package object `pkg3`, then the returned name will be `pkg1.pkg2.pkg3.package`.
* If `s` represents a class `Foo` nested in package object `pkg3` then the returned name is `pkg1.pkg2.pk3.Foo`.
*
* Note that some objects with special access rights are encoded in names
* (like qualified privates `private[qualifier]`). In order to get the right
* original names, we need to use `unexpandedName`.
*/
protected def classNameAsSeenIn(in: Symbol, s: Symbol): String =
enteringPhase(currentRun.picklerPhase.next) {
if (in.isRoot || in.isRootPackage || in == NoSymbol || in.isEffectiveRoot)
s.simpleName.toString
else if (in.isPackageObjectOrClass)
in.owner.fullName + "." + s.name
in.owner.fullName + "." + s.unexpandedName
else
in.fullName + "." + s.name
in.fullName + "." + s.unexpandedName
}

private def pickledName(s: Symbol): Name =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package xsbt

import xsbti.Logger
import scala.tools.nsc.interpreter.{ ILoop, IMain, InteractiveReader }
import scala.tools.nsc.interpreter.{ ILoop, IMain, InteractiveReader, NamedParam }
import scala.tools.nsc.reporters.Reporter
import scala.tools.nsc.{ GenericRunnerCommand, Settings }

Expand Down Expand Up @@ -54,7 +54,7 @@ class ConsoleInterface {
super.createInterpreter()

for ((id, value) <- bindNames zip bindValues)
intp.beQuietDuring(intp.bind(id, value.asInstanceOf[AnyRef].getClass.getName, value))
intp.quietBind(NamedParam.clazz(id, value))

if (!initialCommands.isEmpty)
intp.interpret(initialCommands)
Expand Down
21 changes: 13 additions & 8 deletions internal/compiler-bridge/src/main/scala/xsbt/Dependency.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,21 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with
}

// Define processor reusing `processDependency` definition
val memberRef = processDependency(DependencyByMemberRef) _
val inheritance = processDependency(DependencyByInheritance) _
val localInheritance = processDependency(LocalDependencyByInheritance) _
val memberRef = processDependency(DependencyByMemberRef, false) _
val inheritance = processDependency(DependencyByInheritance, true) _
val localInheritance = processDependency(LocalDependencyByInheritance, true) _

@deprecated("Use processDependency that takes allowLocal.", "1.1.0")
def processDependency(context: DependencyContext)(dep: ClassDependency): Unit =
processDependency(context, true)(dep)

/*
* Handles dependency on given symbol by trying to figure out if represents a term
* that is coming from either source code (not necessarily compiled in this compilation
* run) or from class file and calls respective callback method.
*/
def processDependency(context: DependencyContext)(dep: ClassDependency): Unit = {
def processDependency(context: DependencyContext, allowLocal: Boolean)(
dep: ClassDependency): Unit = {
val fromClassName = classNameAsString(dep.from)

def binaryDependency(file: File, binaryClassName: String) =
Expand Down Expand Up @@ -134,11 +139,12 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with
case None =>
debuglog(Feedback.noOriginFileForExternalSymbol(dep.to))
}
} else if (onSource.file != sourceFile) {
// Dependency is internal -- but from other file / compilation unit
} else if (onSource.file != sourceFile || allowLocal) {
// We cannot ignore dependencies coming from the same source file because
// the dependency info needs to propagate. See source-dependencies/trait-trait-211.
val onClassName = classNameAsString(dep.to)
callback.classDependency(onClassName, fromClassName, context)
} else () // Comes from the same file, ignore
}
}
}

Expand Down Expand Up @@ -228,7 +234,6 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with
val depClass = enclOrModuleClass(dep)
val dependency = ClassDependency(fromClass, depClass)
if (!cache.contains(dependency) &&
fromClass.associatedFile != depClass.associatedFile &&
!depClass.isRefinementClass) {
process(dependency)
cache.add(dependency)
Expand Down
11 changes: 10 additions & 1 deletion internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,16 @@ class ExtractAPI[GlobalType <: Global](
* TODO: can we include hashes for parent classes instead? This seems a bit messy.
*/
private def mkStructureWithInherited(info: Type, s: Symbol): xsbti.api.Structure = {
val ancestorTypes = linearizedAncestorTypes(info)
val ancestorTypes0 = linearizedAncestorTypes(info)
val ancestorTypes =
if (s.isDerivedValueClass) {
val underlying = s.derivedValueClassUnbox.tpe.finalResultType
// The underlying type of a value class should be part of the name hash
// of the value class (see the test `value-class-underlying`), this is accomplished
// by adding the underlying type to the list of parent types.
underlying :: ancestorTypes0
} else
ancestorTypes0
val decls = info.decls.toList
val declsNoModuleCtor = if (s.isModuleClass) removeConstructors(decls) else decls
val declSet = decls.toSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,14 @@ object ClassToAPI {
accumulate(t).filterNot(_ == null).distinct
}

@deprecated("No longer used", "0.13.0")
def parents(c: Class[_]): Seq[api.Type] = types(allSuperTypes(c))
def types(ts: Seq[Type]): Array[api.Type] = (ts filter (_ ne null) map reference).toArray
def types(ts: Seq[Type]): Array[api.Type] =
ts.filter(_ ne null).map(reference).toArray
def upperBounds(ts: Array[Type]): api.Type =
api.Structure.of(lzy(types(ts)), lzyEmptyDefArray, lzyEmptyDefArray)

@deprecated("No longer used", "0.13.0")
def parents(c: Class[_]): Seq[api.Type] = types(allSuperTypes(c))

@deprecated("Use fieldToDef[4] instead", "0.13.9")
def fieldToDef(enclPkg: Option[String])(f: Field): api.FieldLike = {
val c = f.getDeclaringClass
Expand Down Expand Up @@ -496,12 +498,18 @@ object ClassToAPI {
api.Projection.of(api.Singleton.of(pathFromString(p)), cls)
}
}

// sbt/zinc#389: Ignore nulls coming from generic parameter types of lambdas
private[this] def ignoreNulls[T](genericTypes: Array[T]): Array[T] =
genericTypes.filter(_ != null)

def referenceP(t: ParameterizedType): api.Parameterized = {
val targs = t.getActualTypeArguments
val targs = ignoreNulls(t.getActualTypeArguments)
val args = if (targs.isEmpty) emptyTypeArray else arrayMap(targs)(t => reference(t): api.Type)
val base = reference(t.getRawType)
api.Parameterized.of(base, args)
}

def reference(t: Type): api.Type =
t match {
case _: WildcardType => reference("_")
Expand Down Expand Up @@ -553,8 +561,12 @@ object ClassToAPI {
private[this] def exceptionTypes(c: Constructor[_]): Array[Type] = c.getGenericExceptionTypes

private[this] def exceptionTypes(m: Method): Array[Type] = m.getGenericExceptionTypes
private[this] def parameterTypes(m: Method): Array[Type] = m.getGenericParameterTypes
private[this] def parameterTypes(c: Constructor[_]): Array[Type] = c.getGenericParameterTypes

private[this] def parameterTypes(m: Method): Array[Type] =
ignoreNulls(m.getGenericParameterTypes)

private[this] def parameterTypes(c: Constructor[_]): Array[Type] =
ignoreNulls(c.getGenericParameterTypes)

private[this] def typeParameterTypes[T](m: Constructor[T]): Array[TypeVariable[Constructor[T]]] =
m.getTypeParameters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright 2011 - 2017, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* This software is released under the terms written in LICENSE.
*/

package xsbti;

import sbt.internal.inc.ReporterManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright 2011 - 2017, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* This software is released under the terms written in LICENSE.
*/

package sbt.internal.inc

import java.nio.file.Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ class LoggedReporter(
sourcePositionMapper: Position => Position = identity[Position]
) extends Reporter {
import sbt.util.InterfaceUtil.{ toSupplier => f0 }
val positions = new mutable.HashMap[PositionKey, Severity]
val count = new EnumMap[Severity, Int](classOf[Severity])
protected val allProblems = new mutable.ListBuffer[Problem]
lazy val positions = new mutable.HashMap[PositionKey, Severity]
lazy val count = new EnumMap[Severity, Int](classOf[Severity])
protected lazy val allProblems = new mutable.ListBuffer[Problem]
reset()

def reset(): Unit = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright 2011 - 2017, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* This software is released under the terms written in LICENSE.
*/

package sbt.internal.inc

import java.io.{ OutputStreamWriter, PrintStream, PrintWriter }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright 2011 - 2017, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* This software is released under the terms written in LICENSE.
*/

package xsbti.compile;

import sbt.internal.inc.ConcreteAnalysisContents;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright 2011 - 2017, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* This software is released under the terms written in LICENSE.
*/

package xsbti.compile;

import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright 2011 - 2017, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* This software is released under the terms written in LICENSE.
*/

package sbt.internal.inc

import xsbti.compile.{ AnalysisContents, CompileAnalysis, MiniSetup }
Expand Down
40 changes: 19 additions & 21 deletions internal/zinc-core/src/main/scala/sbt/internal/inc/Relations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ object Relations {
case o: ClassDependencies => internal == o.internal && external == o.external
case _ => false
}
override def toString: String = s"ClassDependencies(internal = $internal, external = $external)"

override def hashCode = (internal, external).hashCode
}
Expand Down Expand Up @@ -661,26 +662,23 @@ private class MRelationsNameHashing(
override def hashCode =
(srcProd :: libraryDep :: libraryClassName :: memberRef :: inheritance :: classes :: Nil).hashCode

override def toString = (
"""
override def toString: String = {
val internalDepsStr = (internalDependencies.dependencies map {
case (k, vs) => k + " " + relation_s(vs)
}).mkString("\n ", "\n ", "")
val externalDepsStr = (externalDependencies.dependencies map {
case (k, vs) => k + " " + relation_s(vs)
}).mkString("\n ", "\n ", "")
s"""
|Relations (with name hashing enabled):
| products: %s
| library deps: %s
| library class names: %s
| class deps: %s
| ext deps: %s
| class names: %s
| used names: %s
| product class names: %s
""".trim.stripMargin.format(
List(srcProd,
libraryDep,
libraryClassName,
internalClassDep,
externalClassDep,
classes,
names,
productClassName) map relation_s: _*)
)

| products: ${relation_s(srcProd)}
| library deps: ${relation_s(libraryDep)}
| library class names: ${relation_s(libraryClassName)}
| internalDependencies: $internalDepsStr
| externalDependencies: $externalDepsStr
| class names: ${relation_s(classes)}
| used names: ${relation_s(names)}
| product class names: ${relation_s(productClassName)}
""".trim.stripMargin
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright 2011 - 2017, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* This software is released under the terms written in LICENSE.
*/

package xsbti.compile;

import xsbti.compile.analysis.ReadWriteMappers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright 2011 - 2017, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* This software is released under the terms written in LICENSE.
*/

package xsbti.compile.analysis;

import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright 2011 - 2017, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* This software is released under the terms written in LICENSE.
*/

package sbt.internal.inc

import java.io.File
Expand Down
Loading

0 comments on commit 8aa95a5

Please sign in to comment.