Skip to content

Commit f1e57a3

Browse files
committed
Address review
1 parent 7b7838d commit f1e57a3

File tree

7 files changed

+22
-11
lines changed

7 files changed

+22
-11
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,10 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util.
14271427
def Symbol_isAbstractType(self: Symbol)(implicit ctx: Context): Boolean = self.isAbstractType
14281428
def Symbol_isClassConstructor(self: Symbol)(implicit ctx: Context): Boolean = self.isClassConstructor
14291429

1430+
def Symbol_isType(self: Symbol)(implicit ctx: Context): Boolean = self.isType
1431+
1432+
def Symbol_isTerm(self: Symbol)(implicit ctx: Context): Boolean = self.isTerm
1433+
14301434
type PackageDefSymbol = core.Symbols.Symbol
14311435

14321436
def matchPackageDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[PackageDefSymbol] =

library/src/scala/quoted/Toolbox.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object Toolbox {
3333
}
3434

3535
/** Setting of the Toolbox instance. */
36-
case class Settings private (val outDir: Option[String], val showRawTree: Boolean, val compilerArgs: List[String], val color: Boolean)
36+
case class Settings private (outDir: Option[String], showRawTree: Boolean, compilerArgs: List[String], color: Boolean)
3737

3838
object Settings {
3939

library/src/scala/tasty/reflect/Kernel.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ trait Kernel {
699699
//
700700
// PATTERNS
701701
//
702-
702+
703703
/** Pattern tree of the pattern part of a CaseDef */
704704
type Pattern <: AnyRef
705705

@@ -1169,6 +1169,10 @@ trait Kernel {
11691169

11701170
def Symbol_isDefinedInCurrentRun(self: Symbol)(implicit ctx: Context): Boolean
11711171

1172+
def Symbol_isType(self: Symbol)(implicit ctx: Context): Boolean
1173+
1174+
def Symbol_isTerm(self: Symbol)(implicit ctx: Context): Boolean
1175+
11721176
/** Symbol of a package definition */
11731177
type PackageDefSymbol <: Symbol
11741178

library/src/scala/tasty/reflect/Printers.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ trait Printers
13601360
case tpe @ Type.SymRef(IsClassDefSymbol(sym), _) if sym.name.endsWith("$") =>
13611361
printType(tpe)
13621362
this += ".type"
1363-
case tpe @ Type.SymRef(sym, _) if !IsTypeSymbol.unapply(sym).nonEmpty =>
1363+
case tpe @ Type.SymRef(sym, _) if sym.isTerm =>
13641364
printType(tpe)
13651365
this += ".type"
13661366
case tpe => printType(tpe)
@@ -1445,7 +1445,7 @@ trait Printers
14451445
case Type.ConstantType(const) =>
14461446
printConstant(const)
14471447

1448-
case Type.SymRef(sym, prefix) if IsTypeSymbol.unapply(sym).nonEmpty =>
1448+
case Type.SymRef(sym, prefix) if sym.isType =>
14491449
prefix match {
14501450
case Type.ThisType(Types.EmptyPackage() | Types.RootPackage()) =>
14511451
case NoPrefix() =>
@@ -1464,7 +1464,7 @@ trait Printers
14641464
}
14651465
this += highlightTypeDef(sym.name.stripSuffix("$"), color)
14661466

1467-
case Type.SymRef(sym, prefix) if !IsTypeSymbol.unapply(sym).nonEmpty =>
1467+
case Type.SymRef(sym, prefix) if sym.isTerm =>
14681468
prefix match {
14691469
case NoPrefix() =>
14701470
this += highlightTypeDef(sym.name, color)

library/src/scala/tasty/reflect/SymbolOps.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ trait SymbolOps extends Core {
8282
def isAnonymousFunction(implicit ctx: Context): Boolean = kernel.Symbol_isAnonymousFunction(self)
8383
def isAbstractType(implicit ctx: Context): Boolean = kernel.Symbol_isAbstractType(self)
8484
def isClassConstructor(implicit ctx: Context): Boolean = kernel.Symbol_isClassConstructor(self)
85+
86+
def isType(implicit ctx: Context): Boolean = kernel.Symbol_isType(self)
87+
def isTerm(implicit ctx: Context): Boolean = kernel.Symbol_isTerm(self)
8588
}
8689

8790
// PackageSymbol

tests/pos/i2104b.decompiled

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ case class Pair[A, B](_1: A, _2: B) {
1010
acc = scala.runtime.Statics.mix(acc, scala.runtime.Statics.anyHash(Pair.this._2))
1111
scala.runtime.Statics.finalizeHash(acc, 2)
1212
}
13-
override def equals(x$0: scala.Any): scala.Boolean = Pair.this.eq(x$0.$asInstanceOf$[java.lang.Object]).||(x$0 match {
14-
case x$0: Pair[A, B] @scala.unchecked =>
13+
override def equals(x$0: scala.Any): scala.Boolean = Pair.this.eq(x$0.asInstanceOf[java.lang.Object]).||(x$0 match {
14+
case x$0: Pair[Pair.this.A, Pair.this.B] @scala.unchecked =>
1515
Pair.this._1.==(x$0._1).&&(Pair.this._2.==(x$0._2))
1616
case _ =>
1717
false
1818
})
1919
override def toString(): java.lang.String = scala.runtime.ScalaRunTime._toString(Pair.this)
20-
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[Pair[A, B] @scala.unchecked]
20+
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[Pair[Pair.this.A, Pair.this.B] @scala.unchecked]
2121
override def productArity: scala.Int = 2
2222
override def productPrefix: java.lang.String = "Pair"
2323
override def productElement(n: scala.Int): scala.Any = n match {

tests/pos/simpleCaseClass-3.decompiled

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ case class A[T](x: T) {
44
acc = scala.runtime.Statics.mix(acc, scala.runtime.Statics.anyHash(A.this.x))
55
scala.runtime.Statics.finalizeHash(acc, 1)
66
}
7-
override def equals(x$0: scala.Any): scala.Boolean = A.this.eq(x$0.$asInstanceOf$[java.lang.Object]).||(x$0 match {
8-
case x$0: A[T] @scala.unchecked =>
7+
override def equals(x$0: scala.Any): scala.Boolean = A.this.eq(x$0.asInstanceOf[java.lang.Object]).||(x$0 match {
8+
case x$0: A[A.this.T] @scala.unchecked =>
99
A.this.x.==(x$0.x)
1010
case _ =>
1111
false
1212
})
1313
override def toString(): java.lang.String = scala.runtime.ScalaRunTime._toString(A.this)
14-
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[A[T] @scala.unchecked]
14+
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[A[A.this.T] @scala.unchecked]
1515
override def productArity: scala.Int = 1
1616
override def productPrefix: java.lang.String = "A"
1717
override def productElement(n: scala.Int): scala.Any = n match {

0 commit comments

Comments
 (0)