Skip to content

Commit ef4615d

Browse files
committed
Extending @experimental tests+impl
I wanted to make sure `@annotation.experimental` worked, turns out it already did, but adding to an existing test made me realise I need to handle SHAREDtype.
1 parent fa2a456 commit ef4615d

File tree

9 files changed

+26
-9
lines changed

9 files changed

+26
-9
lines changed

core/src/main/scala/com/typesafe/tools/mima/core/TastyReader.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ final class TastyReader(val bytes: Array[Byte], start: Int, end: Int, val base:
99

1010
private[this] var bp: Int = start
1111

12-
def fork = new TastyReader(bytes, bp, end, base)
13-
def forkAt(start: Addr, end: Addr) = new TastyReader(bytes, index(start), index(end), base)
12+
def fork = new TastyReader(bytes, bp, end, base)
13+
def forkAt(start: Addr) = new TastyReader(bytes, index(start), end, base)
1414

1515
def addr(idx: Int): Addr = Addr(idx - base)
1616
def index(addr: Addr): Int = addr.index + base

core/src/main/scala/com/typesafe/tools/mima/core/TastyUnpickler.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ object TastyUnpickler {
6464
}
6565
}
6666

67-
def unpickleTree(in: TastyReader, names: Names) = {
67+
def unpickleTree(in: TastyReader, names: Names): Tree = {
6868
import in._
6969

7070
def readName() = names(readNat())
7171
def skipTree(tag: Int) = { skipTreeTagged(in, tag); UnknownTree(tag) }
7272
def readTypeRefPkg() = TypeRefPkg(readName()) // fullyQualified_NameRef -- A reference to a package member with given fully qualified name
7373
def readTypeRef() = TypeRef(name = readName(), qual = readType()) // NameRef qual_Type -- A reference `qual.name` to a non-local member
7474
def readAnnot() = { readEnd(); Annot(readType(), skipTree(readByte())) } // tycon_Type fullAnnotation_Tree -- An annotation, given (class) type of constructor, and full application tree
75+
def readSharedType() = unpickleTree(forkAt(readAddr()), names).asInstanceOf[Type]
7576

7677
def readPath() = readByte() match {
7778
case TERMREFpkg => readTypeRefPkg()
@@ -81,6 +82,7 @@ object TastyUnpickler {
8182
def readType(): Type = readByte() match {
8283
case TYPEREF => readTypeRef()
8384
case TERMREFpkg => readTypeRefPkg()
85+
case SHAREDtype => readSharedType()
8486
case tag => skipTree(tag); UnknownType(tag)
8587
}
8688

@@ -509,7 +511,7 @@ object TastyUnpickler {
509511
case PACKAGE => readEnd(); readNames(packageName)
510512
case TERMREFpkg => readNames(readName())
511513
case TYPEREFpkg => readNames(readName())
512-
case SHAREDtype => val r = forkAt(readAddr(), endAddr); r.readByte(); readNames(readName(r))
514+
case SHAREDtype => val r = forkAt(readAddr()); r.readByte(); readNames(readName(r))
513515
case t => skipTreeTagged(in, t); readNames(packageName)
514516
}
515517
readNames(nme.Empty)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
object App {
2-
def main(args: Array[String]): Unit = println(new pkg1.pkg2.Foo().foo)
2+
def main(args: Array[String]): Unit = println(new pkg1.pkg2.Foo())
33
}

functional-tests/src/test/changes-in-experimental-are-ok/testAppRun.pending

Lines changed: 0 additions & 2 deletions
This file was deleted.

functional-tests/src/test/changes-in-experimental-are-ok/v1/A.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ import scala.annotation.experimental2
77
class Foo {
88
def foo = 1
99
}
10+
11+
@annotation.experimental2
12+
class Bar {
13+
def foo = 1
14+
}

functional-tests/src/test/changes-in-experimental-are-ok/v2/A.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@ import scala.annotation.experimental2
55

66
@experimental2
77
class Foo {
8-
def bar = 2
8+
def foo = "1"
9+
}
10+
11+
@annotation.experimental2
12+
class Bar {
13+
def foo = "1"
914
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Haven't implemented the ScalaSig unpickling part, only TASTy
2-
method foo()Int in class pkg1.pkg2.Foo does not have a correspondent in new version
2+
method foo()Int in class pkg1.pkg2.Foo has a different result type in new version, where it is java.lang.String rather than Int
3+
method bar()Int in class pkg1.pkg2.Foo has a different result type in new version, where it is java.lang.String rather than Int

functional-tests/src/test/changes-in-experimental-methods-are-ok/v1/A.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ import scala.annotation.experimental2
66
class Foo {
77
@experimental2
88
def foo = 1
9+
10+
@annotation.experimental2
11+
def bar = 1
912
}

functional-tests/src/test/changes-in-experimental-methods-are-ok/v2/A.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ import scala.annotation.experimental2
55

66
class Foo {
77
@experimental2
8+
def foo = "1"
9+
10+
@annotation.experimental2
811
def bar = "1"
912
}

0 commit comments

Comments
 (0)