File tree 7 files changed +35
-7
lines changed
compiler/src/dotty/tools/dotc
7 files changed +35
-7
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,8 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe
183
183
case LossyWideningConstantConversionID // errorNumber: 167
184
184
case ImplicitSearchTooLargeID // errorNumber: 168
185
185
case TargetNameOnTopLevelClassID // errorNumber: 169
186
-
186
+ case NotClassTypeID // errorNumber 170
187
+
187
188
def errorNumber = ordinal - 1
188
189
189
190
object ErrorMessageID :
Original file line number Diff line number Diff line change @@ -2521,3 +2521,8 @@ import transform.SymUtils._
2521
2521
| $annot $symbol { ... }
2522
2522
|
2523
2523
| ${hl(" export" )} Wrapper. ${symbol.name} ${hl(" // optional" )}"""
2524
+
2525
+ class NotClassType (tp : Type )(using Context )
2526
+ extends TypeMsg (NotClassTypeID ), ShowMatchTrace (tp):
2527
+ def msg = ex " $tp is not a class type "
2528
+ def explain = " "
Original file line number Diff line number Diff line change @@ -937,7 +937,7 @@ trait Checking {
937
937
if (stablePrefixReq && ctx.phase <= refchecksPhase) checkStable(tref.prefix, pos, " class prefix" )
938
938
tp
939
939
case _ =>
940
- report.error(ex " $tp is not a class type " , pos)
940
+ report.error(NotClassType (tp) , pos)
941
941
defn.ObjectType
942
942
}
943
943
Original file line number Diff line number Diff line change 1
- -- Error: tests/neg/classOf.scala:6:22 ------------ ---------------------------------------------------------------------
1
+ -- [E079] Type Error: tests/neg/classOf.scala:6:22 ---------------------------------------------------------------------
2
2
6 | def f1[T] = classOf[T] // error
3
3
| ^
4
4
| T is not a class type
5
- -- Error: tests/neg/classOf.scala:7:32 ------------ ---------------------------------------------------------------------
5
+ -- [E079] Type Error: tests/neg/classOf.scala:7:32 ---------------------------------------------------------------------
6
6
7 | def f2[T <: String] = classOf[T] // error
7
7
| ^
8
8
| T is not a class type
9
9
|
10
10
| where: T is a type in method f2 with bounds <: String
11
- -- Error: tests/neg/classOf.scala:9:18 ------------ ---------------------------------------------------------------------
11
+ -- [E079] Type Error: tests/neg/classOf.scala:9:18 ---------------------------------------------------------------------
12
12
9 | val y = classOf[C { type I = String }] // error
13
13
| ^^^^^^^^^^^^^^^^^^^^^
14
14
| Test.C{I = String} is not a class type
Original file line number Diff line number Diff line change 1
- -- Error: tests/neg/i13808.scala:13:37 ------------ ---------------------------------------------------------------------
1
+ -- [E079] Type Error: tests/neg/i13808.scala:13:37 ---------------------------------------------------------------------
2
2
13 |case class Boom[A](value: A) derives OpaqueType, Foo // error // error
3
3
| ^^^^^^^^^^
4
4
| OpaqueTypes.OpaqueType is not a class type
5
- -- Error: tests/neg/i13808.scala:13:49 ------------ ---------------------------------------------------------------------
5
+ -- [E079] Type Error: tests/neg/i13808.scala:13:49 ---------------------------------------------------------------------
6
6
13 |case class Boom[A](value: A) derives OpaqueType, Foo // error // error
7
7
| ^^^
8
8
| FooModule.Foo is not a class type
Original file line number Diff line number Diff line change
1
+ -- [E079] Type Error: tests/neg/i15155.scala:10:33 ---------------------------------------------------------------------
2
+ 10 | val EnumerationClass = classOf[EnumValue[E]] // error
3
+ | ^^^^^^^^^^^^
4
+ | EnumValue[E] is not a class type
5
+ |
6
+ | Note: a match type could not be fully reduced:
7
+ |
8
+ | trying to reduce EnumValue[E]
9
+ | failed since selector E
10
+ | does not match case Aux[a] => a
11
+ | and cannot be shown to be disjoint from it either.
Original file line number Diff line number Diff line change
1
+ import scala .reflect .ClassTag
2
+ // https://github.com/json4s/json4s/blob/355d8751391773e0d79d04402a4f9fb7bfc684ec/ext/src/main/scala-3/org/json4s/ext/package.scala#L4-L8
3
+ type Aux [A ] = { type Value = A }
4
+ type EnumValue [A <: Enumeration ] = A match {
5
+ case Aux [a] => a
6
+ }
7
+
8
+ // https://github.com/json4s/json4s/blob/355d8751391773e0d79d04402a4f9fb7bfc684ec/ext/src/main/scala/org/json4s/ext/EnumSerializer.scala#L25-L26
9
+ class EnumSerializer [E <: Enumeration : ClassTag ](enumeration : E ) {
10
+ val EnumerationClass = classOf [EnumValue [E ]] // error
11
+ }
You can’t perform that action at this time.
0 commit comments