Skip to content

Commit b28c970

Browse files
committed
Fix #7781: Avoid using nested package definition
Had to remove `sealed` from `Expr`
1 parent 6598edd commit b28c970

File tree

2 files changed

+246
-250
lines changed

2 files changed

+246
-250
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package scala.internal.quoted
2+
3+
import scala.quoted.Expr
4+
5+
/** An Expr backed by a tree. Only the current compiler trees are allowed.
6+
*
7+
* These expressions are used for arguments of macros. They contain and actual tree
8+
* from the program that is being expanded by the macro.
9+
*
10+
* May contain references to code defined outside this TastyTreeExpr instance.
11+
*/
12+
final class TastyTreeExpr[Tree](val tree: Tree, val scopeId: Int) extends Expr[Any] {
13+
override def equals(that: Any): Boolean = that match {
14+
case that: TastyTreeExpr[_] =>
15+
// TastyTreeExpr are wrappers around trees, therfore they are equals if their trees are equal.
16+
// All scopeId should be equal unless two different runs of the compiler created the trees.
17+
tree == that.tree && scopeId == that.scopeId
18+
case _ => false
19+
}
20+
override def hashCode: Int = tree.hashCode
21+
override def toString: String = s"Expr(<tasty tree>)"
22+
}

0 commit comments

Comments
 (0)