Skip to content

Commit 92814e1

Browse files
committed
Change messages.scala to work with cc
1 parent 97ce7c2 commit 92814e1

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

tests/pos-with-compiler-cc/dotc/reporting/Reporter.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import java.io.{BufferedReader, PrintWriter}
1616
import scala.annotation.internal.sharable
1717
import scala.collection.mutable
1818
import scala.caps.unsafeUnbox
19+
import language.experimental.pureFunctions
1920

2021
object Reporter {
2122
/** Convert a SimpleReporter into a real Reporter */

tests/pos-with-compiler-cc/dotc/reporting/messages.scala

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import ast.untpd
2626
import ast.tpd
2727
import transform.SymUtils._
2828
import cc.CaptureSet.IdentityCaptRefMap
29+
import language.experimental.pureFunctions
2930

3031
/** Messages
3132
* ========
@@ -41,45 +42,56 @@ import cc.CaptureSet.IdentityCaptRefMap
4142
*/
4243

4344
abstract class SyntaxMsg(errorId: ErrorMessageID) extends Message(errorId):
45+
this: SyntaxMsg =>
4446
def kind = MessageKind.Syntax
4547

4648
abstract class TypeMsg(errorId: ErrorMessageID) extends Message(errorId):
49+
this: TypeMsg =>
4750
def kind = MessageKind.Type
4851

4952
trait ShowMatchTrace(tps: Type*)(using Context) extends Message:
53+
this: ShowMatchTrace =>
5054
override def msgSuffix: String = matchReductionAddendum(tps*)
5155

5256
abstract class TypeMismatchMsg(found: Type, expected: Type)(errorId: ErrorMessageID)(using Context)
5357
extends Message(errorId), ShowMatchTrace(found, expected):
58+
this: TypeMismatchMsg =>
5459
def kind = MessageKind.TypeMismatch
5560
def explain = err.whyNoMatchStr(found, expected)
5661
override def canExplain = true
5762

5863
abstract class NamingMsg(errorId: ErrorMessageID) extends Message(errorId):
64+
this: NamingMsg =>
5965
def kind = MessageKind.Naming
6066

6167
abstract class DeclarationMsg(errorId: ErrorMessageID) extends Message(errorId):
68+
this: DeclarationMsg =>
6269
def kind = MessageKind.Declaration
6370

6471
/** A simple not found message (either for idents, or member selection.
6572
* Messages of this class are sometimes dropped in favor of other, more
6673
* specific messages.
6774
*/
6875
abstract class NotFoundMsg(errorId: ErrorMessageID) extends Message(errorId):
76+
this: NotFoundMsg =>
6977
def kind = MessageKind.NotFound
7078
def name: Name
7179

7280
abstract class PatternMatchMsg(errorId: ErrorMessageID) extends Message(errorId):
81+
this: PatternMatchMsg =>
7382
def kind = MessageKind.PatternMatch
7483

7584
abstract class CyclicMsg(errorId: ErrorMessageID) extends Message(errorId):
85+
this: CyclicMsg =>
7686
def kind = MessageKind.Cyclic
7787

7888
abstract class ReferenceMsg(errorId: ErrorMessageID) extends Message(errorId):
89+
this: ReferenceMsg =>
7990
def kind = MessageKind.Reference
8091

8192
abstract class EmptyCatchOrFinallyBlock(tryBody: untpd.Tree, errNo: ErrorMessageID)(using Context)
8293
extends SyntaxMsg(errNo) {
94+
this: EmptyCatchOrFinallyBlock =>
8395
def explain = {
8496
val tryString = tryBody match {
8597
case Block(Nil, untpd.EmptyTree) => "{}"
@@ -242,7 +254,7 @@ import cc.CaptureSet.IdentityCaptRefMap
242254
}
243255
}
244256

245-
class TypeMismatch(found: Type, expected: Type, inTree: Option[untpd.Tree], addenda: => String*)(using Context)
257+
class TypeMismatch(found: Type, expected: Type, inTree: Option[untpd.Tree], addenda: -> String*)(using Context)
246258
extends TypeMismatchMsg(found, expected)(TypeMismatchID):
247259

248260
// replace constrained TypeParamRefs and their typevars by their bounds where possible
@@ -298,7 +310,7 @@ import cc.CaptureSet.IdentityCaptRefMap
298310

299311
end TypeMismatch
300312

301-
class NotAMember(site: Type, val name: Name, selected: String, addendum: => String = "")(using Context)
313+
class NotAMember(site: Type, val name: Name, selected: String, addendum: -> String = "")(using Context)
302314
extends NotFoundMsg(NotAMemberID), ShowMatchTrace(site) {
303315
//println(i"site = $site, decls = ${site.decls}, source = ${site.typeSymbol.sourceFile}") //DEBUG
304316

@@ -822,7 +834,7 @@ import cc.CaptureSet.IdentityCaptRefMap
822834
|Write `.to$targetType` instead.""".stripMargin
823835
def explain = ""
824836

825-
class PatternMatchExhaustivity(uncoveredFn: => String, hasMore: Boolean)(using Context)
837+
class PatternMatchExhaustivity(uncoveredFn: -> String, hasMore: Boolean)(using Context)
826838
extends Message(PatternMatchExhaustivityID) {
827839
def kind = MessageKind.PatternMatchExhaustivity
828840
lazy val uncovered = uncoveredFn
@@ -842,7 +854,7 @@ import cc.CaptureSet.IdentityCaptRefMap
842854
|"""
843855
}
844856

845-
class UncheckedTypePattern(msgFn: => String)(using Context)
857+
class UncheckedTypePattern(msgFn: -> String)(using Context)
846858
extends PatternMatchMsg(UncheckedTypePatternID) {
847859
def msg = msgFn
848860
def explain =
@@ -1972,7 +1984,7 @@ import cc.CaptureSet.IdentityCaptRefMap
19721984
}
19731985
}
19741986

1975-
class CyclicInheritance(symbol: Symbol, addendum: => String)(using Context) extends SyntaxMsg(CyclicInheritanceID) {
1987+
class CyclicInheritance(symbol: Symbol, addendum: -> String)(using Context) extends SyntaxMsg(CyclicInheritanceID) {
19761988
def msg = em"Cyclic inheritance: $symbol extends itself$addendum"
19771989
def explain = {
19781990
val codeExample = "class A extends A"

0 commit comments

Comments
 (0)