Skip to content

Flatten term type tree modules #6193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
2 changes: 1 addition & 1 deletion docs/docs/reference/other-new-features/tasty-reflect.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ TASTy Reflect provides the following types:
+- TypeTree ----+- Inferred
| +- TypeIdent
| +- TypeSelect
| +- Project
| +- Projection
| +- Singleton
| +- Refined
| +- Applied
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ trait TreeUtils {
import reflect._

/** Bind the `rhs` to a `val` and use it in `body` */
def let(rhs: Term)(body: Term.Ident => Term): Term = {
def let(rhs: Term)(body: Ident => Term): Term = {
type T // TODO probably it is better to use the Sealed contruct rather than let the user create their own existential type
implicit val rhsTpe: quoted.Type[T] = rhs.tpe.seal.asInstanceOf[quoted.Type[T]]
val rhsExpr = rhs.seal[T]
val expr = '{
val x = $rhsExpr
${
val id = ('x).unseal.asInstanceOf[Term.Ident]
val id = ('x).unseal.asInstanceOf[Ident]
body(id).seal[Any]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait TreeUtils {
import reflect._

/** Bind the `rhs` to a `val` and use it in `body` */
def let(rhs: Term)(bodyType: Type)(body: Term.Ident => Term): Term =
def let(rhs: Term)(bodyType: Type)(body: Ident => Term): Term =
throw new Exception("non bootstrpped lib")

}
18 changes: 1 addition & 17 deletions library/src/scala/tasty/reflect/Core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ package scala.tasty.reflect
* +- TypeTree ----+- Inferred
* | +- TypeIdent
* | +- TypeSelect
* | +- Project
* | +- Projection
* | +- Singleton
* | +- Refined
* | +- Applied
Expand Down Expand Up @@ -160,12 +160,6 @@ trait Core {
/** Tree representing an expression in the source code */
type Term = kernel.Term

/** Trees representing an expression in the source code */
val Term: TermCoreModule

/** Trees representing an expression in the source code */
trait TermCoreModule {

/** Tree representing a reference to definition */
type Ref = kernel.Ref

Expand Down Expand Up @@ -235,17 +229,9 @@ trait Core {
/** Tree representing a while loop */
type While = kernel.While

}

/** Type tree representing a type written in the source */
type TypeTree = kernel.TypeTree

/** Type trees representing a type written in the source */
val TypeTree: TypeTreeCoreModule

/** Type trees representing a type written in the source */
trait TypeTreeCoreModule {

/** Type tree representing an inferred type */
type Inferred = kernel.Inferred

Expand Down Expand Up @@ -285,8 +271,6 @@ trait Core {
/** Type tree within a block with aliases `{ type U1 = ... ; T[U1, U2] }` */
type TypeBlock = kernel.TypeBlock

}

/** Type tree representing a type bound written in the source */
type TypeBoundsTree = kernel.TypeBoundsTree

Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/tasty/reflect/Kernel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ package scala.tasty.reflect
* +- TypeTree ----+- Inferred
* | +- TypeIdent
* | +- TypeSelect
* | +- Project
* | +- Projection
* | +- Singleton
* | +- Refined
* | +- Applied
Expand Down
Loading