diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-29 19:05:20 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:34:59 +0200 |
commit | af43d325b778973ad9e144b5c27c455febb98890 (patch) | |
tree | 7803923eade05a15f0a5bbe3ef8b6fb86390643b /src/dotty/tools/dotc/typer | |
parent | 850dc6f2fb3b6228f2586ce0790621e80f664afe (diff) | |
download | dotty-af43d325b778973ad9e144b5c27c455febb98890.tar.gz dotty-af43d325b778973ad9e144b5c27c455febb98890.tar.bz2 dotty-af43d325b778973ad9e144b5c27c455febb98890.zip |
Abstract type parameters out from type symbols
In the new hk scheme, a type parameter can be represented by a
refinement without a corresponding symbol. Therefore, we need
to disentangle the info inherent in a type parameter from the
contents of a type symbol. We achieve this by creating a common
super trait "MemerInfo" of Symbol and RefinedType.
Diffstat (limited to 'src/dotty/tools/dotc/typer')
-rw-r--r-- | src/dotty/tools/dotc/typer/Implicits.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/TypeAssigner.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 6 |
4 files changed, 7 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index 7de40294d..e21a08fb8 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -325,7 +325,7 @@ trait ImplicitRunInfo { self: RunInfo => } def addParentScope(parent: TypeRef): Unit = { iscopeRefs(parent) foreach addRef - for (param <- parent.typeParams) + for (param <- parent.typeParamSymbols) comps ++= iscopeRefs(tp.member(param.name).info) } val companion = cls.companionModule diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index a8f3b8918..8437b651c 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -989,7 +989,7 @@ class Namer { typer: Typer => if (args.nonEmpty) { val tycon = tp.withoutArgs(args) val tycon1 = this(tycon) - val tparams = tycon.typeParams + val tparams = tycon.typeParamSymbols val args1 = if (args.length == tparams.length) etaExpandIfHK(tparams, args) else args if ((tycon1 eq tycon) && (args1 eq args)) tp else tycon1.appliedTo(args1) } else mapOver(tp) diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala index 47c3631b8..b7e2fd832 100644 --- a/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -409,11 +409,11 @@ trait TypeAssigner { def refineNamed(tycon: Type, arg: Tree) = arg match { case ast.Trees.NamedArg(name, argtpt) => // Dotty deviation: importing ast.Trees._ and matching on NamedArg gives a cyclic ref error - val tparam = tparams.find(_.name == name) match { + val tparam = tparams.find(_.memberName == name) match { case Some(tparam) => tparam case none => ntparams.find(_.name == name).getOrElse(NoSymbol) } - if (tparam.exists) RefinedType(tycon, name, argtpt.tpe.toBounds(tparam)) + if (tparam.isTypeParam) RefinedType(tycon, name, argtpt.tpe.toBounds(tparam)) else errorType(i"$tycon does not have a parameter or abstract type member named $name", arg.pos) case _ => errorType(s"named and positional type arguments may not be mixed", arg.pos) diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index fb3418563..225516503 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -943,14 +943,14 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit ctx.error(d"wrong number of type arguments for ${tpt1.tpe}, should be ${tparams.length}", tree.pos) args = args.take(tparams.length) } - def typedArg(arg: untpd.Tree, tparam: Symbol) = { + def typedArg(arg: untpd.Tree, tparam: MemberBinding) = { val (desugaredArg, argPt) = if (ctx.mode is Mode.Pattern) - (if (isVarPattern(arg)) desugar.patternVar(arg) else arg, tparam.info) + (if (isVarPattern(arg)) desugar.patternVar(arg) else arg, tparam.memberBounds) else (arg, WildcardType) val arg1 = typed(desugaredArg, argPt) - adaptTypeArg(arg1, tparam.info) + adaptTypeArg(arg1, tparam.memberBounds) } args.zipWithConserve(tparams)(typedArg(_, _)).asInstanceOf[List[Tree]] } |