Skip to content

Commit d55938e

Browse files
committedFeb 6, 2024
Update phrasing for NotClassType explain error message
Fixes #14175
1 parent 5850d2d commit d55938e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -2775,7 +2775,10 @@ extends SyntaxMsg(TargetNameOnTopLevelClassID):
27752775
class NotClassType(tp: Type)(using Context)
27762776
extends TypeMsg(NotClassTypeID), ShowMatchTrace(tp):
27772777
def msg(using Context) = i"$tp is not a class type"
2778-
def explain(using Context) = ""
2778+
def explain(using Context) =
2779+
i"""A class type includes classes and traits in a specific order. Defining a class, even an anonymous class,
2780+
|requires specifying an order for the traits it extends. For example, `A & B` is not a class type because it
2781+
|doesn't specify which trait takes precedence, A or B. Both `A with B` and `B with A` are class types."""
27792782

27802783
class NotConstant(suffix: String, tp: Type)(using Context)
27812784
extends TypeMsg(NotConstantID), ShowMatchTrace(tp):

0 commit comments

Comments
 (0)