Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
Fixes in files that were not saved before
  • Loading branch information
odersky committed Mar 25, 2020
1 parent a088941 commit d0679b0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ trait Symbols { this: Context =>
*/
def newSkolem(tp: Type): TermSymbol = newSymbol(defn.RootClass, nme.SKOLEM, SyntheticArtifact | NonMember | Permanent, tp)

def newErrorSymbol(owner: Symbol, name: Name, msg: => Message): Symbol = {
def newErrorSymbol(owner: Symbol, name: Name, msg: Message): Symbol = {
val errType = ErrorType(msg)
newSymbol(owner, name, SyntheticArtifact,
if (name.isTypeName) TypeAlias(errType) else errType)
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeErrors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Contexts._
import SymDenotations._
import Denotations._
import Decorators._
import reporting.diagnostic.Message
import reporting.diagnostic.{Message, NoExplanation}
import reporting.diagnostic.messages._
import ast.untpd
import config.Printers.cyclicErrors
Expand Down Expand Up @@ -69,7 +69,7 @@ class RecursionOverflow(val op: String, details: => String, val previous: Throwa
(rs.map(_.explanation): List[String]).mkString("\n ", "\n| ", "")
}

override def produceMessage(implicit ctx: Context): Message = {
override def produceMessage(implicit ctx: Context): Message = NoExplanation {
val mostCommon = recursions.groupBy(_.op).toList.maxBy(_._2.map(_.weight).sum)._2.reverse
s"""Recursion limit exceeded.
|Maybe there is an illegal cyclic reference?
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
def dynamicsEnabled: Boolean =
featureEnabled(nme.dynamics)

def testScala2CompatMode(msg: => Message, pos: SourcePosition, replace: => Unit = ()): Boolean = {
def testScala2CompatMode(msg: Message, pos: SourcePosition, replace: => Unit = ()): Boolean = {
if (scala2CompatMode) {
migrationWarning(msg, pos)
replace
Expand Down
14 changes: 7 additions & 7 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ object Parsers {
/** Issue an error at given offset if beyond last error offset
* and update lastErrorOffset.
*/
def syntaxError(msg: => Message, offset: Int = in.offset): Unit =
def syntaxError(msg: Message, offset: Int = in.offset): Unit =
if (offset > lastErrorOffset) {
val length = if (offset == in.offset && in.name != null) in.name.show.length else 0
syntaxError(msg, Span(offset, offset + length))
Expand All @@ -141,7 +141,7 @@ object Parsers {
/** Unconditionally issue an error at given span, without
* updating lastErrorOffset.
*/
def syntaxError(msg: => Message, span: Span): Unit =
def syntaxError(msg: Message, span: Span): Unit =
ctx.error(msg, source.atSpan(span))

def unimplementedExpr(implicit ctx: Context): Select =
Expand Down Expand Up @@ -308,23 +308,23 @@ object Parsers {
}
}

def warning(msg: => Message, sourcePos: SourcePosition): Unit =
def warning(msg: Message, sourcePos: SourcePosition): Unit =
ctx.warning(msg, sourcePos)

def warning(msg: => Message, offset: Int = in.offset): Unit =
def warning(msg: Message, offset: Int = in.offset): Unit =
ctx.warning(msg, source.atSpan(Span(offset)))

def deprecationWarning(msg: => Message, offset: Int = in.offset): Unit =
def deprecationWarning(msg: Message, offset: Int = in.offset): Unit =
ctx.deprecationWarning(msg, source.atSpan(Span(offset)))

/** Issue an error at current offset that input is incomplete */
def incompleteInputError(msg: => Message): Unit =
def incompleteInputError(msg: Message): Unit =
ctx.incompleteInputError(msg, source.atSpan(Span(in.offset)))

/** If at end of file, issue an incompleteInputError.
* Otherwise issue a syntax error and skip to next safe point.
*/
def syntaxErrorOrIncomplete(msg: => Message, offset: Int = in.offset): Unit =
def syntaxErrorOrIncomplete(msg: Message, offset: Int = in.offset): Unit =
if (in.token == EOF) incompleteInputError(msg)
else {
syntaxError(msg, offset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2258,7 +2258,7 @@ object messages {
lazy val explanation: String = ""
}

class PureExpressionInStatementPosition(stat: untpd.Tree, exprOwner: Symbol)(implicit ctx: Context)
class PureExpressionInStatementPosition(stat: untpd.Tree, val exprOwner: Symbol)(implicit ctx: Context)
extends Message(PureExpressionInStatementPositionID) {
val kind = "Potential Issue"
lazy val msg = "A pure expression does nothing in statement position; you may be omitting necessary parentheses"
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ object ErrorReporting {

import tpd._

def errorTree(tree: untpd.Tree, msg: => Message, pos: SourcePosition)(implicit ctx: Context): tpd.Tree =
def errorTree(tree: untpd.Tree, msg: Message, pos: SourcePosition)(implicit ctx: Context): tpd.Tree =
tree.withType(errorType(msg, pos))

def errorTree(tree: untpd.Tree, msg: => Message)(implicit ctx: Context): tpd.Tree =
def errorTree(tree: untpd.Tree, msg: Message)(implicit ctx: Context): tpd.Tree =
errorTree(tree, msg, tree.sourcePos)

def errorTree(tree: untpd.Tree, msg: TypeError, pos: SourcePosition)(implicit ctx: Context): tpd.Tree =
tree.withType(errorType(msg, pos))

def errorType(msg: => Message, pos: SourcePosition)(implicit ctx: Context): ErrorType = {
def errorType(msg: Message, pos: SourcePosition)(implicit ctx: Context): ErrorType = {
ctx.error(msg, pos)
ErrorType(msg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@ object DottyLanguageServer {
private def displayMessage(message: Message, sourceFile: SourceFile)(implicit ctx: Context): Boolean = {
if (isWorksheet(sourceFile)) {
message match {
case messages.PureExpressionInStatementPosition(_, exprOwner) =>
val ownerSym = if (exprOwner.isLocalDummy) exprOwner.owner else exprOwner
case msg: messages.PureExpressionInStatementPosition =>
val ownerSym = if (msg.exprOwner.isLocalDummy) msg.exprOwner.owner else msg.exprOwner
!isWorksheetWrapper(ownerSym)
case _ =>
true
Expand Down

0 comments on commit d0679b0

Please sign in to comment.