Skip to content

Fix issue #8124 #8273

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

Closed
wants to merge 11 commits into from
Closed
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 @@ -31,7 +31,7 @@ def exec(projectDir: Path, binary: String, arguments: String*): Int =
exitCode


sealed trait CommunityProject:
sealed trait CommunityProject
private var published = false

val project: String
Expand Down Expand Up @@ -77,23 +77,17 @@ sealed trait CommunityProject:
published = true
end CommunityProject

final case class MillCommunityProject(
project: String,
baseCommand: String,
dependencies: List[CommunityProject] = Nil) extends CommunityProject:
final case class MillCommunityProject(project: String, baseCommand: String,
dependencies: List[CommunityProject] = Nil) extends CommunityProject
override val binaryName: String = "./mill"
override val updateCommand = s"$baseCommand.compileClasspath"
override val testCommand = s"$baseCommand.test"
override val publishCommand = s"$baseCommand.publishLocal"
override val runCommandsArgs = List("-i", "-D", s"dottyVersion=$compilerVersion")

final case class SbtCommunityProject(
project: String,
sbtTestCommand: String,
sbtUpdateCommand: String,
extraSbtArgs: List[String] = Nil,
dependencies: List[CommunityProject] = Nil,
sbtPublishCommand: String = null) extends CommunityProject:
final case class SbtCommunityProject(project: String, sbtTestCommand: String,
sbtUpdateCommand: String, extraSbtArgs: List[String] = Nil,
dependencies: List[CommunityProject] = Nil, sbtPublishCommand: String = null) extends CommunityProject
override val binaryName: String = "sbt"
private val baseCommand = s";clean ;set updateOptions in Global ~= (_.withLatestSnapshots(false)) ;++$compilerVersion! "
override val testCommand = s"$baseCommand$sbtTestCommand"
Expand All @@ -109,7 +103,7 @@ final case class SbtCommunityProject(
"-sbt-version", "1.3.6",
s"--addPluginSbtFile=$sbtPluginFilePath")

