Skip to content

Type matched class cannot be referenced using classOf #15155

Closed
@WojciechMazur

Description

@WojciechMazur

Compiler version

3.2.0-RC1-bin-20220429-400427d-NIGHTLY

Works with 3.1.2

The first bad commit is 54dc0c1 from #14761

Minimized code

//> using scala "3.2.0-RC1-bin-20220429-400427d-NIGHTLY"

// Last working version
// //> using scala "3.1.2"

import scala.reflect.ClassTag
// https://github.com/json4s/json4s/blob/355d8751391773e0d79d04402a4f9fb7bfc684ec/ext/src/main/scala-3/org/json4s/ext/package.scala#L4-L8
type Aux[A] = { type Value = A }
type EnumValue[A <: Enumeration] = A match {
  case Aux[a] => a
}

// https://github.com/json4s/json4s/blob/355d8751391773e0d79d04402a4f9fb7bfc684ec/ext/src/main/scala/org/json4s/ext/EnumSerializer.scala#L25-L26
class EnumSerializer[E <: Enumeration: ClassTag](enumeration: E) {
  val EnumerationClass = classOf[EnumValue[E]]
}

Output

[error] ./test.scala:15:34: EnumValue[E] is not a class type
[error]   val EnumerationClass = classOf[EnumValue[E]]
[error]                                  ^^^^^^^^^^^^```

Expectation

Should correctly allow getting an instance of Class for Enum.Value

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions