aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-18 11:26:59 +0100
committerMartin Odersky <odersky@gmail.com>2017-04-06 13:15:28 +0200
commitdb4f7a19c9329d59da09a4de6b8476b4b6988cdf (patch)
treee70a1cf2d4af3a9e3e4b3999d5000b4466627143 /compiler/src/dotty/tools/dotc/typer
parent26497bb3c654e294a48db2098978bc77b11f2889 (diff)
downloaddotty-db4f7a19c9329d59da09a4de6b8476b4b6988cdf.tar.gz
dotty-db4f7a19c9329d59da09a4de6b8476b4b6988cdf.tar.bz2
dotty-db4f7a19c9329d59da09a4de6b8476b4b6988cdf.zip
Further refactorings
- Use TypeLambda instead of PolyType. - Further harmonize factory operations
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Applications.scala9
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Checking.scala8
-rw-r--r--compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Implicits.scala6
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Inliner.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Namer.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala2
7 files changed, 14 insertions, 19 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala
index cd7c7fd66..25c9c13d8 100644
--- a/compiler/src/dotty/tools/dotc/typer/Applications.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala
@@ -34,7 +34,7 @@ object Applications {
def extractorMember(tp: Type, name: Name)(implicit ctx: Context) = {
def isPossibleExtractorType(tp: Type) = tp match {
- case _: MethodType | _: PolyType => false
+ case _: MethodOrPoly => false
case _ => true
}
tp.member(name).suchThat(d => isPossibleExtractorType(d.info))
@@ -1412,12 +1412,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
recur(altFormals.map(_.tail), args1)
case _ =>
}
- def paramTypes(alt: Type): List[Type] = alt match {
- case mt: MethodType => mt.paramInfos
- case mt: PolyType => paramTypes(mt.resultType)
- case _ => Nil
- }
- recur(alts.map(alt => paramTypes(alt.widen)), pt.args)
+ recur(alts.map(_.widen.firstParamTypes), pt.args)
}
private def harmonizeWith[T <: AnyRef](ts: List[T])(tpe: T => Type, adapt: (T, Type) => T)(implicit ctx: Context): List[T] = {
diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala
index e959e6984..00d36651e 100644
--- a/compiler/src/dotty/tools/dotc/typer/Checking.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala
@@ -50,12 +50,12 @@ object Checking {
arg.pos.focus)
}
- /** Check that type arguments `args` conform to corresponding bounds in `poly`
+ /** Check that type arguments `args` conform to corresponding bounds in `tl`
* Note: This does not check the bounds of AppliedTypeTrees. These
* are handled by method checkBounds in FirstTransform
*/
- def checkBounds(args: List[tpd.Tree], poly: PolyType)(implicit ctx: Context): Unit =
- checkBounds(args, poly.paramInfos, _.substParams(poly, _))
+ def checkBounds(args: List[tpd.Tree], tl: TypeLambda)(implicit ctx: Context): Unit =
+ checkBounds(args, tl.paramInfos, _.substParams(tl, _))
/** Check applied type trees for well-formedness. This means
* - all arguments are within their corresponding bounds
@@ -82,7 +82,7 @@ object Checking {
def checkWildcardHKApply(tp: Type, pos: Position): Unit = tp match {
case tp @ HKApply(tycon, args) if args.exists(_.isInstanceOf[TypeBounds]) =>
tycon match {
- case tycon: PolyType =>
+ case tycon: TypeLambda =>
ctx.errorOrMigrationWarning(
ex"unreducible application of higher-kinded type $tycon to wildcard arguments",
pos)
diff --git a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
index 5063a111c..6c72c16e0 100644
--- a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
+++ b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
@@ -74,7 +74,7 @@ object ErrorReporting {
def anonymousTypeMemberStr(tpe: Type) = {
val kind = tpe match {
case _: TypeBounds => "type with bounds"
- case _: PolyType | _: MethodType => "method"
+ case _: MethodOrPoly => "method"
case _ => "value of type"
}
em"$kind $tpe"
diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala
index af2145376..703d2fc3c 100644
--- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala
@@ -108,8 +108,8 @@ object Implicits {
}
def discardForValueType(tpw: Type): Boolean = tpw match {
- case mt: MethodType => !mt.isImplicit
- case mt: PolyType => discardForValueType(tpw.resultType)
+ case tpw: MethodType => !tpw.isImplicit
+ case tpw: PolyType => discardForValueType(tpw.resultType)
case _ => false
}
@@ -387,7 +387,7 @@ trait ImplicitRunInfo { self: RunInfo =>
case _ => arg
}
(apply(tp.tycon) /: tp.args)((tc, arg) => AndType.make(tc, applyArg(arg)))
- case tp: PolyType =>
+ case tp: TypeLambda =>
apply(tp.resType)
case _ =>
mapOver(tp)
diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala
index 6ef6c12cc..90052a1ed 100644
--- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala
@@ -120,7 +120,7 @@ object Inliner {
// Abstract accessed type over local refs
def abstractQualType(mtpe: Type): Type =
if (localRefs.isEmpty) mtpe
- else mtpe.LambdaAbstract(localRefs.map(_.symbol)).asInstanceOf[PolyType].flatten
+ else PolyType.fromParams(localRefs.map(_.symbol.asType), mtpe).flatten
val accessorType = abstractQualType(addQualType(dealiasMap(accessedType)))
val accessor = accessorSymbol(tree, accessorType).asTerm
diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala
index 54e9af593..bdf044aa8 100644
--- a/compiler/src/dotty/tools/dotc/typer/Namer.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala
@@ -113,9 +113,9 @@ trait NamerContextOps { this: Context =>
if (isJava)
for (param <- params)
if (param.info.isDirectRef(defn.ObjectClass)) param.info = defn.AnyType
- make.fromSymbols(params, resultType)
+ make.fromSymbols(params.asInstanceOf[List[TermSymbol]], resultType)
}
- if (typeParams.nonEmpty) monotpe.LambdaAbstract(typeParams)
+ if (typeParams.nonEmpty) monotpe.LambdaAbstract(typeParams.asInstanceOf[List[TypeSymbol]])
else if (valueParamss.isEmpty) ExprType(monotpe)
else monotpe
}
diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala
index 0edb22b06..4416428f4 100644
--- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -460,7 +460,7 @@ trait TypeAssigner {
}
def assignType(tree: untpd.LambdaTypeTree, tparamDefs: List[TypeDef], body: Tree)(implicit ctx: Context) =
- tree.withType(body.tpe.LambdaAbstract(tparamDefs.map(_.symbol)))
+ tree.withType(body.tpe.LambdaAbstract(tparamDefs.map(_.symbol.asType)))
def assignType(tree: untpd.ByNameTypeTree, result: Tree)(implicit ctx: Context) =
tree.withType(ExprType(result.tpe))