-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reflect TypeRepr.dealiasKeepOpaques
From #18562
- Loading branch information
1 parent
89fa247
commit b59b901
Showing
6 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
java.lang.String | ||
java.lang.String | ||
scala.collection.immutable.List[Test_2$package.A] | ||
scala.collection.immutable.List[scala.Int] | ||
Test_2$package.OA | ||
Test_2$package.OB | ||
Test_2$package.OC[scala.Int] | ||
Test_2$package.OA | ||
Test_2$package.OB | ||
Test_2$package.OC[scala.Int] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import scala.quoted.* | ||
|
||
inline def dealiasKeepOpaques[T]: String = ${ impl[T] } | ||
|
||
def impl[T: Type](using Quotes) : Expr[String] = { | ||
import quotes.reflect.* | ||
Expr(TypeRepr.of[T].dealiasKeepOpaques.show) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
type A = String | ||
type B = List[A] | ||
type C[X] = List[X] | ||
|
||
opaque type OA = String | ||
object OA: | ||
def test = println(dealiasKeepOpaques[OA]) | ||
|
||
opaque type OB = List[A] | ||
object OB: | ||
def test = println(dealiasKeepOpaques[OB]) | ||
|
||
opaque type OC[X] = List[X] | ||
object OC: | ||
def test = println(dealiasKeepOpaques[OC[Int]]) | ||
|
||
|
||
@main def Test: Unit = { | ||
println(dealiasKeepOpaques[String]) | ||
println(dealiasKeepOpaques[A]) | ||
println(dealiasKeepOpaques[B]) | ||
println(dealiasKeepOpaques[C[Int]]) | ||
println(dealiasKeepOpaques[OA]) | ||
println(dealiasKeepOpaques[OB]) | ||
println(dealiasKeepOpaques[OC[Int]]) | ||
OA.test | ||
OB.test | ||
OC.test | ||
} |