Skip to content

Commit daaec42

Browse files
authored
Merge pull request #366 from eed3si9n/wip/integration
Bump to latest modules + integrate ripples
2 parents 1de92bf + b5bcc8b commit daaec42

File tree

118 files changed

+4525
-756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+4525
-756
lines changed

build.sbt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ lazy val zincTesting = (project in internalPath / "zinc-testing")
187187
publishArtifact := false,
188188
libraryDependencies ++= Seq(scalaCheck, scalatest, junit, sjsonnewScalaJson.value)
189189
)
190-
.configure(addSbtLm, addSbtUtilTesting)
190+
.configure(addSbtLmCore, addSbtLmIvy, addSbtUtilTesting)
191191

192192
lazy val zincCompile = (project in file("zinc-compile"))
193193
.dependsOn(zincCompileCore, zincCompileCore % "test->test")
@@ -250,7 +250,7 @@ lazy val zincIvyIntegration = (project in internalPath / "zinc-ivy-integration")
250250
name := "zinc Ivy Integration",
251251
compileOrder := sbt.CompileOrder.ScalaThenJava
252252
)
253-
.configure(addSbtLm)
253+
.configure(addSbtLmCore, addSbtLmIvyTest)
254254

255255
// sbt-side interface to compiler. Calls compiler-side interface reflectively
256256
lazy val zincCompileCore = (project in internalPath / "zinc-compile-core")
@@ -266,7 +266,10 @@ lazy val zincCompileCore = (project in internalPath / "zinc-compile-core")
266266
.settings(
267267
name := "zinc Compile Core",
268268
libraryDependencies ++= Seq(scalaCompiler.value % Test, launcherInterface, parserCombinator),
269-
unmanagedJars in Test := Seq(packageSrc in compilerBridge in Compile value).classpath
269+
unmanagedJars in Test := Seq(packageSrc in compilerBridge in Compile value).classpath,
270+
managedSourceDirectories in Compile +=
271+
baseDirectory.value / "src" / "main" / "contraband-java",
272+
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-java"
270273
)
271274
.configure(addSbtUtilLogging, addSbtIO, addSbtUtilControl)
272275

@@ -302,6 +305,9 @@ lazy val compilerInterface = (project in internalPath / "compiler-interface")
302305
(baseDirectory.value / "other"),
303306
(baseDirectory.value / "type")
304307
),
308+
managedSourceDirectories in Compile +=
309+
baseDirectory.value / "src" / "main" / "contraband-java",
310+
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-java",
305311
crossPaths := false,
306312
autoScalaLibrary := false,
307313
altPublishSettings

internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala

Lines changed: 61 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ class ExtractAPI[GlobalType <: Global](
173173

174174
private def thisPath(sym: Symbol) = path(pathComponents(sym, Constants.thisPath :: Nil))
175175
private def path(components: List[PathComponent]) =
176-
new xsbti.api.Path(components.toArray[PathComponent])
176+
xsbti.api.Path.of(components.toArray[PathComponent])
177177
private def pathComponents(sym: Symbol, postfix: List[PathComponent]): List[PathComponent] = {
178178
if (sym == NoSymbol || sym.isRoot || sym.isEmptyPackageClass || sym.isRootPackage) postfix
179-
else pathComponents(sym.owner, new xsbti.api.Id(simpleName(sym)) :: postfix)
179+
else pathComponents(sym.owner, xsbti.api.Id.of(simpleName(sym)) :: postfix)
180180
}
181181
private def types(in: Symbol, t: List[Type]): Array[xsbti.api.Type] =
182182
t.toArray[Type].map(processType(in, _))
@@ -191,24 +191,25 @@ class ExtractAPI[GlobalType <: Global](
191191
reference(sym)
192192
}
193193
} else if (sym.isRoot || sym.isRootPackage) Constants.emptyType
194-
else new xsbti.api.Projection(processType(in, pre), simpleName(sym))
194+
else xsbti.api.Projection.of(processType(in, pre), simpleName(sym))
195195
}
196196
private def reference(sym: Symbol): xsbti.api.ParameterRef =
197-
new xsbti.api.ParameterRef(tparamID(sym))
197+
xsbti.api.ParameterRef.of(tparamID(sym))
198198

