diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index af17a866c5c0..fe620e61e89c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,12 +4,12 @@ on: push: paths-ignore: # Do not run everything on changes only in docs - - 'scala3doc/**' + - 'scala3doc/**' - 'scala3doc-testcases/**' pull_request: paths-ignore: # Do not run everything on changes only in docs - - 'scala3doc/**' + - 'scala3doc/**' - 'scala3doc-testcases/**' schedule: - cron: '0 3 * * *' # Every day at 3 AM @@ -20,13 +20,13 @@ env: jobs: test: runs-on: [self-hosted, Linux] - container: lampepfl/dotty:2020-04-24 + container: lampepfl/dotty:2020-09-08 if: "!(github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/sbt-dotty-'))" steps: - name: Set JDK 11 as default - run: echo "/usr/lib/jvm/java-11-openjdk-amd64/bin" >> $GITHUB_PATH + run: echo "/usr/lib/jvm/java-14-openjdk-amd64/bin" >> $GITHUB_PATH - name: Checkout cleanup script uses: actions/checkout@v2 @@ -65,13 +65,13 @@ jobs: test_bootstrapped: runs-on: [self-hosted, Linux] - container: lampepfl/dotty:2020-04-24 + container: lampepfl/dotty:2020-09-08 if: "!(github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/sbt-dotty-'))" steps: - name: Set JDK 11 as default - run: echo "/usr/lib/jvm/java-11-openjdk-amd64/bin" >> $GITHUB_PATH + run: echo "/usr/lib/jvm/java-14-openjdk-amd64/bin" >> $GITHUB_PATH - name: Checkout cleanup script uses: actions/checkout@v2 @@ -143,7 +143,7 @@ jobs: community_build: runs-on: [self-hosted, Linux] - container: lampepfl/dotty:2020-04-24 + container: lampepfl/dotty:2020-09-08 steps: - name: Checkout cleanup script @@ -184,7 +184,7 @@ jobs: test_sbt: runs-on: [self-hosted, Linux] - container: lampepfl/dotty:2020-04-24 + container: lampepfl/dotty:2020-09-08 if: ( github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') @@ -227,7 +227,7 @@ jobs: test_java8: runs-on: [self-hosted, Linux] - container: lampepfl/dotty:2020-04-24 + container: lampepfl/dotty:2020-09-08 if: "( github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') && @@ -274,7 +274,7 @@ jobs: publish_nightly: runs-on: [self-hosted, Linux] - container: lampepfl/dotty:2020-04-24 + container: lampepfl/dotty:2020-09-08 needs: [test, test_bootstrapped, community_build, test_sbt, test_java8] if: github.event_name == 'schedule' env: @@ -321,7 +321,7 @@ jobs: nightly_documentation: runs-on: [self-hosted, Linux] - container: lampepfl/dotty:2020-04-24 + container: lampepfl/dotty:2020-09-08 needs: [publish_nightly] if: github.event_name == 'schedule' env: @@ -375,7 +375,7 @@ jobs: publish_release: runs-on: [self-hosted, Linux] - container: lampepfl/dotty:2020-04-24 + container: lampepfl/dotty:2020-09-08 needs: [test, test_bootstrapped, community_build, test_sbt, test_java8] if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') && @@ -470,7 +470,7 @@ jobs: release_documentation: runs-on: [self-hosted, Linux] - container: lampepfl/dotty:2020-04-24 + container: lampepfl/dotty:2020-09-08 needs: [publish_release] if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') && @@ -527,7 +527,7 @@ jobs: publish_sbt_release: runs-on: [self-hosted, Linux] - container: lampepfl/dotty:2020-04-24 + container: lampepfl/dotty:2020-09-08 needs: [community_build, test_sbt] if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/sbt-dotty-') diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 5edfaa29dc9c..10c8a9051199 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -518,16 +518,24 @@ class ClassfileParser( } // sigToType - def parseAnnotArg(skip: Boolean = false)(using ctx: Context, in: DataReader): Option[untpd.Tree] = { + class EnumTag(sig: String, name: NameOrString) { + def toTree(using ctx: Context): untpd.Tree = { + val enumClassTp = sigToType(sig) + val enumModuleClass = enumClassTp.classSymbol.companionModule + val tmref = TermRef(enumModuleClass.termRef, name.name) + untpd.TypedSplice(ref(tmref)) + } + } + + def parseAnnotArg(skip: Boolean = false)(using ctx: Context, in: DataReader): Option[untpd.Tree | EnumTag] = { // If we encounter an empty array literal, we need the type of the corresponding // parameter to properly type it, but that would require forcing the annotation // early. To avoid this we store annotation arguments as untyped trees - import untpd._ // ... but constants need to actually be typed with a ConstantType, so we // can't rely on type inference, and type them early. - def lit(c: Constant): Tree = TypedSplice(ast.tpd.Literal(c)) + def lit(c: Constant): untpd.Tree = untpd.TypedSplice(tpd.Literal(c)) val tag = in.nextByte.toChar val index = in.nextChar @@ -545,34 +553,36 @@ class ClassfileParser( case CLASS_TAG => if (skip) None else Some(lit(Constant(pool.getType(index)))) case ENUM_TAG => - val enumClassTp = pool.getType(index) + val sig = pool.getExternalName(index).value val enumCaseName = pool.getName(in.nextChar) - if (skip) - None - else { - val enumModuleClass = enumClassTp.classSymbol.companionModule - Some(Select(ref(enumModuleClass), enumCaseName.name)) - } + if (skip) None else Some(EnumTag(sig, enumCaseName)) case ARRAY_TAG => - val arr = new ArrayBuffer[Tree]() + val arr = new ArrayBuffer[untpd.Tree]() var hasError = false for (i <- 0 until index) parseAnnotArg(skip) match { - case Some(c) => arr += c + case Some(c: untpd.Tree) => arr += c + case Some(tag: EnumTag) => arr += tag.toTree case None => hasError = true } if (hasError) None else if (skip) None else { val elems = arr.toList - Some(untpd.JavaSeqLiteral(elems, TypeTree())) + Some(untpd.JavaSeqLiteral(elems, untpd.TypeTree())) } case ANNOTATION_TAG => parseAnnotation(index, skip).map(_.untpdTree) } } - class ClassfileAnnotation(annotType: Type, args: List[untpd.Tree]) extends LazyAnnotation { + class ClassfileAnnotation(annotType: Type, lazyArgs: List[(NameOrString, untpd.Tree | EnumTag)]) extends LazyAnnotation { + private def args(using Context): List[untpd.Tree] = + lazyArgs.map { + case (name, tree: untpd.Tree) => untpd.NamedArg(name.name, tree).withSpan(NoSpan) + case (name, tag: EnumTag) => untpd.NamedArg(name.name, tag.toTree).withSpan(NoSpan) + } + protected var mySym: Symbol | (Context ?=> Symbol) = (using ctx: Context) => annotType.classSymbol @@ -598,13 +608,16 @@ class ClassfileParser( case _ => val nargs = in.nextChar - val argbuf = new ListBuffer[untpd.Tree] + val argbuf = new ListBuffer[(NameOrString, untpd.Tree | EnumTag)] var hasError = false for (i <- 0 until nargs) { val name = pool.getName(in.nextChar) parseAnnotArg(skip) match { - case Some(arg) => argbuf += untpd.NamedArg(name.name, arg) - case None => hasError = !skip + case Some(arg) => + argbuf += name -> arg + + case None => + hasError = !skip } } if (hasError || skip) None