mirror of https://github.com/sbt/sbt.git
an annotation can reference a non-simple type, fixes #24
This commit is contained in:
parent
e88589c158
commit
24dfb69400
|
|
@ -211,7 +211,7 @@ class SameAPI(tagsA: TypeVars, tagsB: TypeVars, includePrivate: Boolean, include
|
|||
def sameAnnotations(a: Seq[Annotation], b: Seq[Annotation]): Boolean =
|
||||
sameSeq(a, b)(sameAnnotation)
|
||||
def sameAnnotation(a: Annotation, b: Annotation): Boolean =
|
||||
debug(sameSimpleType(a.base, b.base), "Annotation base type differed") &&
|
||||
debug(sameType(a.base, b.base), "Annotation base type differed") &&
|
||||
debug(sameAnnotationArguments(a.arguments, b.arguments), "Annotation arguments differed (" + a + ") and (" + b + ")")
|
||||
def sameAnnotationArguments(a: Seq[AnnotationArgument], b: Seq[AnnotationArgument]): Boolean =
|
||||
argumentMap(a) == argumentMap(b)
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ trait ShowTypes
|
|||
// don't show inherited to avoid dealing with cycles
|
||||
concat(s.parents, t, " with ") + "\n{\n" + lines(s.declared, d) + "\n}"
|
||||
}
|
||||
implicit def showAnnotated(implicit as: Show[Annotation], t: Show[SimpleType]): Show[Annotated] =
|
||||
implicit def showAnnotated(implicit as: Show[Annotation], t: Show[Type]): Show[Annotated] =
|
||||
new Show[Annotated] { def show(a: Annotated) = spaced(a.annotations, as) + " " + t.show(a.baseType) }
|
||||
implicit def showProjection(implicit t: Show[SimpleType]): Show[Projection] =
|
||||
new Show[Projection] { def show(p: Projection) = t.show(p.prefix) + "#" + p.id }
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ final class API(val global: Global, val callback: xsbti.AnalysisCallback) extend
|
|||
|
||||
private def annotations(in: Symbol, as: List[AnnotationInfo]): Array[xsbti.api.Annotation] = as.toArray[AnnotationInfo].map(annotation(in,_))
|
||||
private def annotation(in: Symbol, a: AnnotationInfo) =
|
||||
new xsbti.api.Annotation(simpleType(in, a.atp),
|
||||
new xsbti.api.Annotation(processType(in, a.atp),
|
||||
if(a.assocs.isEmpty) Array(new xsbti.api.AnnotationArgument("", 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) }.toArray[xsbti.api.AnnotationArgument]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ trait APIFormats extends FormatExtra
|
|||
p7( (td: TypeDeclaration) => (td.lowerBound, td.upperBound, td.typeParameters, td.name, td.access, td.modifiers, td.annotations))( new TypeDeclaration(_,_,_,_,_,_,_))(t,t,tps,n,acs,ms,ans)
|
||||
|
||||
// cyclic with SimpleType
|
||||
def formatAnnotation(implicit t: Format[SimpleType], af: Format[Array[AnnotationArgument]]): Format[Annotation] =
|
||||
def formatAnnotation(implicit t: Format[Type], af: Format[Array[AnnotationArgument]]): Format[Annotation] =
|
||||
p2( (a: Annotation) => (a.base, a.arguments) )( (a,b) => new Annotation(a,b) )(t, af)
|
||||
|
||||
implicit def formatAnnotationArgument(implicit sf: Format[String]): Format[AnnotationArgument] =
|
||||
|
|
@ -209,9 +209,9 @@ class DefaultAPIFormats(implicit val references: References) extends APIFormats
|
|||
implicit lazy val df: Format[Definition] = lazyFormat( formatDefinition )
|
||||
|
||||
// Projection, Annotation, and Parameterized are cyclic with SimpleType
|
||||
// Parameterized is also cyclic with Type
|
||||
// Parameterized and Annotation are also cyclic with Type
|
||||
implicit lazy val projf: Format[Projection] = formatProjection(stf, ??)
|
||||
implicit lazy val af: Format[Annotation] = formatAnnotation(stf, ??)
|
||||
implicit lazy val af: Format[Annotation] = formatAnnotation(tf, ??)
|
||||
implicit lazy val paramf: Format[Parameterized] = formatParameterized(stf, array(tf))
|
||||
|
||||
// Super and Path are cyclic
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ TypeParameter
|
|||
upperBound: Type
|
||||
|
||||
Annotation
|
||||
base: SimpleType
|
||||
base: Type
|
||||
arguments: AnnotationArgument*
|
||||
AnnotationArgument
|
||||
name: String
|
||||
|
|
|
|||
Loading…
Reference in New Issue