- Notifications
You must be signed in to change notification settings - Fork3.1k
TASTy Reader: support Scala 3.4 [ci: last-only]#10670
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
19 commits Select commitHold shift + click to select a range
f0a484b prepare for syntax changes in Scala 3.4.0
bishaboshad3e7895 Upgrade tasty format, copy new tasty config
bishaboshaa565f9a enable pipelined compilation against Scala 3
bishabosha95900a6 support Java enum from TASTy
bishabosha9d37a96 support varargs and fields
bishaboshac09a900 support erasure of java arrays
bishaboshabd5b335 support Java fields
bishabosha0bd266c support java interfaces
bishabosha19ea949 support java annotations
bishaboshaabcb8ee add test for deprecation
bishabosha8cb3eff support inner class selection
bishabosha0cc7d73 workaround TASTy selection of inner class
bishaboshaa18de29 test parameterised types and bounds
bishaboshac00adb8 improved inner class selection
bishabosha6b2c4ae tweak symbolops error message
bishaboshae623261 deterministic loading of TASTy
bishaboshab0c8120 test annotations on types
bishaboshafa4c3df add filtering by jvm version in TastyTest
bishaboshabfed4df move isJava to Context
bishaboshaFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletionproject/DottySupport.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
16 changes: 11 additions & 5 deletionssrc/compiler/scala/tools/nsc/classpath/DirectoryClassPath.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletionssrc/compiler/scala/tools/nsc/classpath/FileUtils.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -24,7 +24,7 @@ object FileUtils { | ||
| implicit class AbstractFileOps(val file: AbstractFile) extends AnyVal { | ||
| def isPackage: Boolean = file.isDirectory && mayBeValidPackage(file.name) | ||
| def isClass: Boolean = !file.isDirectory && (file.hasExtension("class") || file.hasExtension("sig") || file.hasExtension("tasty")) | ||
bishabosha marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| def isScalaOrJavaSource: Boolean = !file.isDirectory && (file.hasExtension("scala") || file.hasExtension("java")) | ||
| @@ -46,6 +46,7 @@ object FileUtils { | ||
| private val SUFFIX_SCALA = ".scala" | ||
| private val SUFFIX_JAVA = ".java" | ||
| private val SUFFIX_SIG = ".sig" | ||
| private val SUFFIX_TASTY = ".tasty" | ||
| def stripSourceExtension(fileName: String): String = { | ||
| if (endsScala(fileName)) stripClassExtension(fileName) | ||
| @@ -58,7 +59,7 @@ object FileUtils { | ||
| @inline private def ends (filename:String, suffix:String) = filename.endsWith(suffix) && filename.length > suffix.length | ||
| def endsClass(fileName: String): Boolean = | ||
| ends (fileName, SUFFIX_CLASS) || fileName.endsWith(SUFFIX_SIG) || fileName.endsWith(SUFFIX_TASTY) | ||
| def endsScalaOrJava(fileName: String): Boolean = | ||
| endsScala(fileName) || endsJava(fileName) | ||
5 changes: 4 additions & 1 deletionsrc/compiler/scala/tools/nsc/classpath/VirtualDirectoryClassPath.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletionssrc/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletionssrc/compiler/scala/tools/nsc/classpath/ZipArchiveFileLookup.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
101 changes: 17 additions & 84 deletionssrc/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -15,22 +15,19 @@ package tools.nsc | ||
| package symtab | ||
| package classfile | ||
| import java.io.IOException | ||
| import java.lang.Integer.toHexString | ||
| import scala.annotation.switch | ||
| import scala.collection.{immutable, mutable}, mutable.{ArrayBuffer, ListBuffer} | ||
| import scala.reflect.internal.JavaAccFlags | ||
| import scala.reflect.internal.pickling.ByteCodecs | ||
| import scala.reflect.internal.util.ReusableInstance | ||
| import scala.reflect.io.NoAbstractFile | ||
| import scala.tools.nsc.Reporting.WarningCategory | ||
| import scala.tools.nsc.io.AbstractFile | ||
| import scala.tools.nsc.util.ClassPath | ||
| import scala.tools.nsc.tasty.{TastyUniverse, TastyUnpickler} | ||
| import scala.util.control.NonFatal | ||
| /** This abstract class implements a class file parser. | ||
| @@ -73,14 +70,12 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) { | ||
| protected var staticScope: Scope = _ // the scope of all static definitions | ||
| protected var pool: ConstantPool = _ // the classfile's constant pool | ||
| protected var isScala: Boolean = _ // does class file describe a scala class? | ||
bishabosha marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| protected var isScalaRaw: Boolean = _ // this class file is a scala class with no pickled info | ||
| protected var busy: Symbol = _ // lock to detect recursive reads | ||
| protected var currentClass: String = _ // JVM name of the current class | ||
| protected var classTParams = Map[Name,Symbol]() | ||
| protected var srcfile0 : Option[AbstractFile] = None | ||
| protected def moduleClass: Symbol = staticModule.moduleClass | ||
| private var YtastyReader = false | ||
| private def ownerForFlags(jflags: JavaAccFlags) = if (jflags.isStatic) moduleClass else clazz | ||
| @@ -163,11 +158,22 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) { | ||
| this.isScala = false | ||
| this.YtastyReader = settings.YtastyReader.value | ||
| valisJavaMagic = in.getInt(in.bp) == JAVA_MAGIC | ||
| if (!isJavaMagic && file.name.endsWith(".sig")) { | ||
| currentClass = clazz.javaClassName | ||
| isScala = true | ||
| unpickler.unpickle(in.buf.take(file.sizeOption.get), 0, clazz, staticModule, file.name) | ||
| } else if (!isJavaMagic && file.name.endsWith(".tasty")) { | ||
| if (!YtastyReader) | ||
| MissingRequirementError.signal(s"Add -Ytasty-reader to scalac options to parse the TASTy in $file") | ||
| // TODO [tasty]: it seems tests don't fail if we remove this, but previously this | ||
| // was added for the following reason: | ||
| // > Force scala.AnyRef, otherwise we get "error: Symbol AnyRef is missing from the classpath" | ||
| AnyRefClass | ||
| val bytes = in.buf.take(file.sizeOption.get) | ||
| TastyUnpickler.unpickle(TastyUniverse)(bytes, clazz, staticModule, file.path.stripSuffix(".class") + ".tasty") | ||
| } else { | ||
| parseHeader() | ||
| this.pool = new ConstantPool | ||
| @@ -501,7 +507,7 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) { | ||
| if (!c.isInstanceOf[StubSymbol] && c != clazz) mismatchError(c) | ||
| } | ||
| if (isScala) { | ||
| () // We're done | ||
| } else if (isScalaRaw) { | ||
| val decls = clazz.enclosingPackage.info.decls | ||
| @@ -1095,8 +1101,6 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) { | ||
| var innersStart = -1 | ||
| var runtimeAnnotStart = -1 | ||
| val numAttrs = u2() | ||
| var i = 0 | ||
| @@ -1110,13 +1114,8 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) { | ||
| case tpnme.ScalaATTR => | ||
| isScalaRaw = true | ||
| i = numAttrs | ||
| case tpnme.TASTYATTR => | ||
| MissingRequirementError.notFound(s"TASTy file for associated class file $file") | ||
| case tpnme.InnerClassesATTR => | ||
| innersStart = in.bp | ||
| case tpnme.RuntimeAnnotationATTR => | ||
| @@ -1128,13 +1127,6 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) { | ||
| i += 1 | ||
| } | ||
| if (isScala) { | ||
| def parseScalaSigBytes(): Array[Byte] = { | ||
| val tag = u1() | ||
| @@ -1212,65 +1204,6 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) { | ||
| AnyRefClass // Force scala.AnyRef, otherwise we get "error: Symbol AnyRef is missing from the classpath" | ||
| assert(bytes != null, s"No Scala(Long)Signature annotation in classfile with ScalaSignature attribute: $clazz") | ||
| unpickler.unpickle(bytes, 0, clazz, staticModule, file.name) | ||
| } else if (!isScalaRaw && innersStart != -1) { | ||
| in.bp = innersStart | ||
| val entries = u2() | ||
3 changes: 3 additions & 0 deletionssrc/compiler/scala/tools/nsc/tasty/TastyModes.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.