Skip to content

Make annotation reading lazier in Scala2Unpickler #12117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1011,9 +1011,9 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
*/
protected def deferredAnnot(end: Int)(using Context): Annotation = {
val start = readIndex
val atp = readTypeRef()
val phase = ctx.phase
Annotation.deferred(atp.typeSymbol)(
Annotation.deferredSymAndTree(
atReadPos(start, () => atPhase(phase)(readTypeRef().typeSymbol)))(
atReadPos(start, () => atPhase(phase)(readAnnotationContents(end))))
}

Expand Down
3 changes: 3 additions & 0 deletions sbt-dotty/sbt-test/scala2-compat/i12109/app/App.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import i12109.*

def test = JsonReaderDefaultValue
13 changes: 13 additions & 0 deletions sbt-dotty/sbt-test/scala2-compat/i12109/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
val scala3Version = sys.props("plugin.scalaVersion")
val scala2Version = "2.13.5"

lazy val lib = project.in(file("lib"))
.settings(
scalaVersion := scala2Version
)

lazy val app = project.in(file("app"))
.dependsOn(lib)
.settings(
scalaVersion := scala3Version
)
10 changes: 10 additions & 0 deletions sbt-dotty/sbt-test/scala2-compat/i12109/lib/Lib.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package i12109

object JsonReaderDefaultValue extends LowPriorityDefaultValue {
class ReaderDefaultValue extends scala.annotation.StaticAnnotation
}

trait LowPriorityDefaultValue {
@JsonReaderDefaultValue.ReaderDefaultValue
class NoDefaultValue
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.version"))
1 change: 1 addition & 0 deletions sbt-dotty/sbt-test/scala2-compat/i12109/test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
> app/compile