-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix publishing for 2.13.16 and 3.6.3 (#1603)
# 3.6.3 - `DottyParser.blockStatSeq` signature change from 3.6.2 to 3.6.3 See scala/scala3@3.6.2...3.6.3#diff-89e03cdd16b8e5fd6435d2df4b44a3e58c408a22adb7683c149015ab0d64f4bfR4717 <img width="816" alt="Screenshot 2025-01-27 at 1 41 27 PM" src="https://github.com/user-attachments/assets/d35ac655-9ece-48c0-a3bd-46ba3de02c1b" /> Thus the current `amm/compiler/src/main/scala-3/DottyParser.scala` is moved to `.../scala-3.0.0-3.6.2/DottyParser.scala`. A new `.../scala-3.6.3+/DottyParser.scala` was created with the new signature. `build.mill` was updated accordingly. # 2.13.16 - A change in upstream (scala/scala#10868) caused an error in autocompletion. Attempting to autocomplete `import java.|` would trigger the error. The workaround is to change the autocomplete code wrapper to ```scala object AutocompleteWrapper{ def main(args: Array[String])={ import java. () }} ``` (similar to Scala 3) instead of ```scala object AutocompleteWrapper{ import java.} ``` --------- Co-authored-by: Li Haoyi <[email protected]>
- Loading branch information
Showing
7 changed files
with
95 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
File renamed without changes.
70 changes: 70 additions & 0 deletions
70
amm/compiler/src/main/scala-3.6.3+/ammonite/compiler/DottyParser.scala
This file contains 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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package ammonite.compiler | ||
|
||
import dotty.tools.dotc | ||
import dotc.ast.untpd | ||
import dotc.core.Contexts.Context | ||
import dotc.core.Flags | ||
import dotc.core.StdNames.nme | ||
import dotc.parsing.Parsers.{Location, Parser} | ||
import dotc.parsing.Tokens | ||
import dotc.reporting.IllegalStartOfStatement | ||
import dotc.util.SourceFile | ||
|
||
import scala.collection.mutable | ||
|
||
class DottyParser(source: SourceFile)(using Context) extends Parser(source) with CompatibilityParser { | ||
|
||
// From | ||
// https://github.com/lampepfl/dotty/blob/3.0.0-M3/ | ||
// compiler/src/dotty/tools/dotc/parsing/Parsers.scala/#L67-L71 | ||
extension (buf: mutable.ListBuffer[untpd.Tree]) | ||
def +++=(x: untpd.Tree) = x match { | ||
case x: untpd.Thicket => buf ++= x.trees | ||
case x => buf += x | ||
} | ||
|
||
private val oursLocalModifierTokens = Tokens.localModifierTokens + Tokens.PRIVATE | ||
|
||
override def localDef( | ||
start: Int, | ||
implicitMods: untpd.Modifiers = untpd.EmptyModifiers | ||
): untpd.Tree = { | ||
var mods = defAnnotsMods(oursLocalModifierTokens) | ||
for (imod <- implicitMods.mods) mods = addMod(mods, imod) | ||
if (mods.is(Flags.Final)) | ||
// A final modifier means the local definition is "class-like". | ||
// FIXME: Deal with modifiers separately | ||
tmplDef(start, mods) | ||
else | ||
defOrDcl(start, mods) | ||
} | ||
|
||
// Adapted from | ||
// https://github.com/lampepfl/dotty/blob/3.2.0/ | ||
// compiler/src/dotty/tools/dotc/parsing/Parsers.scala#L4075-L4094 | ||
// Unlike it, we accept private modifiers for top-level definitions. | ||
override def blockStatSeq(outermost: Boolean = false): List[untpd.Tree] = checkNoEscapingPlaceholders { | ||
val stats = new mutable.ListBuffer[untpd.Tree] | ||
while | ||
var empty = false | ||
if (in.token == Tokens.IMPORT) | ||
stats ++= compatibilityImportClause() | ||
else if (isExprIntro) | ||
stats += expr(Location.InBlock) | ||
else if in.token == Tokens.IMPLICIT && !in.inModifierPosition() then | ||
stats += closure( | ||
in.offset, | ||
Location.InBlock, | ||
modifiers(scala.collection.immutable.BitSet(Tokens.IMPLICIT)) | ||
) | ||
else if isIdent(nme.extension) && followingIsExtension() then | ||
stats += extension() | ||
else if isDefIntro(oursLocalModifierTokens, excludedSoftModifiers = Set(nme.`opaque`)) then | ||
stats +++= localDef(in.offset) | ||
else | ||
empty = true | ||
statSepOrEnd(stats, noPrevStat = empty, altEnd = Tokens.CASE) | ||
do () | ||
stats.toList | ||
} | ||
} |
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -127,6 +127,10 @@ | |
|
||
|
||
@sect{Changelog} | ||
@sect{3.0.1} | ||
@ul | ||
@li | ||
Support for Scala 2.13.16, 3.3.4 | ||
@sect{3.0.0} | ||
@ul | ||
@li | ||
|
This file contains 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