Merge branch '0.13' into 0.13.10

This commit is contained in:
Eugene Yokota 2016-01-24 15:57:53 -08:00
commit e64b01142b
5 changed files with 42 additions and 15 deletions

View File

@ -45,15 +45,10 @@ abstract class Compat {
val Nullary = global.NullaryMethodType
val ScalaObjectClass = definitions.ScalaObjectClass
// `afterPostErasure` doesn't exist in Scala < 2.10
implicit def withAfterPostErasure(global: Global): WithAfterPostErasure = new WithAfterPostErasure(global)
class WithAfterPostErasure(global: Global) {
def afterPostErasure[T](op: => T): T = op
}
// `exitingPostErasure` was called `afterPostErasure` in 2.10
implicit def withExitingPostErasure(global: Global): WithExitingPostErasure = new WithExitingPostErasure(global)
class WithExitingPostErasure(global: Global) {
def exitingPostErasure[T](op: => T): T = global afterPostErasure op
// `transformedType` doesn't exist in Scala < 2.10
implicit def withTransformedType(global: Global): WithTransformedType = new WithTransformedType(global)
class WithTransformedType(global: Global) {
def transformedType(tpe: Type): Type = tpe
}
private[this] final class MiscCompat {

View File

@ -225,10 +225,10 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
def build(t: Type, typeParams: Array[xsbti.api.TypeParameter], valueParameters: List[xsbti.api.ParameterList]): List[xsbti.api.Def] =
{
def parameterList(syms: List[Symbol]): xsbti.api.ParameterList =
def parameterList(syms: List[Symbol], erase: Boolean = false): xsbti.api.ParameterList =
{
val isImplicitList = syms match { case head :: _ => isImplicit(head); case _ => false }
new xsbti.api.ParameterList(syms.map(parameterS).toArray, isImplicitList)
new xsbti.api.ParameterList(syms.map(parameterS(erase)).toArray, isImplicitList)
}
t match {
case PolyType(typeParams0, base) =>
@ -249,7 +249,7 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
build(resultType, typeParams, parameterList(params) :: valueParameters)
val afterErasure =
if (inspectPostErasure)
build(resultType, typeParams, global exitingPostErasure (parameterList(mType.params) :: valueParameters))
build(resultType, typeParams, parameterList(mType.params, erase = true) :: valueParameters)
else
Nil
@ -277,7 +277,7 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
val beforeErasure = makeDef(processType(in, dropConst(returnType)))
val afterErasure =
if (inspectPostErasure) {
val erasedReturn = dropConst(global exitingPostErasure viewer(in).memberInfo(s)) map {
val erasedReturn = dropConst(global.transformedType(viewer(in).memberInfo(s))) map {
case MethodType(_, r) => r
case other => other
}
@ -287,8 +287,10 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
beforeErasure :: afterErasure
}
}
def parameterS(s: Symbol): xsbti.api.MethodParameter =
makeParameter(simpleName(s), s.info, s.info.typeSymbol, s)
def parameterS(erase: Boolean)(s: Symbol): xsbti.api.MethodParameter = {
val tp = if (erase) global.transformedType(s.info) else s.info
makeParameter(simpleName(s), tp, tp.typeSymbol, s)
}
// paramSym is only for 2.8 and is to determine if the parameter has a default
def makeParameter(name: String, tpe: Type, ts: Symbol, paramSym: Symbol): xsbti.api.MethodParameter =

View File

@ -0,0 +1,11 @@
package example
class A {
case class B(x: Int)
def c = B
}
object A {
def main(args: Array[String]): Unit = {
(new A).c
}
}

View File

@ -0,0 +1,13 @@
package example
class VC(val self: Int) extends AnyVal
class A {
case class B(x: VC)
def c = B
}
object A {
def main(args: Array[String]): Unit = {
(new A).c
}
}

View File

@ -0,0 +1,6 @@
$ copy-file changes/A0.scala A.scala
> run
# The same test case, but involving value classes
$ copy-file changes/A1.scala A.scala
> run