Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ Full per-file list with locations is in the Backlog table below (filter rows whe
| `core/src/main/scala/com/avsystem/commons/misc/SealedUtils.scala:8` | caseObjectsFor (Scala 2 macro def) | L |
| `core/src/main/scala/com/avsystem/commons/misc/SelfInstance.scala:4` | C[_] existential narrowed to C[Any] (Scala 3 forbids HKT wildcard application) | S |
| `core/src/main/scala/com/avsystem/commons/misc/SelfInstance.scala:7` | SelfInstance.materialize (Scala 2 macro def) | L |
| `core/src/main/scala/com/avsystem/commons/misc/SimpleClassName.scala:8` | SimpleClassName.materialize (Scala 2 macro def) | L |
| `core/src/main/scala/com/avsystem/commons/misc/SourceInfo.scala:28` | SourceInfo.here (Scala 2 macro def) | L |
| `core/src/main/scala/com/avsystem/commons/misc/Timestamp.scala:13` | Comparable[Timestamp] (Scala 3 forbids AnyVal inheriting Object-derived traits) | S |
| `core/src/main/scala/com/avsystem/commons/misc/TypeString.scala:31` | TypeString.materialize (Scala 2 macro def) | L |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package com.avsystem.commons
package misc

import scala.quoted.*

case class SimpleClassName[T](name: String) extends AnyVal
object SimpleClassName {
def of[T](implicit scn: SimpleClassName[T]): String = scn.name

// TODO[scala3-port]: SimpleClassName.materialize (Scala 2 macro def) (L)
implicit def materialize[T]: SimpleClassName[T] = ???
inline implicit def materialize[T]: SimpleClassName[T] = ${ materializeImpl[T] }

private def materializeImpl[T: Type](using Quotes): Expr[SimpleClassName[T]] = {
import quotes.reflect.*
val sym = TypeRepr.of[T].dealias.typeSymbol
val name = Expr(sym.name.stripSuffix("$"))
'{ SimpleClassName[T]($name) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.avsystem.commons.misc

import org.scalatest.funsuite.AnyFunSuite

class SimpleClassNameTest extends AnyFunSuite {
test("String") {
assert(SimpleClassName.of[String] == "String")
}

test("List[Int]") {
assert(SimpleClassName.of[List[Int]] == "List")
}

test("nested case class") {
assert(SimpleClassName.of[SimpleClassNameTest.Foo] == "Foo")
}
}

object SimpleClassNameTest {
case class Foo(x: Int)
}
Loading