199199
// The compiler only pickles static annotations, so only include these in the API.
200200
// This way, the API is not sensitive to whether we compiled from source or loaded from classfile.
201201
// (When looking at the sources we see all annotations, but when loading from classes we only see the pickled (static) ones.)
202202
private def mkAnnotations(in: Symbol, as: List[AnnotationInfo]): Array[xsbti.api.Annotation] =
203203
staticAnnotations(as).toArray.map { a =>
204-
new xsbti.api.Annotation(
204+
xsbti.api.Annotation.of(
205205
processType(in, a.atp),
206206
if (a.assocs.isEmpty)
207-
Array(new xsbti.api.AnnotationArgument("", a.args.mkString("(", ",", ")"))) // what else to do with a Tree?
207+
Array(xsbti.api.AnnotationArgument.of("", a.args.mkString("(", ",", ")"))) // what else to do with a Tree?
208208
else
209209
a.assocs
210210
.map {
211-
case (name, value) => new xsbti.api.AnnotationArgument(name.toString, value.toString)
211+
case (name, value) =>
212+
xsbti.api.AnnotationArgument.of(name.toString, value.toString)
212213
}
213214
.toArray[xsbti.api.AnnotationArgument]
214215
)
@@ -234,7 +235,7 @@ class ExtractAPI[GlobalType <: Global](
234235
valueParameters: List[xsbti.api.ParameterList]): xsbti.api.Def = {
235236
def parameterList(syms: List[Symbol]): xsbti.api.ParameterList = {
236237
val isImplicitList = syms match { case head :: _ => isImplicit(head); case _ => false }
237-
new xsbti.api.ParameterList(syms.map(parameterS).toArray, isImplicitList)
238+
xsbti.api.ParameterList.of(syms.map(parameterS).toArray, isImplicitList)
238239
}
239240
t match {
240241
case PolyType(typeParams0, base) =>
@@ -247,13 +248,13 @@ class ExtractAPI[GlobalType <: Global](
247248
build(resultType, typeParams, valueParameters)
248249
case returnType =>
249250
val retType = processType(in, dropConst(returnType))
250-
new xsbti.api.Def(simpleName(s),
251-
getAccess(s),
252-
getModifiers(s),
253-
annotations(in, s),
254-
typeParams,
255-
valueParameters.reverse.toArray,
256-
retType)
251+
xsbti.api.Def.of(simpleName(s),
252+
getAccess(s),
253+
getModifiers(s),
254+
annotations(in, s),
255+
typeParams,
256+
valueParameters.reverse.toArray,
257+
retType)
257258
}
258259
}
259260
def parameterS(s: Symbol): xsbti.api.MethodParameter = {
@@ -274,7 +275,7 @@ class ExtractAPI[GlobalType <: Global](
274275
(tpe.typeArgs.head, ByName)
275276
else
276277
(tpe, Plain)
277-
new xsbti.api.MethodParameter(name, processType(in, t), hasDefault(paramSym), special)
278+
xsbti.api.MethodParameter.of(name, processType(in, t), hasDefault(paramSym), special)
278279
}
279280
val t = viewer(in).memberInfo(s)
280281
build(t, Array(), Nil)
@@ -313,16 +314,16 @@ class ExtractAPI[GlobalType <: Global](
313314
val as = annotations(in, s)
314315

315316
if (s.isAliasType)
316-
new xsbti.api.TypeAlias(name, access, modifiers, as, typeParams, processType(in, tpe))
317+
xsbti.api.TypeAlias.of(name, access, modifiers, as, typeParams, processType(in, tpe))
317318
else if (s.isAbstractType) {
318319
val bounds = tpe.bounds
319-
new xsbti.api.TypeDeclaration(name,
320-
access,
321-
modifiers,
322-
as,
323-
typeParams,
324-
processType(in, bounds.lo),
325-
processType(in, bounds.hi))
320+
xsbti.api.TypeDeclaration.of(name,
321+
access,
322+
modifiers,
323+
as,
324+
typeParams,
325+
processType(in, bounds.lo),
326+
processType(in, bounds.hi))
326327
} else
327328
error("Unknown type member" + s)
328329
}
@@ -375,9 +376,9 @@ class ExtractAPI[GlobalType <: Global](
375376
bases: List[Type],
376377
declared: List[Symbol],
377378
inherited: List[Symbol]): xsbti.api.Structure = {
378-
new xsbti.api.Structure(lzy(types(s, bases)),
379-
lzy(processDefinitions(s, declared)),
380-
lzy(processDefinitions(s, inherited)))
379+
xsbti.api.Structure.of(lzy(types(s, bases)),
380+
lzy(processDefinitions(s, declared)),
381+
lzy(processDefinitions(s, inherited)))
381382
}
382383
private def processDefinitions(in: Symbol,
383384
defs: List[Symbol]): Array[xsbti.api.ClassDefinition] =
@@ -388,8 +389,8 @@ class ExtractAPI[GlobalType <: Global](
388389
}
389390

390391
private def definition(in: Symbol, sym: Symbol): Option[xsbti.api.ClassDefinition] = {
391-
def mkVar = Some(fieldDef(in, sym, keepConst = false, new xsbti.api.Var(_, _, _, _, _)))
392-
def mkVal = Some(fieldDef(in, sym, keepConst = true, new xsbti.api.Val(_, _, _, _, _)))
392+
def mkVar = Some(fieldDef(in, sym, keepConst = false, xsbti.api.Var.of(_, _, _, _, _)))
393+
def mkVal = Some(fieldDef(in, sym, keepConst = true, xsbti.api.Val.of(_, _, _, _, _)))
393394
if (isClass(sym))
394395
if (ignoreClass(sym)) None else Some(classLike(in, sym))
395396
else if (sym.isNonClassType)
@@ -438,9 +439,9 @@ class ExtractAPI[GlobalType <: Global](
438439
val within = c.privateWithin
439440
val qualifier =
440441
if (within == NoSymbol) Constants.unqualified
441-
else new xsbti.api.IdQualifier(within.fullName)
442-
if (c.hasFlag(Flags.PROTECTED)) new xsbti.api.Protected(qualifier)
443-
else new xsbti.api.Private(qualifier)
442+
else xsbti.api.IdQualifier.of(within.fullName)
443+
if (c.hasFlag(Flags.PROTECTED)) xsbti.api.Protected.of(qualifier)
444+
else xsbti.api.Private.of(qualifier)
444445
}
445446
}
446447

@@ -465,10 +466,10 @@ class ExtractAPI[GlobalType <: Global](
465466

466467
dealiased match {
467468
case NoPrefix => Constants.emptyType
468-
case ThisType(sym) => new xsbti.api.Singleton(thisPath(sym))
469+
case ThisType(sym) => xsbti.api.Singleton.of(thisPath(sym))
469470
case SingleType(pre, sym) => projectionType(in, pre, sym)
470471
case ConstantType(constant) =>
471-
new xsbti.api.Constant(processType(in, constant.tpe), constant.stringValue)
472+
xsbti.api.Constant.of(processType(in, constant.tpe), constant.stringValue)
472473

473474
/* explaining the special-casing of references to refinement classes (https://support.typesafe.com/tickets/1882)
474475
*
@@ -509,22 +510,22 @@ class ExtractAPI[GlobalType <: Global](
509510
else
510511
base
511512
else
512-
new xsbti.api.Parameterized(base, types(in, args))
513+
xsbti.api.Parameterized.of(base, types(in, args))
513514
case SuperType(thistpe: Type, supertpe: Type) =>
514515
warning("sbt-api: Super type (not implemented): this=" + thistpe + ", super=" + supertpe);
515516
Constants.emptyType
516517
case at: AnnotatedType =>
517518
at.annotations match {
518519
case Nil => processType(in, at.underlying)
519520
case annots =>
520-
new xsbti.api.Annotated(processType(in, at.underlying), mkAnnotations(in, annots))
521+
xsbti.api.Annotated.of(processType(in, at.underlying), mkAnnotations(in, annots))
521522
}
522523
case rt: CompoundType => structure(rt, rt.typeSymbol)
523524
case t: ExistentialType => makeExistentialType(in, t)
524525
case NoType =>
525526
Constants.emptyType // this can happen when there is an error that will be reported by a later phase
526527
case PolyType(typeParams, resultType) =>
527-
new xsbti.api.Polymorphic(processType(in, resultType), typeParameters(in, typeParams))
528+
xsbti.api.Polymorphic.of(processType(in, resultType), typeParameters(in, typeParams))
528529
case NullaryMethodType(_) =>
529530
warning("sbt-api: Unexpected nullary method type " + in + " in " + in.owner);
530531
Constants.emptyType
@@ -537,7 +538,7 @@ class ExtractAPI[GlobalType <: Global](
537538
try {
538539
val typeVariablesConverted = typeParameters(in, typeVariables)
539540
val qualifiedConverted = processType(in, qualified)
540-
new xsbti.api.Existential(qualifiedConverted, typeVariablesConverted)
541+
xsbti.api.Existential.of(qualifiedConverted, typeVariablesConverted)
541542
} finally {
542543
existentialRenamings.leaveExistentialTypeVariables(typeVariables)
543544
}
@@ -554,19 +555,19 @@ class ExtractAPI[GlobalType <: Global](
554555
if (varianceInt < 0) Contravariant else if (varianceInt > 0) Covariant else Invariant
555556
viewer(in).memberInfo(s) match {
556557
case TypeBounds(low, high) =>
557-
new xsbti.api.TypeParameter(tparamID(s),
558-
annots,
559-
typeParameters(in, s),
560-
variance,
561-
processType(in, low),
562-
processType(in, high))
558+
xsbti.api.TypeParameter.of(tparamID(s),
559+
annots,
560+
typeParameters(in, s),
561+
variance,
562+
processType(in, low),
563+
processType(in, high))
563564
case PolyType(typeParams, base) =>
564-
new xsbti.api.TypeParameter(tparamID(s),
565-
annots,
566-
typeParameters(in, typeParams),
567-
variance,
568-
processType(in, base.bounds.lo),
569-
processType(in, base.bounds.hi))
565+
xsbti.api.TypeParameter.of(tparamID(s),
566+
annots,
567+
typeParameters(in, typeParams),
568+
variance,
569+
processType(in, base.bounds.lo),
570+
processType(in, base.bounds.hi))
570571
case x => error("Unknown type parameter info: " + x.getClass)
571572
}
572573
}
@@ -629,7 +630,7 @@ class ExtractAPI[GlobalType <: Global](
629630
val tParams = typeParameters(in, sym) // look at class symbol
630631
val selfType = lzy(this.selfType(in, sym))
631632
def constructClass(structure: xsbti.api.Lazy[Structure]): ClassLike = {
632-
new xsbti.api.ClassLike(
633+
xsbti.api.ClassLike.of(
633634
name,
634635
acc,
635636
modifiers,
@@ -652,7 +653,7 @@ class ExtractAPI[GlobalType <: Global](
652653
_mainClasses += name
653654
}
654655

655-
val classDef = new xsbti.api.ClassLikeDef(
656+
val classDef = xsbti.api.ClassLikeDef.of(
656657
name,
657658
acc,
658659
modifiers,
@@ -690,14 +691,14 @@ class ExtractAPI[GlobalType <: Global](
690691
}
691692
}
692693
private object Constants {
693-
val local = new xsbti.api.ThisQualifier
694-
val public = new xsbti.api.Public
695-
val privateLocal = new xsbti.api.Private(local)
696-
val protectedLocal = new xsbti.api.Protected(local)
697-
val unqualified = new xsbti.api.Unqualified
698-
val emptyPath = new xsbti.api.Path(Array())
699-
val thisPath = new xsbti.api.This
700-
val emptyType = new xsbti.api.EmptyType
694+
val local = xsbti.api.ThisQualifier.of()
695+
val public = xsbti.api.Public.of()
696+
val privateLocal = xsbti.api.Private.of(local)
697+
val protectedLocal = xsbti.api.Protected.of(local)
698+
val unqualified = xsbti.api.Unqualified.of()
699+
val emptyPath = xsbti.api.Path.of(Array())
700+
val thisPath = xsbti.api.This.of()
701+
val emptyType = xsbti.api.EmptyType.of()
701702
}
702703

703704
private def simpleName(s: Symbol): String = {

internal/compiler-bridge/src/main/scala/xsbt/Message.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
package xsbt
99

10+
import java.util.function.Supplier
11+
1012
object Message {
11-
def apply[T](s: => T) = new xsbti.F0[T] { def apply() = s }
13+
def apply[T](s: => T): Supplier[T] = new Supplier[T] {
14+
override def get(): T = s
15+
}
1216
}

internal/compiler-bridge/src/test/scala/xsbt/ExtractAPISpecification.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class ExtractAPISpecification extends UnitSpec {
196196
List(srcX, srcY, srcC1, srcC2, srcC3, srcC4, srcC5, srcC6, srcC7, srcC8)
197197
)
198198
.map(_.head)
199-
val emptyType = new EmptyType
199+
val emptyType = EmptyType.of()
200200
def hasSelfType(c: ClassLike): Boolean =
201201
c.selfType != emptyType
202202
val (withSelfType, withoutSelfType) = apis.partition(hasSelfType)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]].
3+
*/
4+
5+
// DO NOT EDIT MANUALLY
6+
package xsbti.api;
7+
public abstract class Access implements java.io.Serializable {
8+
9+
10+
protected Access() {
11+
super();
12+
13+
}
14+
15+
16+
public boolean equals(Object obj) {
17+
if (this == obj) {
18+
return true;
19+
} else if (!(obj instanceof Access)) {
20+
return false;
21+
} else {
22+
Access o = (Access)obj;
23+
return true;
24+
}
25+
}
26+
public int hashCode() {
27+
return 37 * (17 + "xsbti.api.Access".hashCode());
28+
}
29+
public String toString() {
30+
return "Access(" + ")";
31+
}
32+
}

0 commit comments

Comments
 (0)