Skip to content

Commit

Permalink
Bump to the latest Contraband
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Jul 15, 2017
1 parent 88dc0ed commit 68ac7a2
Show file tree
Hide file tree
Showing 94 changed files with 794 additions and 462 deletions.
121 changes: 61 additions & 60 deletions internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ class ExtractAPI[GlobalType <: Global](

private def thisPath(sym: Symbol) = path(pathComponents(sym, Constants.thisPath :: Nil))
private def path(components: List[PathComponent]) =
new xsbti.api.Path(components.toArray[PathComponent])
xsbti.api.Path.of(components.toArray[PathComponent])
private def pathComponents(sym: Symbol, postfix: List[PathComponent]): List[PathComponent] = {
if (sym == NoSymbol || sym.isRoot || sym.isEmptyPackageClass || sym.isRootPackage) postfix
else pathComponents(sym.owner, new xsbti.api.Id(simpleName(sym)) :: postfix)
else pathComponents(sym.owner, xsbti.api.Id.of(simpleName(sym)) :: postfix)
}
private def types(in: Symbol, t: List[Type]): Array[xsbti.api.Type] =
t.toArray[Type].map(processType(in, _))
Expand All @@ -191,24 +191,25 @@ class ExtractAPI[GlobalType <: Global](
reference(sym)
}
} else if (sym.isRoot || sym.isRootPackage) Constants.emptyType
else new xsbti.api.Projection(processType(in, pre), simpleName(sym))
else xsbti.api.Projection.of(processType(in, pre), simpleName(sym))
}
private def reference(sym: Symbol): xsbti.api.ParameterRef =
new xsbti.api.ParameterRef(tparamID(sym))
xsbti.api.ParameterRef.of(tparamID(sym))

