From cd82c859bb2fe05de257cbc81e97bedd2bbf2a4a Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 10 Jul 2014 14:37:19 +0200 Subject: Make more Definition methods depend on implicit context argument The problem is that exploration methods are run and phase dependent, whereas Definitions has an implicit context that freezes the period when Definitions ewas created. We should complement this by splitting Definitions into a global and per/run part, but that is independent of the change in this commit. --- src/dotty/tools/dotc/core/Definitions.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/dotty/tools/dotc/core/Definitions.scala') diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index d04a26883..594f0c013 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -409,20 +409,20 @@ class Definitions { lazy val RootImports = List[Symbol](JavaLangPackageVal, ScalaPackageVal, ScalaPredefModule, DottyPredefModule) - def isTupleType(tp: Type) = { + def isTupleType(tp: Type)(implicit ctx: Context) = { val arity = tp.dealias.argInfos.length arity <= MaxTupleArity && (tp isRef TupleClass(arity)) } - def isProductSubType(tp: Type) = + def isProductSubType(tp: Type)(implicit ctx: Context) = (tp derivesFrom ProductClass) && tp.baseClasses.exists(ProductClasses contains _) - def isFunctionType(tp: Type) = { + def isFunctionType(tp: Type)(implicit ctx: Context) = { val arity = functionArity(tp) 0 <= arity && arity <= MaxFunctionArity && (tp isRef FunctionClass(arity)) } - def functionArity(tp: Type) = tp.dealias.argInfos.length - 1 + def functionArity(tp: Type)(implicit ctx: Context) = tp.dealias.argInfos.length - 1 // ----- LambdaXYZ traits ------------------------------------------ @@ -544,7 +544,7 @@ class Definitions { val BooleanEnc = 17 val UnitEnc = 19 - def isValueSubClass(cls1: Symbol, cls2: Symbol) = + def isValueSubClass(cls1: Symbol, cls2: Symbol)(implicit ctx: Context) = valueClassEnc(cls2) % valueClassEnc(cls1) == 0 // ----- Initialization --------------------------------------------------- -- cgit v1.2.3