object projects:
object projects
lazy val utest = MillCommunityProject(
project = "utest",
baseCommand = s"utest.jvm[$compilerVersion]",
Expand Down Expand Up @@ -271,7 +265,7 @@ object projects:
end projects

@Category(Array(classOf[TestCategory]))
class CommunityBuildTest:
class CommunityBuildTest {
given CommunityBuildTest = this

/** Build the given project with the published local compiler and sbt plugin.
Expand Down Expand Up @@ -341,7 +335,7 @@ class CommunityBuildTest:
@Test def xmlInterpolator = projects.xmlInterpolator.run()
@Test def effpi = projects.effpi.run()
@Test def sconfig = projects.sconfig.run()
end CommunityBuildTest
}

class TestCategory
class UpdateCategory
Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/config/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ object Config {
/** Assume -indent by default */
final val defaultIndent = true

/** Assume indentation is significant after a class, object, ... signature */
final val silentTemplateIndent = true

/** If set, prints a trace of all symbol completions */
final val showCompletions = false

Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ object Settings {
update(output, args)
}
case (StringTag, arg2 :: args2) =>
update(arg2, args2)
if (arg2 startsWith "-") missingArg
else update(arg2, args2)
case (IntTag, arg2 :: args2) =>
try {
val x = arg2.toInt
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Decorators._
import scala.internal.Chars
import scala.annotation.{tailrec, switch}
import rewrites.Rewrites.{patch, overlapsPatch}
import config.Config.silentTemplateIndent

object Parsers {

Expand Down Expand Up @@ -1318,6 +1319,7 @@ object Parsers {
if in.token != LBRACE && in.token != INDENT then
syntaxError(i"indented definitions or `{` expected")
else
if silentTemplateIndent && !isNew then in.observeIndented()
newLineOptWhenFollowedBy(LBRACE)

def endMarkerScope[T](pid: Tree)(op: => T): T = pid match {
Expand Down
21 changes: 4 additions & 17 deletions compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,6 @@ object Scanners {
case _ => false
}

/** Are we in a `${ }` block? such that RBRACE exits back into multiline string. */
private def inMultiLineInterpolatedExpression =
currentRegion match {
case InBraces(_, InString(true, _)) => true
case _ => false
}

/** read next token and return last offset
*/
def skipToken(): Offset = {
Expand Down Expand Up @@ -749,22 +742,17 @@ object Scanners {
if (token == INTERPOLATIONID) {
nextRawChar()
if (ch == '\"') {
if (lookaheadChar() == '\"') {
nextRawChar()
//offset += 3 // first part is positioned at the quote
nextRawChar()
if (ch == '\"') {
nextRawChar()
stringPart(multiLine = true)
}
else {
nextChar()
token = STRINGLIT
strVal = ""
}
}
else {
//offset += 1 // first part is positioned at the quote
stringPart(multiLine = false)
}
else stringPart(multiLine = false)
}
else {
nextChar()
Expand Down Expand Up @@ -818,8 +806,7 @@ object Scanners {
case ')' =>
nextChar(); token = RPAREN
case '}' =>
if (inMultiLineInterpolatedExpression) nextRawChar() else nextChar()
token = RBRACE
nextChar(); token = RBRACE
case '[' =>
nextChar(); token = LBRACKET
case ']' =>
Expand Down
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
}

private def paramsText[T>: Untyped](params: List[ValDef[T]]) =
"(" ~ keywordText("using ").provided(params.nonEmpty && params.head.mods.is(Given))
~ keywordText("erased ").provided(params.nonEmpty && params.head.mods.is(Erased))
~ toText(params, ", ") ~ ")"
keywordText(" with ").provided(params.nonEmpty && params.head.mods.is(Given))
~ "(" ~ toText(params, ", ") ~ ")"

protected def defDefToText[T >: Untyped](tree: DefDef[T]): Text = {
import untpd.{modsDeco => _}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ object Inliner {

object Intrinsics {
import dotty.tools.dotc.reporting.diagnostic.messages.Error
private enum ErrorKind:
private enum ErrorKind
case Parser, Typer

private def compileForErrors(tree: Tree, stopAfterParser: Boolean)(using ctx: Context): List[(ErrorKind, Error)] =
Expand Down
22 changes: 11 additions & 11 deletions compiler/src/dotty/tools/dotc/typer/Nullables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import config.Printers.nullables
import ast.{tpd, untpd}

/** Operations for implementing a flow analysis for nullability */
object Nullables:
object Nullables with
import ast.tpd._

/** A set of val or var references that are known to be not null, plus a set of
* variable references that are not known (anymore) to be not null
*/
case class NotNullInfo(asserted: Set[TermRef], retracted: Set[TermRef]):
case class NotNullInfo(asserted: Set[TermRef], retracted: Set[TermRef])
assert((asserted & retracted).isEmpty)

def isEmpty = this eq NotNullInfo.empty
Expand All @@ -43,18 +43,18 @@ object Nullables:
def alt(that: NotNullInfo): NotNullInfo =
NotNullInfo(this.asserted.intersect(that.asserted), this.retracted.union(that.retracted))

object NotNullInfo:
object NotNullInfo with
val empty = new NotNullInfo(Set(), Set())
def apply(asserted: Set[TermRef], retracted: Set[TermRef]): NotNullInfo =
if asserted.isEmpty && retracted.isEmpty then empty
else new NotNullInfo(asserted, retracted)
end NotNullInfo

/** A pair of not-null sets, depending on whether a condition is `true` or `false` */
case class NotNullConditional(ifTrue: Set[TermRef], ifFalse: Set[TermRef]):
case class NotNullConditional(ifTrue: Set[TermRef], ifFalse: Set[TermRef]) with
def isEmpty = this eq NotNullConditional.empty

object NotNullConditional:
object NotNullConditional with
val empty = new NotNullConditional(Set(), Set())
def apply(ifTrue: Set[TermRef], ifFalse: Set[TermRef]): NotNullConditional =
if ifTrue.isEmpty && ifFalse.isEmpty then empty
Expand All @@ -72,7 +72,7 @@ object Nullables:
private[typer] val NNInfo = Property.StickyKey[NotNullInfo]

/** An extractor for null comparisons */
object CompareNull:
object CompareNull with

/** Matches one of
*
Expand All @@ -97,7 +97,7 @@ object Nullables:
end CompareNull

/** An extractor for null-trackable references */
object TrackedRef:
object TrackedRef
def unapply(tree: Tree)(using Context): Option[TermRef] = tree.typeOpt match
case ref: TermRef if isTracked(ref) => Some(ref)
case _ => None
Expand Down Expand Up @@ -160,7 +160,7 @@ object Nullables:
// TODO: Add constant pattern if the constant type is not nullable
case _ => false

extension notNullInfoOps on (infos: List[NotNullInfo]):
extension notNullInfoOps on (infos: List[NotNullInfo]) with

/** Do the current not-null infos imply that `ref` is not null?
* Not-null infos are as a history where earlier assertions and retractions replace
Expand Down Expand Up @@ -191,7 +191,7 @@ object Nullables:
infos.extendWith(NotNullInfo(Set(), mutables))
// end notNullInfoOps

extension refOps on (ref: TermRef):
extension refOps on (ref: TermRef) with

/** Is the use of a mutable variable out of order
*
Expand Down Expand Up @@ -245,7 +245,7 @@ object Nullables:
&& refOwner.isTerm
&& recur(curCtx.owner)

extension treeOps on (tree: Tree):
extension treeOps on (tree: Tree) with

/* The `tree` with added nullability attachment */
def withNotNullInfo(info: NotNullInfo): tree.type =
Expand Down Expand Up @@ -335,7 +335,7 @@ object Nullables:
tree.computeNullable()
}.traverse(tree)

extension assignOps on (tree: Assign):
extension assignOps on (tree: Assign) with
def computeAssignNullable()(using Context): tree.type = tree.lhs match
case TrackedRef(ref) =>
val rhstp = tree.rhs.typeOpt
Expand Down
10 changes: 10 additions & 0 deletions compiler/test/dotty/tools/dotc/SettingsTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,14 @@ class SettingsTests {
assertEquals(0, reporter.errorCount)
assertTrue(Files.exists(out))
}

@Test def t8124: Unit = {
val source = Paths.get("tests/pos/Foo.scala").normalize
val outputDir = Paths.get("out/testSettings").normalize
if (Files.notExists(outputDir)) Files.createDirectory(outputDir)
val options = Array("-encoding", "-d", outputDir.toString, source.toString)
val reporter = Main.process(options)
assertEquals(1, reporter.errorCount)
}

}
73 changes: 0 additions & 73 deletions compiler/test/dotty/tools/dotc/parsing/ParserEdgeTest.scala

This file was deleted.

9 changes: 3 additions & 6 deletions compiler/test/dotty/tools/dotc/parsing/ParserTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ class ParserTest extends DottyTest {
parsedTrees.clear()
}

def parse(file: PlainFile): Tree = parseSource(new SourceFile(file, Codec.UTF8))

private def parseSource(source: SourceFile): Tree = {
//println("***** parsing " + source.file)
def parse(file: PlainFile): Tree = {
//println("***** parsing " + file)
val source = new SourceFile(file, Codec.UTF8)
val parser = new Parser(source)
val tree = parser.parse()
parsed += 1
Expand All @@ -42,6 +41,4 @@ class ParserTest extends DottyTest {
for (d <- dir.dirs)
parseDir(d.path)
}

def parseText(code: String): Tree = parseSource(SourceFile.virtual("<code>", code))
}
18 changes: 18 additions & 0 deletions doc-tool/test/dotty/tools/dottydoc/SettingsTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dotty.tools
package dottydoc

import org.junit.Test
import org.junit.Assert._

class SettingsTests {

@Test def t8124: Unit = {
val source = "tests/pos/Foo.scala"
val url = "https://github.com/lampepfl/dotty/tree/master/tests"
val options = Array("-project", "-project-url", url, source)
val reporter = Main.process(options)
assertEquals(2, reporter.errorCount)
assertEquals("missing argument for option -project", reporter.allErrors.last.message)
}

}
Loading