Skip to content

Commit 4eb40c9

Browse files
committed
Add AnyRef bound to TASTy reflect types
All implementations are and will always be AnyRefs. This also allows us to use methods such as mapConserve on a List[Tree].
1 parent 755d607 commit 4eb40c9

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

library/src/scala/tasty/reflect/Core.scala

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,17 @@ package scala.tasty.reflect
115115
trait Core {
116116

117117
/** Compilation context */
118-
type Context
118+
type Context <: AnyRef
119119

120120
/** Settings */
121-
type Settings
121+
type Settings <: AnyRef
122122

123123
// TODO: When bootstrapped, remove and use `Term | TypeTree` type directly in other files
124124
/** Workaround missing `|` types in Scala 2 to represent `Term | TypeTree` */
125-
type TermOrTypeTree /* Term | TypeTree */
125+
type TermOrTypeTree /* Term | TypeTree */ <: AnyRef
126126

127127
/** Tree representing code written in the source */
128-
type Tree
128+
type Tree <: AnyRef
129129

130130
/** Tree representing a pacakage clause in the source code */
131131
type PackageClause <: Tree
@@ -161,13 +161,13 @@ trait Core {
161161

162162

163163
/** Branch of a pattern match or catch clause */
164-
type CaseDef
164+
type CaseDef <: AnyRef
165165

166166
/** Branch of a type pattern match */
167-
type TypeCaseDef
167+
type TypeCaseDef <: AnyRef
168168

169169
/** Pattern tree of the pattern part of a CaseDef */
170-
type Pattern
170+
type Pattern <: AnyRef
171171

172172
/** Pattern representing a value. This includes `1`, ```x``` and `_` */
173173
type Value <: Pattern
@@ -185,7 +185,7 @@ trait Core {
185185
type TypeTest <: Pattern
186186

187187
/** Type tree representing a type or a bounds written in the source */
188-
type TypeOrBoundsTree
188+
type TypeOrBoundsTree <: AnyRef
189189

190190
/** Type tree representing a type written in the source */
191191
type TypeTree <: TypeOrBoundsTree
@@ -197,7 +197,7 @@ trait Core {
197197
type TypeBoundsTree <: TypeOrBoundsTree
198198

199199
/** Type or bounds */
200-
type TypeOrBounds
200+
type TypeOrBounds <: AnyRef
201201

202202
/** NoPrefix for a type selection */
203203
type NoPrefix <: TypeOrBounds
@@ -231,24 +231,24 @@ trait Core {
231231
* * RenameSelector: `.{bar => baz}` in `import foo.{bar => baz}`
232232
* * OmitSelector: `.{bar => _}` in `import foo.{bar => _}`
233233
*/
234-
type ImportSelector
234+
type ImportSelector <: AnyRef
235235

236236
/** Untyped identifier */
237-
type Id
237+
type Id <: AnyRef
238238

239239
/** JVM signature of a method */
240-
type Signature
240+
type Signature <: AnyRef
241241

242242
/** Source position */
243-
type Position
243+
type Position <: AnyRef
244244

245245
/** Constant value represented as the constant itself */
246-
type Constant
246+
type Constant <: AnyRef
247247

248248
/** Symbol of a definition.
249249
* Then can be compared with == to know if the definition is the same.
250250
*/
251-
type Symbol
251+
type Symbol <: AnyRef
252252

253253
/** Symbol of a package defnition */
254254
type PackageSymbol <: Symbol

0 commit comments

Comments
 (0)