aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 33258b6b6..f24c41ee2 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -386,7 +386,7 @@ object SymDenotations {
/** Is symbol a primitive value class? */
def isPrimitiveValueClass(implicit ctx: Context) = defn.ScalaValueClasses contains symbol
- /** Is symbol a primitive value class? */
+ /** Is symbol a primitive numeric value class? */
def isNumericValueClass(implicit ctx: Context) = defn.ScalaNumericValueClasses contains symbol
/** Is symbol a phantom class for which no runtime representation exists? */
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index dadd2afdc..9e9acf97a 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -1057,6 +1057,9 @@ trait Applications extends Compatibility { self: Typer =>
else ts
}
+ /** If `trees` all have numeric value types, and they do not have all the same type,
+ * pick a common numeric supertype and convert all trees to this type.
+ */
def harmonize(trees: List[Tree])(implicit ctx: Context): List[Tree] = {
def adapt(tree: Tree, pt: Type): Tree = tree match {
case cdef: CaseDef => tpd.cpy.CaseDef(cdef)(body = adapt(cdef.body, pt))
@@ -1065,6 +1068,9 @@ trait Applications extends Compatibility { self: Typer =>
harmonizeWith(trees)(_.tpe, adapt)
}
+ /** If all `types` are numeric value types, and they are not all the same type,
+ * pick a common numeric supertype and return it instead of every original type.
+ */
def harmonizeTypes(tpes: List[Type])(implicit ctx: Context): List[Type] =
harmonizeWith(tpes)(identity, (tp, pt) => pt)
}