mirror of https://github.com/sbt/sbt.git
API extraction: handle any type that is annotated, not just the spec'd simple type. Fixes #559.
This commit is contained in:
parent
0bf22bb0e6
commit
18a03f0e25
|
|
@ -325,7 +325,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean)
|
||||||
sameTypeParameters(a.parameters, b.parameters) &&
|
sameTypeParameters(a.parameters, b.parameters) &&
|
||||||
sameType(a.baseType, b.baseType)
|
sameType(a.baseType, b.baseType)
|
||||||
def sameAnnotatedType(a: Annotated, b: Annotated): Boolean =
|
def sameAnnotatedType(a: Annotated, b: Annotated): Boolean =
|
||||||
sameSimpleType(a.baseType, b.baseType) &&
|
sameType(a.baseType, b.baseType) &&
|
||||||
sameAnnotations(a.annotations, b.annotations)
|
sameAnnotations(a.annotations, b.annotations)
|
||||||
def sameStructure(a: Structure, b: Structure): Boolean =
|
def sameStructure(a: Structure, b: Structure): Boolean =
|
||||||
samePending(a,b)(sameStructureDirect)
|
samePending(a,b)(sameStructureDirect)
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ final class API(val global: CallbackGlobal) extends Compat
|
||||||
if(a.assocs.isEmpty) Array(new xsbti.api.AnnotationArgument("", a.args.mkString("(", ",", ")"))) // what else to do with a Tree?
|
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]
|
else a.assocs.map { case (name, value) => new xsbti.api.AnnotationArgument(name.toString, value.toString) }.toArray[xsbti.api.AnnotationArgument]
|
||||||
)
|
)
|
||||||
private def annotated(in: Symbol, as: List[AnnotationInfo], tpe: Type) = new xsbti.api.Annotated(simpleType(in, tpe), annotations(in, as))
|
private def annotated(in: Symbol, as: List[AnnotationInfo], tpe: Type) = new xsbti.api.Annotated(processType(in, tpe), annotations(in, as))
|
||||||
|
|
||||||
private def viewer(s: Symbol) = (if(s.isModule) s.moduleClass else s).thisType
|
private def viewer(s: Symbol) = (if(s.isModule) s.moduleClass else s).thisType
|
||||||
private def printMember(label: String, in: Symbol, t: Type) = println(label + " in " + in + " : " + t + " (debug: " + debugString(t) + " )")
|
private def printMember(label: String, in: Symbol, t: Type) = println(label + " in " + in + " : " + t + " (debug: " + debugString(t) + " )")
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ trait APIFormats extends FormatExtra
|
||||||
implicit def formatSource(implicit pa: Format[Array[Package]], da: Format[Array[Definition]]): Format[SourceAPI] =
|
implicit def formatSource(implicit pa: Format[Array[Package]], da: Format[Array[Definition]]): Format[SourceAPI] =
|
||||||
p2( (s: SourceAPI) => (s.packages, s.definitions))( (p, d) => new SourceAPI(p, d) )(pa, da)
|
p2( (s: SourceAPI) => (s.packages, s.definitions))( (p, d) => new SourceAPI(p, d) )(pa, da)
|
||||||
|
|
||||||
implicit def formatAnnotated(implicit t: Format[SimpleType], as: Format[Array[Annotation]]): Format[Annotated] =
|
implicit def formatAnnotated(implicit t: Format[Type], as: Format[Array[Annotation]]): Format[Annotated] =
|
||||||
p2( (a: Annotated) => (a.baseType,a.annotations))(new Annotated(_,_))(t,as)
|
p2( (a: Annotated) => (a.baseType,a.annotations))(new Annotated(_,_))(t,as)
|
||||||
|
|
||||||
implicit def formatPolymorphic(implicit t: Format[Type], tps: Format[Array[TypeParameter]]): Format[Polymorphic] =
|
implicit def formatPolymorphic(implicit t: Format[Type], tps: Format[Array[TypeParameter]]): Format[Polymorphic] =
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ Type
|
||||||
baseType: Type
|
baseType: Type
|
||||||
value: String
|
value: String
|
||||||
Annotated
|
Annotated
|
||||||
baseType : SimpleType
|
baseType : Type
|
||||||
annotations : Annotation*
|
annotations : Annotation*
|
||||||
Structure
|
Structure
|
||||||
parents : ~Type*
|
parents : ~Type*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
trait Foo
|
||||||
|
trait BarA
|
||||||
|
trait BarB
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
import scala.util.continuations._
|
||||||
|
|
||||||
|
class Use {
|
||||||
|
val a = new Baz
|
||||||
|
def bar: (Foo with BarA) @cpsParam[Unit, Unit] = a.foo
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
autoCompilerPlugins := true
|
||||||
|
|
||||||
|
addCompilerPlugin("org.scala-lang.plugins" % "continuations" % "2.9.2")
|
||||||
|
|
||||||
|
scalaVersion := "2.9.2"
|
||||||
|
|
||||||
|
scalacOptions += "-P:continuations:enable"
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import scala.util.continuations._
|
||||||
|
|
||||||
|
class Baz {
|
||||||
|
def foo = shiftUnit[Foo with BarA, Unit, Unit](null)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import scala.util.continuations._
|
||||||
|
|
||||||
|
class Baz {
|
||||||
|
def foo = shiftUnit[Foo with BarB, Unit, Unit](null)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Compile code with a type (Foo with BarA) @cpsParam...
|
||||||
|
# The spec says only simple types can be annotated, but scalac allows any type.
|
||||||
|
$ copy-file changes/Def1.scala Def.scala
|
||||||
|
> compile
|
||||||
|
|
||||||
|
# To ensure it was properly processed, change it to (Foo with BarB) @cpsParam...
|
||||||
|
# This should invalidate Use.scala, which expects it to be BarA and so compilation should fail.
|
||||||
|
$ delete Def.scala
|
||||||
|
$ copy-file changes/Def2.scala Def.scala
|
||||||
|
-> compile
|
||||||
Loading…
Reference in New Issue