Skip to content

Commit 619fcf1

Browse files
committed
Avoid recomputing .moduleClass on compiletime.ops modules
1 parent 45d0678 commit 619fcf1

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ class Definitions {
241241
@tu lazy val CompiletimeTesting_ErrorKind_Parser: Symbol = CompiletimeTesting_ErrorKind.requiredMethod("Parser")
242242
@tu lazy val CompiletimeTesting_ErrorKind_Typer: Symbol = CompiletimeTesting_ErrorKind.requiredMethod("Typer")
243243
@tu lazy val CompiletimeOpsPackage: Symbol = requiredPackage("scala.compiletime.ops")
244-
@tu lazy val CompiletimeOpsAny: Symbol = requiredModule("scala.compiletime.ops.any")
245-
@tu lazy val CompiletimeOpsInt: Symbol = requiredModule("scala.compiletime.ops.int")
246-
@tu lazy val CompiletimeOpsString: Symbol = requiredModule("scala.compiletime.ops.string")
247-
@tu lazy val CompiletimeOpsBoolean: Symbol = requiredModule("scala.compiletime.ops.boolean")
244+
@tu lazy val CompiletimeOpsAnyModuleClass: Symbol = requiredModule("scala.compiletime.ops.any").moduleClass
245+
@tu lazy val CompiletimeOpsIntModuleClass: Symbol = requiredModule("scala.compiletime.ops.int").moduleClass
246+
@tu lazy val CompiletimeOpsStringModuleClass: Symbol = requiredModule("scala.compiletime.ops.string").moduleClass
247+
@tu lazy val CompiletimeOpsBooleanModuleClass: Symbol = requiredModule("scala.compiletime.ops.boolean").moduleClass
248248

249249
/** Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter)
250250
* because after erasure the Any and AnyVal references get remapped to the Object methods
@@ -1070,11 +1070,11 @@ class Definitions {
10701070
final def isCompiletimeAppliedType(sym: Symbol)(using Context): Boolean =
10711071
compiletimePackageOpTypes.contains(sym.name)
10721072
&& (
1073-
sym.owner == CompiletimePackageObject.moduleClass && sym.name == tpnme.S
1074-
|| sym.owner == CompiletimeOpsAny.moduleClass && compiletimePackageAnyTypes.contains(sym.name)
1075-
|| sym.owner == CompiletimeOpsInt.moduleClass && compiletimePackageIntTypes.contains(sym.name)
1076-
|| sym.owner == CompiletimeOpsBoolean.moduleClass && compiletimePackageBooleanTypes.contains(sym.name)
1077-
|| sym.owner == CompiletimeOpsString.moduleClass && compiletimePackageStringTypes.contains(sym.name)
1073+
isCompiletime_S(sym)
1074+
|| sym.owner == CompiletimeOpsAnyModuleClass && compiletimePackageAnyTypes.contains(sym.name)
1075+
|| sym.owner == CompiletimeOpsIntModuleClass && compiletimePackageIntTypes.contains(sym.name)
1076+
|| sym.owner == CompiletimeOpsBooleanModuleClass && compiletimePackageBooleanTypes.contains(sym.name)
1077+
|| sym.owner == CompiletimeOpsStringModuleClass && compiletimePackageStringTypes.contains(sym.name)
10781078
)
10791079

10801080
// ----- Scala-2 library patches --------------------------------------

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4062,11 +4062,11 @@ object Types {
40624062
if (owner == defn.CompiletimePackageObject.moduleClass) name match {
40634063
case tpnme.S if nArgs == 1 => constantFold1(natValue, _ + 1)
40644064
case _ => None
4065-
} else if (owner == defn.CompiletimeOpsAny.moduleClass) name match {
4065+
} else if (owner == defn.CompiletimeOpsAnyModuleClass) name match {
40664066
case tpnme.Equals if nArgs == 2 => constantFold2(constValue, _ == _)
40674067
case tpnme.NotEquals if nArgs == 2 => constantFold2(constValue, _ != _)
40684068
case _ => None
4069-
} else if (owner == defn.CompiletimeOpsInt.moduleClass) name match {
4069+
} else if (owner == defn.CompiletimeOpsIntModuleClass) name match {
40704070
case tpnme.Abs if nArgs == 1 => constantFold1(intValue, _.abs)
40714071
case tpnme.Negate if nArgs == 1 => constantFold1(intValue, x => -x)
40724072
case tpnme.ToString if nArgs == 1 => constantFold1(intValue, _.toString)
@@ -4094,10 +4094,10 @@ object Types {
40944094
case tpnme.Min if nArgs == 2 => constantFold2(intValue, _ min _)
40954095
case tpnme.Max if nArgs == 2 => constantFold2(intValue, _ max _)
40964096
case _ => None
4097-
} else if (owner == defn.CompiletimeOpsString.moduleClass) name match {
4097+
} else if (owner == defn.CompiletimeOpsStringModuleClass) name match {
40984098
case tpnme.Plus if nArgs == 2 => constantFold2(stringValue, _ + _)
40994099
case _ => None
4100-
} else if (owner == defn.CompiletimeOpsBoolean.moduleClass) name match {
4100+
} else if (owner == defn.CompiletimeOpsBooleanModuleClass) name match {
41014101
case tpnme.Not if nArgs == 1 => constantFold1(boolValue, x => !x)
41024102
case tpnme.And if nArgs == 2 => constantFold2(boolValue, _ && _)
41034103
case tpnme.Or if nArgs == 2 => constantFold2(boolValue, _ || _)

0 commit comments

Comments
 (0)