// The compiler only pickles static annotations, so only include these in the API.
// This way, the API is not sensitive to whether we compiled from source or loaded from classfile.
// (When looking at the sources we see all annotations, but when loading from classes we only see the pickled (static) ones.)
private def mkAnnotations(in: Symbol, as: List[AnnotationInfo]): Array[xsbti.api.Annotation] =
staticAnnotations(as).toArray.map { a =>
new xsbti.api.Annotation(
xsbti.api.Annotation.of(
processType(in, a.atp),
if (a.assocs.isEmpty)
Array(new xsbti.api.AnnotationArgument("", a.args.mkString("(", ",", ")"))) // what else to do with a Tree?
Array(xsbti.api.AnnotationArgument.of("", a.args.mkString("(", ",", ")"))) // what else to do with a Tree?
else
a.assocs
.map {
case (name, value) => new xsbti.api.AnnotationArgument(name.toString, value.toString)
case (name, value) =>
xsbti.api.AnnotationArgument.of(name.toString, value.toString)
}
.toArray[xsbti.api.AnnotationArgument]
)
Expand All @@ -234,7 +235,7 @@ class ExtractAPI[GlobalType <: Global](
valueParameters: List[xsbti.api.ParameterList]): xsbti.api.Def = {
def parameterList(syms: List[Symbol]): xsbti.api.ParameterList = {
val isImplicitList = syms match { case head :: _ => isImplicit(head); case _ => false }
new xsbti.api.ParameterList(syms.map(parameterS).toArray, isImplicitList)
xsbti.api.ParameterList.of(syms.map(parameterS).toArray, isImplicitList)
}
t match {
case PolyType(typeParams0, base) =>
Expand All @@ -247,13 +248,13 @@ class ExtractAPI[GlobalType <: Global](
build(resultType, typeParams, valueParameters)
case returnType =>
val retType = processType(in, dropConst(returnType))
new xsbti.api.Def(simpleName(s),
getAccess(s),
getModifiers(s),
annotations(in, s),
typeParams,
valueParameters.reverse.toArray,
retType)
xsbti.api.Def.of(simpleName(s),
getAccess(s),
getModifiers(s),
annotations(in, s),
typeParams,
valueParameters.reverse.toArray,
retType)
}
}
def parameterS(s: Symbol): xsbti.api.MethodParameter = {
Expand All @@ -274,7 +275,7 @@ class ExtractAPI[GlobalType <: Global](
(tpe.typeArgs.head, ByName)
else
(tpe, Plain)
new xsbti.api.MethodParameter(name, processType(in, t), hasDefault(paramSym), special)
xsbti.api.MethodParameter.of(name, processType(in, t), hasDefault(paramSym), special)
}
val t = viewer(in).memberInfo(s)
build(t, Array(), Nil)
Expand Down Expand Up @@ -313,16 +314,16 @@ class ExtractAPI[GlobalType <: Global](
val as = annotations(in, s)

if (s.isAliasType)
new xsbti.api.TypeAlias(name, access, modifiers, as, typeParams, processType(in, tpe))
xsbti.api.TypeAlias.of(name, access, modifiers, as, typeParams, processType(in, tpe))
else if (s.isAbstractType) {
val bounds = tpe.bounds
new xsbti.api.TypeDeclaration(name,
access,
modifiers,
as,
typeParams,
processType(in, bounds.lo),
processType(in, bounds.hi))
xsbti.api.TypeDeclaration.of(name,
access,
modifiers,
as,
typeParams,
processType(in, bounds.lo),
processType(in, bounds.hi))
} else
error("Unknown type member" + s)
}
Expand Down Expand Up @@ -375,9 +376,9 @@ class ExtractAPI[GlobalType <: Global](
bases: List[Type],
declared: List[Symbol],
inherited: List[Symbol]): xsbti.api.Structure = {
new xsbti.api.Structure(lzy(types(s, bases)),
lzy(processDefinitions(s, declared)),
lzy(processDefinitions(s, inherited)))
xsbti.api.Structure.of(lzy(types(s, bases)),
lzy(processDefinitions(s, declared)),
lzy(processDefinitions(s, inherited)))
}
private def processDefinitions(in: Symbol,
defs: List[Symbol]): Array[xsbti.api.ClassDefinition] =
Expand All @@ -388,8 +389,8 @@ class ExtractAPI[GlobalType <: Global](
}

private def definition(in: Symbol, sym: Symbol): Option[xsbti.api.ClassDefinition] = {
def mkVar = Some(fieldDef(in, sym, keepConst = false, new xsbti.api.Var(_, _, _, _, _)))
def mkVal = Some(fieldDef(in, sym, keepConst = true, new xsbti.api.Val(_, _, _, _, _)))
def mkVar = Some(fieldDef(in, sym, keepConst = false, xsbti.api.Var.of(_, _, _, _, _)))
def mkVal = Some(fieldDef(in, sym, keepConst = true, xsbti.api.Val.of(_, _, _, _, _)))
if (isClass(sym))
if (ignoreClass(sym)) None else Some(classLike(in, sym))
else if (sym.isNonClassType)
Expand Down Expand Up @@ -438,9 +439,9 @@ class ExtractAPI[GlobalType <: Global](
val within = c.privateWithin
val qualifier =
if (within == NoSymbol) Constants.unqualified
else new xsbti.api.IdQualifier(within.fullName)
if (c.hasFlag(Flags.PROTECTED)) new xsbti.api.Protected(qualifier)
else new xsbti.api.Private(qualifier)
else xsbti.api.IdQualifier.of(within.fullName)
if (c.hasFlag(Flags.PROTECTED)) xsbti.api.Protected.of(qualifier)
else xsbti.api.Private.of(qualifier)
}
}

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

dealiased match {
case NoPrefix => Constants.emptyType
case ThisType(sym) => new xsbti.api.Singleton(thisPath(sym))
case ThisType(sym) => xsbti.api.Singleton.of(thisPath(sym))
case SingleType(pre, sym) => projectionType(in, pre, sym)
case ConstantType(constant) =>
new xsbti.api.Constant(processType(in, constant.tpe), constant.stringValue)
xsbti.api.Constant.of(processType(in, constant.tpe), constant.stringValue)

/* explaining the special-casing of references to refinement classes (https://support.typesafe.com/tickets/1882)
*
Expand Down Expand Up @@ -509,22 +510,22 @@ class ExtractAPI[GlobalType <: Global](
else
base
else
new xsbti.api.Parameterized(base, types(in, args))
xsbti.api.Parameterized.of(base, types(in, args))
case SuperType(thistpe: Type, supertpe: Type) =>
warning("sbt-api: Super type (not implemented): this=" + thistpe + ", super=" + supertpe);
Constants.emptyType
case at: AnnotatedType =>
at.annotations match {
case Nil => processType(in, at.underlying)
case annots =>
new xsbti.api.Annotated(processType(in, at.underlying), mkAnnotations(in, annots))
xsbti.api.Annotated.of(processType(in, at.underlying), mkAnnotations(in, annots))
}
case rt: CompoundType => structure(rt, rt.typeSymbol)
case t: ExistentialType => makeExistentialType(in, t)
case NoType =>
Constants.emptyType // this can happen when there is an error that will be reported by a later phase
case PolyType(typeParams, resultType) =>
new xsbti.api.Polymorphic(processType(in, resultType), typeParameters(in, typeParams))
xsbti.api.Polymorphic.of(processType(in, resultType), typeParameters(in, typeParams))
case NullaryMethodType(_) =>
warning("sbt-api: Unexpected nullary method type " + in + " in " + in.owner);
Constants.emptyType
Expand All @@ -537,7 +538,7 @@ class ExtractAPI[GlobalType <: Global](
try {
val typeVariablesConverted = typeParameters(in, typeVariables)
val qualifiedConverted = processType(in, qualified)
new xsbti.api.Existential(qualifiedConverted, typeVariablesConverted)
xsbti.api.Existential.of(qualifiedConverted, typeVariablesConverted)
} finally {
existentialRenamings.leaveExistentialTypeVariables(typeVariables)
}
Expand All @@ -554,19 +555,19 @@ class ExtractAPI[GlobalType <: Global](
if (varianceInt < 0) Contravariant else if (varianceInt > 0) Covariant else Invariant
viewer(in).memberInfo(s) match {
case TypeBounds(low, high) =>
new xsbti.api.TypeParameter(tparamID(s),
annots,
typeParameters(in, s),
variance,
processType(in, low),
processType(in, high))
xsbti.api.TypeParameter.of(tparamID(s),
annots,
typeParameters(in, s),
variance,
processType(in, low),
processType(in, high))
case PolyType(typeParams, base) =>
new xsbti.api.TypeParameter(tparamID(s),
annots,
typeParameters(in, typeParams),
variance,
processType(in, base.bounds.lo),
processType(in, base.bounds.hi))
xsbti.api.TypeParameter.of(tparamID(s),
annots,
typeParameters(in, typeParams),
variance,
processType(in, base.bounds.lo),
processType(in, base.bounds.hi))
case x => error("Unknown type parameter info: " + x.getClass)
}
}
Expand Down Expand Up @@ -629,7 +630,7 @@ class ExtractAPI[GlobalType <: Global](
val tParams = typeParameters(in, sym) // look at class symbol
val selfType = lzy(this.selfType(in, sym))
def constructClass(structure: xsbti.api.Lazy[Structure]): ClassLike = {
new xsbti.api.ClassLike(
xsbti.api.ClassLike.of(
name,
acc,
modifiers,
Expand All @@ -652,7 +653,7 @@ class ExtractAPI[GlobalType <: Global](
_mainClasses += name
}

val classDef = new xsbti.api.ClassLikeDef(
val classDef = xsbti.api.ClassLikeDef.of(
name,
acc,
modifiers,
Expand Down Expand Up @@ -690,14 +691,14 @@ class ExtractAPI[GlobalType <: Global](
}
}
private object Constants {
val local = new xsbti.api.ThisQualifier
val public = new xsbti.api.Public
val privateLocal = new xsbti.api.Private(local)
val protectedLocal = new xsbti.api.Protected(local)
val unqualified = new xsbti.api.Unqualified
val emptyPath = new xsbti.api.Path(Array())
val thisPath = new xsbti.api.This
val emptyType = new xsbti.api.EmptyType
val local = xsbti.api.ThisQualifier.of()
val public = xsbti.api.Public.of()
val privateLocal = xsbti.api.Private.of(local)
val protectedLocal = xsbti.api.Protected.of(local)
val unqualified = xsbti.api.Unqualified.of()
val emptyPath = xsbti.api.Path.of(Array())
val thisPath = xsbti.api.This.of()
val emptyType = xsbti.api.EmptyType.of()
}

private def simpleName(s: Symbol): String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class ExtractAPISpecification extends UnitSpec {
List(srcX, srcY, srcC1, srcC2, srcC3, srcC4, srcC5, srcC6, srcC7, srcC8)
)
.map(_.head)
val emptyType = new EmptyType
val emptyType = EmptyType.of()
def hasSelfType(c: ClassLike): Boolean =
c.selfType != emptyType
val (withSelfType, withoutSelfType) = apis.partition(hasSelfType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public abstract class Access implements java.io.Serializable {


public Access() {
protected Access() {
super();

}
Expand All @@ -24,7 +24,7 @@ public boolean equals(Object obj) {
}
}
public int hashCode() {
return 37 * (17 + "Access".hashCode());
return 37 * (17 + "xsbti.api.Access".hashCode());
}
public String toString() {
return "Access(" + ")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
package xsbti.api;
public final class AnalyzedClass implements java.io.Serializable {

public static AnalyzedClass create(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro) {
return new AnalyzedClass(_compilationTimestamp, _name, _api, _apiHash, _nameHashes, _hasMacro);
}
public static AnalyzedClass of(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro) {
return new AnalyzedClass(_compilationTimestamp, _name, _api, _apiHash, _nameHashes, _hasMacro);
}

private long compilationTimestamp;
private String name;
private xsbti.api.Lazy<Companions> api;
private int apiHash;
private NameHash[] nameHashes;
private boolean hasMacro;
public AnalyzedClass(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro) {
protected AnalyzedClass(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro) {
super();
compilationTimestamp = _compilationTimestamp;
name = _name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
package xsbti.api;
public final class Annotated extends xsbti.api.Type {

public static Annotated create(Type _baseType, Annotation[] _annotations) {
return new Annotated(_baseType, _annotations);
}
public static Annotated of(Type _baseType, Annotation[] _annotations) {
return new Annotated(_baseType, _annotations);
}

private Type baseType;
private Annotation[] annotations;
public Annotated(Type _baseType, Annotation[] _annotations) {
protected Annotated(Type _baseType, Annotation[] _annotations) {
super();
baseType = _baseType;
annotations = _annotations;
Expand Down Expand Up @@ -37,7 +43,7 @@ public boolean equals(Object obj) {
}
}
public int hashCode() {
return 37 * (37 * (37 * (17 + "Annotated".hashCode()) + baseType().hashCode()) + annotations().hashCode());
return 37 * (37 * (37 * (17 + "xsbti.api.Annotated".hashCode()) + baseType().hashCode()) + annotations().hashCode());
}
public String toString() {
return "Annotated(" + "baseType: " + baseType() + ", " + "annotations: " + annotations() + ")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
package xsbti.api;
public final class Annotation implements java.io.Serializable {

public static Annotation create(Type _base, AnnotationArgument[] _arguments) {
return new Annotation(_base, _arguments);
}
public static Annotation of(Type _base, AnnotationArgument[] _arguments) {
return new Annotation(_base, _arguments);
}

private Type base;
private AnnotationArgument[] arguments;
public Annotation(Type _base, AnnotationArgument[] _arguments) {
protected Annotation(Type _base, AnnotationArgument[] _arguments) {
super();
base = _base;
arguments = _arguments;
Expand Down Expand Up @@ -37,7 +43,7 @@ public boolean equals(Object obj) {
}
}
public int hashCode() {
return 37 * (37 * (37 * (17 + "Annotation".hashCode()) + base().hashCode()) + arguments().hashCode());
return 37 * (37 * (37 * (17 + "xsbti.api.Annotation".hashCode()) + base().hashCode()) + arguments().hashCode());
}
public String toString() {
return "Annotation(" + "base: " + base() + ", " + "arguments: " + arguments() + ")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
package xsbti.api;
public final class AnnotationArgument implements java.io.Serializable {

public static AnnotationArgument create(String _name, String _value) {
return new AnnotationArgument(_name, _value);
}
public static AnnotationArgument of(String _name, String _value) {
return new AnnotationArgument(_name, _value);
}

private String name;
private String value;
public AnnotationArgument(String _name, String _value) {
protected AnnotationArgument(String _name, String _value) {
super();
name = _name;
value = _value;
Expand Down Expand Up @@ -37,7 +43,7 @@ public boolean equals(Object obj) {
}
}
public int hashCode() {
return 37 * (37 * (37 * (17 + "AnnotationArgument".hashCode()) + name().hashCode()) + value().hashCode());
return 37 * (37 * (37 * (17 + "xsbti.api.AnnotationArgument".hashCode()) + name().hashCode()) + value().hashCode());
}
public String toString() {
return "AnnotationArgument(" + "name: " + name() + ", " + "value: " + value() + ")";
Expand Down
Loading

0 comments on commit 68ac7a2

Please sign in to comment.