From f922a46b09cd65a421f8a61eb1979e651a8e8110 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 19 Feb 2015 12:18:10 +0100 Subject: Moved part of computation of types of DefDefs from Namer to TypeOps ... so that this can be re-used in the tree unpickler. --- src/dotty/tools/dotc/core/TypeOps.scala | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/dotty/tools/dotc/core/TypeOps.scala') diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 3e04eb037..9a9251646 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -10,7 +10,7 @@ import util.SimpleMap import collection.mutable import ast.tpd._ -trait TypeOps { this: Context => +trait TypeOps { this: Context => // TODO: Make standalone object. final def asSeenFrom(tp: Type, pre: Type, cls: Symbol, theMap: AsSeenFromMap): Type = { @@ -402,6 +402,23 @@ trait TypeOps { this: Context => /** Is auto-tupling enabled? */ def canAutoTuple = !featureEnabled(defn.LanguageModuleClass, nme.noAutoTupling) + + def methodType(typeParams: List[Symbol], valueParamss: List[List[Symbol]], resultType: Type, isJava: Boolean = false)(implicit ctx: Context): Type = { + val monotpe = + (valueParamss :\ resultType) { (params, resultType) => + val make = + if (params.nonEmpty && (params.head is Implicit)) ImplicitMethodType + else if (isJava) JavaMethodType + else MethodType + if (isJava) + for (param <- params) + if (param.info.isDirectRef(defn.ObjectClass)) param.info = defn.AnyType + make.fromSymbols(params, resultType) + } + if (typeParams.nonEmpty) PolyType.fromSymbols(typeParams, monotpe) + else if (valueParamss.isEmpty) ExprType(monotpe) + else monotpe + } } object TypeOps { -- cgit v1.2.3