@@ -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 = {
0 commit comments