blob: d474c77b4621039078c36e8a3ad1321c3348a947 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package dotty.tools.dotc
package transform
import core._
import TypeErasure.ErasedValueType
import Types._
import Contexts._
import Symbols._
import Decorators._
import StdNames.nme
import NameOps._
import language.implicitConversions
object TypeUtils {
implicit def decorateTypeUtils(tpe: Type): TypeUtils = new TypeUtils(tpe)
}
/** A decorator that provides methods on types
* that are needed in the transformer pipeline.
*/
class TypeUtils(val self: Type) extends AnyVal {
import TypeUtils._
def isErasedValueType(implicit ctx: Context): Boolean =
self.isInstanceOf[ErasedValueType]
def isPrimitiveValueType(implicit ctx: Context): Boolean =
self.classSymbol.isPrimitiveValueClass
def ensureMethodic(implicit ctx: Context): Type = self match {
case self: MethodicType => self
case _ => if (ctx.erasedTypes) MethodType(Nil, self) else ExprType(self)
}
}
|