Skip to content

Commit adf1152

Browse files
committed
update to scala 3.5.0-RC3
1 parent d4d685b commit adf1152

File tree

15 files changed

+215
-104
lines changed

15 files changed

+215
-104
lines changed

project/DottySupport.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import sbt.librarymanagement.{
1212
* Settings to support validation of TastyUnpickler against the release of dotty with the matching TASTy version
1313
*/
1414
object TastySupport {
15-
val supportedTASTyRelease = "3.4.2" // TASTY: 28.4-0
15+
val supportedTASTyRelease = "3.5.0-RC4" // TASTY: 28.5-1
1616
val scala3Compiler = "org.scala-lang" % "scala3-compiler_3" % supportedTASTyRelease
1717
val scala3Library = "org.scala-lang" % "scala3-library_3" % supportedTASTyRelease
1818

@@ -26,7 +26,7 @@ object TastySupport {
2626
* Dotty in .travis.yml.
2727
*/
2828
object DottySupport {
29-
val dottyVersion = TastySupport.supportedTASTyRelease
29+
val dottyVersion = "3.4.2" // TastySupport.supportedTASTyRelease // TODO: use same as tasty version when sources are fixed
3030
val compileWithDotty: Boolean =
3131
Option(System.getProperty("scala.build.compileWithDotty")).exists(_.toBoolean)
3232
lazy val commonSettings = Seq(

src/compiler/scala/tools/nsc/tasty/TastyUnpickler.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ object TastyUnpickler {
7171
/** When Scala 3 is in an RC phase for a new minor version, we put here the TASTy of that Minor,
7272
* otherwise it should be empty.
7373
*/
74-
final val toolOverrides: List[TastyVersion] = Nil
74+
final val toolOverrides: List[TastyVersion] = List(
75+
TastyVersion(28, 5, 1) // 3.5.0-RC4 // TODO: remove this when 3.5.0 is released
76+
)
7577

7678
private def asScala3Compiler(version: TastyVersion): String =
7779
if (version.major == 28) {

src/compiler/scala/tools/nsc/tasty/TreeUnpickler.scala

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ class TreeUnpickler[Tasty <: TastyUniverse](
409409
case METHODtype => readMethodic(MethodTermLambda, FlagSets.parseMethod, id)
410410
case TYPELAMBDAtype => readMethodic(HKTypeLambda, FlagSets.addDeferred, _.toTypeName)
411411
case PARAMtype => defn.ParamRef(readTypeRef(), readNat()) // reference to a parameter within a LambdaType
412+
case FLEXIBLEtype =>
413+
// dotty would wrap the inner type in FlexibleType (with lower bound >: tpe | Null),
414+
// but we can leave as-is - as Scala 2 does not have explicit nulls.
415+
readType()
412416
}
413417
assert(currentAddr === end, s"$start $currentAddr $end ${astTagToString(tag)}")
414418
result
@@ -694,6 +698,7 @@ class TreeUnpickler[Tasty <: TastyUniverse](
694698
case EXPORTED => addFlag(Exported)
695699
case OPEN => addFlag(Open)
696700
case INVISIBLE => addFlag(Invisible)
701+
case TRACKED => addFlag(Tracked)
697702
case PRIVATEqualified =>
698703
readByte()
699704
privateWithin = readWithin(ctx)
@@ -882,7 +887,7 @@ class TreeUnpickler[Tasty <: TastyUniverse](
882887
def TypeDef(repr: TastyRepr, localCtx: Context)(implicit ctx: Context): Unit = {
883888
val allowedShared = Enum | Opaque | Infix | Given
884889
val allowedTypeFlags = allowedShared | Exported
885-
val allowedClassFlags = allowedShared | Open | Transparent
890+
val allowedClassFlags = allowedShared | Open | Transparent | Tracked
886891
if (sym.isClass) {
887892
checkUnsupportedFlags(repr.unsupportedFlags &~ allowedClassFlags)
888893
sym.owner.ensureCompleted(CompleteOwner)
@@ -905,7 +910,7 @@ class TreeUnpickler[Tasty <: TastyUniverse](
905910
}
906911

907912
def TermParam(repr: TastyRepr, localCtx: Context)(implicit ctx: Context): Unit = {
908-
checkUnsupportedFlags(repr.unsupportedFlags &~ (ParamAlias | Exported | Given))
913+
checkUnsupportedFlags(repr.unsupportedFlags &~ (ParamAlias | Exported | Given | Tracked))
909914
val tpt = readTpt()(localCtx)
910915
ctx.setInfo(sym,
911916
if (nothingButMods(end) && sym.not(ParamSetter)) tpt.tpe
@@ -1220,19 +1225,23 @@ class TreeUnpickler[Tasty <: TastyUniverse](
12201225
exprReader.readTerm()
12211226
}
12221227
else unsupportedTermTreeError("block expression")
1223-
case ASSIGN => unsupportedTermTreeError("assignment expression")
1224-
case LAMBDA => unsupportedTermTreeError("anonymous function literal")
1225-
case MATCH => unsupportedTermTreeError("match expression")
1226-
case RETURN => unsupportedTermTreeError("return statement")
1227-
case WHILE => unsupportedTermTreeError("loop statement")
1228-
case TRY => unsupportedTermTreeError("try expression")
1229-
case BIND => unsupportedTermTreeError("bind pattern")
1230-
case ALTERNATIVE => unsupportedTermTreeError("pattern alternative")
1231-
case UNAPPLY => unsupportedTermTreeError("unapply pattern")
1232-
case INLINED => unsupportedTermTreeError("inlined expression")
1233-
case SELECTouter => metaprogrammingIsUnsupported // only within inline
1234-
case HOLE => abortMacroHole
1235-
case _ => readPathTerm()
1228+
case ASSIGN => unsupportedTermTreeError("assignment expression")
1229+
case LAMBDA => unsupportedTermTreeError("anonymous function literal")
1230+
case MATCH => unsupportedTermTreeError("match expression")
1231+
case RETURN => unsupportedTermTreeError("return statement")
1232+
case WHILE => unsupportedTermTreeError("loop statement")
1233+
case TRY => unsupportedTermTreeError("try expression")
1234+
case BIND => unsupportedTermTreeError("bind pattern")
1235+
case ALTERNATIVE => unsupportedTermTreeError("pattern alternative")
1236+
case UNAPPLY => unsupportedTermTreeError("unapply pattern")
1237+
case INLINED => unsupportedTermTreeError("inlined expression")
1238+
case SELECTouter => metaprogrammingIsUnsupported // only within inline
1239+
case QUOTE => abortQuote
1240+
case SPLICE => abortSplice
1241+
case QUOTEPATTERN => abortQuotePattern
1242+
case SPLICEPATTERN => abortSplicePattern
1243+
case HOLE => abortMacroHole
1244+
case _ => readPathTerm()
12361245
}
12371246
assert(currentAddr === end, s"$start $currentAddr $end ${astTagToString(tag)}")
12381247
result
@@ -1265,6 +1274,10 @@ class TreeUnpickler[Tasty <: TastyUniverse](
12651274
* A HOLE should never appear in TASTy for a top level class, only in quotes.
12661275
*/
12671276
private def abortMacroHole[T]: T = abortWith(msg = "Scala 3 macro hole in pickled TASTy")
1277+
private def abortQuote[T]: T = abortWith(msg = "Scala 3 quoted expression in pickled TASTy")
1278+
private def abortSplice[T]: T = abortWith(msg = "Scala 3 quoted splice in pickled TASTy")
1279+
private def abortQuotePattern[T]: T = abortWith(msg = "Scala 3 quoted pattern in pickled TASTy")
1280+
private def abortSplicePattern[T]: T = abortWith(msg = "Scala 3 quoted pattern splice in pickled TASTy")
12681281

12691282
private def signaturePolymorphicIsUnsupported[T](implicit ctx: Context): T =
12701283
unsupportedTermTreeError("signature polymorphic application")

src/compiler/scala/tools/nsc/tasty/bridge/FlagOps.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ trait FlagOps { self: TastyUniverse =>
2626

2727
val TastyOnlyFlags: TastyFlagSet = (
2828
Erased | Inline | InlineProxy | Opaque | Extension | Given | Exported | Transparent
29-
| Enum | Infix | Open | ParamAlias | Invisible
29+
| Enum | Infix | Open | ParamAlias | Invisible | Tracked
3030
)
3131

3232
type FlagParser = TastyFlagSet => Context => TastyFlagSet
@@ -139,6 +139,7 @@ trait FlagOps { self: TastyUniverse =>
139139
if (flags.is(ParamAlias)) sb += "<paramalias>"
140140
if (flags.is(Infix)) sb += "infix"
141141
if (flags.is(Invisible)) sb += "<invisible>"
142+
if (flags.is(Tracked)) sb += "<tracked>"
142143
sb.mkString(" | ")
143144
}
144145
}

src/compiler/scala/tools/tasty/TastyFlags.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ object TastyFlags {
6060
final val ParamAlias = Open.next
6161
final val Infix = ParamAlias.next
6262
final val Invisible = Infix.next
63+
final val Tracked = Invisible.next
6364

6465
def optFlag(cond: Boolean)(flag: TastyFlagSet): TastyFlagSet = if (cond) flag else EmptyTastyFlags
6566

@@ -125,6 +126,7 @@ object TastyFlags {
125126
if (is(ParamAlias)) sb += "ParamAlias"
126127
if (is(Infix)) sb += "Infix"
127128
if (is(Invisible)) sb += "Invisible"
129+
if (is(Tracked)) sb += "Tracked"
128130
sb.mkString(" | ")
129131
}
130132
}

src/compiler/scala/tools/tasty/TastyFormat.scala

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
package scala.tools.tasty
1414

15-
// revision: https://github.com/scala/scala3/commit/0938fe5603a17c7c786ac8fc6118a9d5d8b257de
15+
// revision: https://github.com/scala/scala3/commit/5189e6854ad1dacc3454542c2f124f5bcb7e2a9c
1616
object TastyFormat {
1717

1818
/** The first four bytes of a TASTy file, followed by four values:
@@ -34,9 +34,9 @@ object TastyFormat {
3434
/** Natural number. Each increment of the `MinorVersion`, within
3535
* a series declared by the `MajorVersion`, breaks forward
3636
* compatibility, but remains backwards compatible, with all
37-
* preceeding `MinorVersion`.
37+
* preceding `MinorVersion`.
3838
*/
39-
final val MinorVersion: Int = 4
39+
final val MinorVersion: Int = 5
4040

4141
/** Natural Number. The `ExperimentalVersion` allows for
4242
* experimentation with changes to TASTy without committing
@@ -222,6 +222,7 @@ object TastyFormat {
222222
final val INVISIBLE = 44
223223
final val EMPTYCLAUSE = 45
224224
final val SPLITCLAUSE = 46
225+
final val TRACKED = 47
225226

226227
// Tree Cat. 2: tag Nat
227228
final val firstNatTreeTag = SHAREDterm
@@ -261,7 +262,6 @@ object TastyFormat {
261262
final val EXPLICITtpt = 103
262263
final val ELIDED = 104
263264

264-
265265
// Tree Cat. 4: tag Nat AST
266266
final val firstNatASTTreeTag = IDENT
267267
final val IDENT = 110
@@ -327,14 +327,17 @@ object TastyFormat {
327327
final val TYPEREFin = 175
328328
final val SELECTin = 176
329329
final val EXPORT = 177
330-
// final val ??? = 178
331-
// final val ??? = 179
330+
final val QUOTE = 178
331+
final val SPLICE = 179
332332
final val METHODtype = 180
333333
final val APPLYsigpoly = 181
334+
final val QUOTEPATTERN = 182
335+
final val SPLICEPATTERN = 183
334336

335337
final val MATCHtype = 190
336338
final val MATCHtpt = 191
337339
final val MATCHCASEtype = 192
340+
final val FLEXIBLEtype = 193
338341

339342
final val HOLE = 255
340343

@@ -366,7 +369,7 @@ object TastyFormat {
366369
firstNatTreeTag <= tag && tag <= RENAMED ||
367370
firstASTTreeTag <= tag && tag <= BOUNDED ||
368371
firstNatASTTreeTag <= tag && tag <= NAMEDARG ||
369-
firstLengthTreeTag <= tag && tag <= MATCHCASEtype ||
372+
firstLengthTreeTag <= tag && tag <= FLEXIBLEtype ||
370373
tag == HOLE
371374

372375
def isParamTag(tag: Int): Boolean = tag == PARAM || tag == TYPEPARAM
@@ -411,7 +414,8 @@ object TastyFormat {
411414
| INVISIBLE
412415
| ANNOTATION
413416
| PRIVATEqualified
414-
| PROTECTEDqualified => true
417+
| PROTECTEDqualified
418+
| TRACKED => true
415419
case _ => false
416420
}
417421

@@ -568,11 +572,16 @@ object TastyFormat {
568572
case MATCHCASEtype => "MATCHCASEtype"
569573
case MATCHtpt => "MATCHtpt"
570574
case PARAMtype => "PARAMtype"
575+
case FLEXIBLEtype => "FLEXIBLEtype"
571576
case ANNOTATION => "ANNOTATION"
572577
case PRIVATEqualified => "PRIVATEqualified"
573578
case PROTECTEDqualified => "PROTECTEDqualified"
574579
case EXPLICITtpt => "EXPLICITtpt"
575580
case ELIDED => "ELIDED"
581+
case QUOTE => "QUOTE"
582+
case SPLICE => "SPLICE"
583+
case QUOTEPATTERN => "QUOTEPATTERN"
584+
case SPLICEPATTERN => "SPLICEPATTERN"
576585
case HOLE => "HOLE"
577586
}
578587

src/tastytest/scala/tools/tastytest/Dotc.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ object Dotc extends Script.Command {
8181

8282
private def makeConsoleReporter(stream: OutputStream)(implicit cl: Dotc.ClassLoader): Try[AnyRef] = Try {
8383
val consoleReporterCls = loadClass("dotty.tools.dotc.reporting.ConsoleReporter")
84-
val ctor = consoleReporterCls.getConstructor(classOf[BufferedReader], classOf[PrintWriter])
84+
val ctor = consoleReporterCls.getConstructor(
85+
/* reader: BufferedReader */classOf[BufferedReader],
86+
/* writer: PrintWriter */classOf[PrintWriter],
87+
/* echoer: PrintWriter */classOf[PrintWriter] // since 3.5.0-RC2
88+
)
8589
val pwriter = new PrintWriter(stream, true)
8690
inClassloader[AnyRef] {
87-
ctor.newInstance(Console.in, pwriter)
91+
ctor.newInstance(/* reader = */Console.in, /* writer = */pwriter, /* echoer= */pwriter)
8892
}
8993
}
9094

src/tastytest/scala/tools/tastytest/TastyTest.scala

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ object TastyTest {
268268
private def negTestImpl(compile: String => (String, Try[Boolean]))(files: String*): Try[Unit] = {
269269
val errors = mutable.ArrayBuffer.empty[String]
270270
val unexpectedFail = mutable.ArrayBuffer.empty[String]
271+
val crashes = mutable.ArrayBuffer.empty[String]
271272
val failMap: Map[String, (Option[String], Option[String])] = {
272273
val (sources, rest) = files.partition(ScalaFail.permits)
273274
sources.map({ s =>
@@ -297,51 +298,61 @@ object TastyTest {
297298
}
298299
compile(source)
299300
}
300-
if (compiled.getOrElse(false)) {
301-
if (failMap.contains(source)) {
302-
errors += source
303-
printerrln(s"ERROR: $source successfully compiled.")
304-
}
305-
}
306-
else {
307-
failMap.get(source) match {
308-
case None =>
309-
unexpectedFail += source
310-
System.err.println(output)
311-
printerrln(s"ERROR: $source did not compile when expected to. Perhaps it should match (**/*${ScalaFail.name})")
312-
case Some((Some(checkFile), _)) if Check.permits(checkFile) =>
313-
processLines(checkFile) { stream =>
314-
val checkLines = Diff.splitIntoLines(stream)
315-
val outputLines = Diff.splitIntoLines(output)
316-
val diff = Diff.compareContents(outputLines, checkLines)
317-
if (diff.nonEmpty) {
301+
compiled match {
302+
case Failure(exception) =>
303+
crashes += source
304+
printerrln(s"ERROR: fatal error running compiler for $source: $exception")
305+
case Success(true) =>
306+
if (failMap.contains(source)) {
307+
errors += source
308+
printerrln(s"ERROR: $source successfully compiled when expected to fail.")
309+
}
310+
case Success(false) =>
311+
failMap.get(source) match {
312+
case None =>
313+
unexpectedFail += source
314+
System.err.println(output)
315+
printerrln(s"ERROR: $source did not compile when expected to. Perhaps it should match (**/*${ScalaFail.name})")
316+
case Some((Some(checkFile), _)) if Check.permits(checkFile) =>
317+
processLines(checkFile) { stream =>
318+
val checkLines = Diff.splitIntoLines(stream)
319+
val outputLines = Diff.splitIntoLines(output)
320+
assert(outputLines.filterNot(_.isEmpty()).nonEmpty, s"outputLines should not be empty: $outputLines")
321+
val diff = Diff.compareContents(outputLines, checkLines)
322+
if (diff.nonEmpty) {
323+
errors += source
324+
printerrln(s"ERROR: $source failed, unexpected output.\n$diff")
325+
}
326+
}
327+
case Some((Some(skipCheckFile), _)) =>
328+
printwarnln(s"warning: skipping check on ${skipCheckFile.stripSuffix(SkipCheck.name)}")
329+
case Some((None, _)) =>
330+
if (output.nonEmpty) {
318331
errors += source
319-
printerrln(s"ERROR: $source failed, unexpected output.\n$diff")
332+
val diff = Diff.compareContents(output, "")
333+
printerrln(s"ERROR: $source failed, no check file found for unexpected output.\n$diff")
320334
}
321-
}
322-
case Some((Some(skipCheckFile), _)) =>
323-
printwarnln(s"warning: skipping check on ${skipCheckFile.stripSuffix(SkipCheck.name)}")
324-
case Some((None, _)) =>
325-
if (output.nonEmpty) {
326-
errors += source
327-
val diff = Diff.compareContents(output, "")
328-
printerrln(s"ERROR: $source failed, no check file found for unexpected output.\n$diff")
329-
}
330-
}
335+
}
331336
}
332337
}
333338

334339
val sources = files.filter(Scala.permits).filterNot(ScalaPre.permits)
335340
sources.foreach(negCompile)
336-
successWhen(errors.isEmpty && unexpectedFail.isEmpty) {
337-
if (unexpectedFail.nonEmpty) {
341+
successWhen(errors.isEmpty && unexpectedFail.isEmpty && crashes.isEmpty) {
342+
var msgs = List.empty[String]
343+
if (crashes.nonEmpty) {
344+
val str = if (crashes.size == 1) "file" else "files"
345+
msgs ::= s"${crashes.length} $str fatally crashed the compiler: ${crashes.mkString(", ")}."
346+
}
347+
else if (unexpectedFail.nonEmpty) {
338348
val str = if (unexpectedFail.size == 1) "file" else "files"
339-
s"${unexpectedFail.length} $str did not compile when expected to: ${unexpectedFail.mkString(", ")}."
349+
msgs ::= s"${unexpectedFail.length} $str did not compile when expected to: ${unexpectedFail.mkString(", ")}."
340350
}
341-
else {
351+
else if (errors.nonEmpty) {
342352
val str = if (errors.size == 1) "error" else "errors"
343-
s"${errors.length} $str. These sources either compiled or had an incorrect or missing check file: ${errors.mkString(", ")}."
353+
msgs ::= s"Found ${errors.length} $str. These sources either compiled or had an incorrect or missing check file: ${errors.mkString(", ")}."
344354
}
355+
msgs.mkString(System.lineSeparator())
345356
}
346357
}
347358

@@ -354,7 +365,7 @@ object TastyTest {
354365
}
355366

356367
private def pipelineDottyOpts(tastyJar: String): Seq[String] =
357-
Seq("-Yjava-tasty", "-Yjava-tasty-output", tastyJar)
368+
Seq("-Xjava-tasty", "-Xearly-tasty-output", tastyJar)
358369

359370
private def dotcNeg(out: String, additionalSettings: Seq[String], files: String*)(implicit cl: Dotc.ClassLoader): Try[Unit] = {
360371
def compile(source: String, writer: OutputStream) = {

0 commit comments

Comments
 (0)