Skip to content

Commit 2036126

Browse files
committed
Address PR tasks
1 parent 546bc4c commit 2036126

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,20 +1889,20 @@ object messages {
18891889
val explanation = "A statement is either an import, a definition or an expression."
18901890
}
18911891

1892-
case class TraitIsExpected(tref: TypeRef)(implicit ctx: Context) extends Message(TraitIsExpectedID) {
1892+
case class TraitIsExpected(symbol: Symbol)(implicit ctx: Context) extends Message(TraitIsExpectedID) {
18931893
val kind = "Syntax"
1894-
val msg = hl"$tref is not a trait"
1894+
val msg = hl"$symbol is not a trait"
18951895
val explanation = {
18961896
val errorCodeExample =
18971897
"""class A
18981898
|class B
18991899
|
1900-
|val a = new A with B // will fail with a compile error - B is not a trait"""
1900+
|val a = new A with B // will fail with a compile error - class B is not a trait""".stripMargin
19011901
val codeExample =
19021902
"""class A
19031903
|trait B
19041904
|
1905-
|val a = new A with B // compiles normally"""
1905+
|val a = new A with B // compiles normally""".stripMargin
19061906

19071907
hl"""Only traits can be mixed into classes using a ${"with"} keyword.
19081908
|Consider the following example:

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ trait Checking {
548548
def checkClassType(tp: Type, pos: Position, traitReq: Boolean, stablePrefixReq: Boolean)(implicit ctx: Context): Type =
549549
tp.underlyingClassRef(refinementOK = false) match {
550550
case tref: TypeRef =>
551-
if (traitReq && !(tref.symbol is Trait)) ctx.error(TraitIsExpected(tref), pos)
551+
if (traitReq && !(tref.symbol is Trait)) ctx.error(TraitIsExpected(tref.symbol), pos)
552552
if (stablePrefixReq && ctx.phase <= ctx.refchecksPhase) checkStable(tref.prefix, pos)
553553
tp
554554
case _ =>

compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ class ErrorMessagesTests extends ErrorMessagesTest {
11691169
implicit val ctx: Context = ictx
11701170

11711171
assertMessageCount(1, messages)
1172-
val TraitIsExpected(tref) :: Nil = messages
1173-
assertEquals("B", tref.show)
1172+
val TraitIsExpected(symbol) :: Nil = messages
1173+
assertEquals("class B", symbol.show)
11741174
}
11751175
}

0 commit comments

Comments
 (0)