diff options
author | Martin Odersky <odersky@gmail.com> | 2017-03-18 18:46:24 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-06 13:15:28 +0200 |
commit | f6c61f3976a2780ce42ea6cd814986b662570687 (patch) | |
tree | 55ba214a169584e8ea2d7faff5c34296951b9b3b /compiler/src/dotty/tools/dotc/typer | |
parent | 8b1340b9b73d319ef7ac8f7f3bdaa75943de277e (diff) | |
download | dotty-f6c61f3976a2780ce42ea6cd814986b662570687.tar.gz dotty-f6c61f3976a2780ce42ea6cd814986b662570687.tar.bz2 dotty-f6c61f3976a2780ce42ea6cd814986b662570687.zip |
Split HKTypeLambda from PolyType
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer')
4 files changed, 17 insertions, 17 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Inferencing.scala b/compiler/src/dotty/tools/dotc/typer/Inferencing.scala index 18a1982e1..48da9f35f 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inferencing.scala @@ -119,9 +119,9 @@ object Inferencing { } } - /** If `tree` has a PolyType, infer its type parameters by comparing with expected type `pt` */ + /** If `tree` has a type lambda type, infer its type parameters by comparing with expected type `pt` */ def inferTypeParams(tree: Tree, pt: Type)(implicit ctx: Context): Tree = tree.tpe match { - case poly: PolyType => + case poly: TypeLambda => val (poly1, tvars) = constrained(poly, tree) val tree1 = tree.withType(poly1).appliedToTypeTrees(tvars) tree1.tpe <:< pt diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index a27175abd..ab342dc17 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -369,35 +369,35 @@ object ProtoTypes { /** A prototype for type constructors that are followed by a type application */ @sharable object AnyTypeConstructorProto extends UncachedGroundType with MatchAlways - /** Add all parameters in given polytype `pt` to the constraint's domain. + /** Add all parameters of given type lambda `tl` to the constraint's domain. * If the constraint contains already some of these parameters in its domain, - * make a copy of the polytype and add the copy's type parameters instead. - * Return either the original polytype, or the copy, if one was made. + * make a copy of the type lambda and add the copy's type parameters instead. + * Return either the original type lambda, or the copy, if one was made. * Also, if `owningTree` is non-empty, add a type variable for each parameter. - * @return The added polytype, and the list of created type variables. + * @return The added type lambda, and the list of created type variables. */ - def constrained(pt: PolyType, owningTree: untpd.Tree)(implicit ctx: Context): (PolyType, List[TypeTree]) = { + def constrained(tl: TypeLambda, owningTree: untpd.Tree)(implicit ctx: Context): (TypeLambda, List[TypeTree]) = { val state = ctx.typerState assert(!(ctx.typerState.isCommittable && owningTree.isEmpty), s"inconsistent: no typevars were added to committable constraint ${state.constraint}") - def newTypeVars(pt: PolyType): List[TypeTree] = - for (n <- (0 until pt.paramNames.length).toList) + def newTypeVars(tl: TypeLambda): List[TypeTree] = + for (n <- (0 until tl.paramNames.length).toList) yield { val tt = new TypeTree().withPos(owningTree.pos) - tt.withType(new TypeVar(TypeParamRef(pt, n), state, tt, ctx.owner)) + tt.withType(new TypeVar(TypeParamRef(tl, n), state, tt, ctx.owner)) } val added = - if (state.constraint contains pt) pt.newLikeThis(pt.paramNames, pt.paramInfos, pt.resultType) - else pt + if (state.constraint contains tl) tl.newLikeThis(tl.paramNames, tl.paramInfos, tl.resultType) + else tl val tvars = if (owningTree.isEmpty) Nil else newTypeVars(added) ctx.typeComparer.addToConstraint(added, tvars.tpes.asInstanceOf[List[TypeVar]]) (added, tvars) } - /** Same as `constrained(pt, EmptyTree)`, but returns just the created polytype */ - def constrained(pt: PolyType)(implicit ctx: Context): PolyType = constrained(pt, EmptyTree)._1 + /** Same as `constrained(tl, EmptyTree)`, but returns just the created type lambda */ + def constrained(tl: TypeLambda)(implicit ctx: Context): TypeLambda = constrained(tl, EmptyTree)._1 /** Create a new TypeParamRef that represents a dependent method parameter singleton */ def newDepTypeParamRef(tp: Type)(implicit ctx: Context): TypeParamRef = { diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala index fb1728578..2aa7036b4 100644 --- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -329,7 +329,7 @@ trait TypeAssigner { def assignType(tree: untpd.TypeApply, fn: Tree, args: List[Tree])(implicit ctx: Context) = { val ownType = fn.tpe.widen match { - case pt: PolyType => + case pt: TypeLambda => val paramNames = pt.paramNames if (hasNamedArg(args)) { // Type arguments which are specified by name (immutable after this first loop) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 8bde5e4e3..9a9e45941 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1055,7 +1055,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit typr.println(s"adding refinement $refinement") checkRefinementNonCyclic(refinement, refineCls, seen) val rsym = refinement.symbol - if (rsym.info.isInstanceOf[PolyType] && rsym.allOverriddenSymbols.isEmpty) + if (rsym.info.isInstanceOf[TypeLambda] && rsym.allOverriddenSymbols.isEmpty) ctx.error(i"polymorphic refinement $rsym without matching type in parent $tpt1 is no longer allowed", refinement.pos) } assignType(cpy.RefinedTypeTree(tree)(tpt1, refinements1), tpt1, refinements1, refineCls) } @@ -1841,7 +1841,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit } def adaptToArgs(wtp: Type, pt: FunProto): Tree = wtp match { - case _: MethodType | _: PolyType => + case _: MethodOrPoly => if (pt.args.lengthCompare(1) > 0 && isUnary(wtp) && ctx.canAutoTuple) adaptInterpolated(tree, pt.tupled, original) else |