aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-06-03 11:33:53 +0200
committerMartin Odersky <odersky@gmail.com>2013-06-03 11:33:53 +0200
commit339809ed82e14699681a5a7765c87133cd681ec0 (patch)
tree283b653e9260d3feb01e19b955033de74bc53790 /src/dotty/tools/dotc/core/Types.scala
parent17d0e7008f62882c10193ea0db09c9b90736c320 (diff)
downloaddotty-339809ed82e14699681a5a7765c87133cd681ec0.tar.gz
dotty-339809ed82e14699681a5a7765c87133cd681ec0.tar.bz2
dotty-339809ed82e14699681a5a7765c87133cd681ec0.zip
More solid design of Namer with some Typer bits added.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index c0e338ef1..c78b876b4 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -411,6 +411,22 @@ object Types {
ctx.typeComparer.matchesType(
this, that, alwaysMatchSimple = !ctx.phase.erasedTypes)
+ /** The non-private symbol with given name in the given class that matches this type.
+ * @param inClass The class containing the symbol's definition
+ * @param name The name of the symbol we are looking for
+ * @param site The base type from which member types are computed
+ */
+ def matchingTermSymbol(inClass: Symbol, name: Name, site: Type)(implicit ctx: Context): Symbol = {
+ var denot = inClass.info.nonPrivateDecl(name)
+ if (denot.isTerm) { // types of the same name always match
+ if (denot.isOverloaded)
+ denot = denot.atSignature(this.signature) // seems we need two kinds of signatures here
+ if (!(site.memberInfo(denot.symbol) matches this))
+ denot = NoDenotation
+ }
+ denot.symbol
+ }
+
/** The basetype of this type with given class symbol */
final def baseType(base: Symbol)(implicit ctx: Context): Type = base.denot match {
case classd: ClassDenotation => classd.baseTypeOf(this)
@@ -505,6 +521,15 @@ object Types {
/** The resultType of a PolyType, MethodType, or ExprType, the type itself for others */
def resultType: Type = this
+ /** The final result type of a PolyType, MethodType, or ExprType, after skipping
+ * all parameter sections, the type itself for all others.
+ */
+ def finalResultType: Type = resultType match {
+ case mt: MethodType => mt.resultType.finalResultType
+ case pt: PolyType => pt.resultType.finalResultType
+ case _ => resultType
+ }
+
/** This type seen as a TypeBounds */
final def bounds(implicit ctx: Context): TypeBounds = this match {
case tp: TypeBounds => tp
@@ -1369,13 +1394,15 @@ object Types {
}
object PolyType {
- def fromSymbols(tparams: List[Symbol], resultType: Type)(implicit ctx: Context) = {
- def transform(pt: PolyType, tp: Type) =
- tp.subst(tparams, (0 until tparams.length).toList map (PolyParam(pt, _)))
- apply(tparams map (_.name.asTypeName))(
+ def fromSymbols(tparams: List[Symbol], resultType: Type)(implicit ctx: Context) =
+ if (tparams.isEmpty) resultType
+ else {
+ def transform(pt: PolyType, tp: Type) =
+ tp.subst(tparams, (0 until tparams.length).toList map (PolyParam(pt, _)))
+ apply(tparams map (_.name.asTypeName))(
pt => tparams map (tparam => transform(pt, tparam.info).bounds),
pt => transform(pt, resultType))
- }
+ }
}
abstract class BoundType extends UncachedProxyType with ValueType {