aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2014-09-23 11:21:09 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-09-23 11:21:09 +0200
commit8bd14310f60c1be997a62eaba84dd49624ea2df6 (patch)
tree39369f935293359c80414f0cdafbdf8acc0468c3 /src/dotty/tools/dotc
parent857cd4839c872d229994c9d27bb06ef866dad93d (diff)
downloaddotty-8bd14310f60c1be997a62eaba84dd49624ea2df6.tar.gz
dotty-8bd14310f60c1be997a62eaba84dd49624ea2df6.tar.bz2
dotty-8bd14310f60c1be997a62eaba84dd49624ea2df6.zip
Renamed parameters in Typer&Applictaions.
Indicating that pt is type of selector is this pattern match makes it easier to follow.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala21
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala4
2 files changed, 13 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 35a1ab3e9..b2572dcda 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -581,7 +581,7 @@ trait Applications extends Compatibility { self: Typer =>
assignType(cpy.TypeApply(tree)(typedFn, typedArgs), typedFn, typedArgs)
}
- def typedUnApply(tree: untpd.Apply, pt: Type)(implicit ctx: Context): Tree = track("typedUnApply") {
+ def typedUnApply(tree: untpd.Apply, selType: Type)(implicit ctx: Context): Tree = track("typedUnApply") {
val Apply(qual, args) = tree
def notAnExtractor(tree: Tree) =
@@ -620,7 +620,7 @@ trait Applications extends Compatibility { self: Typer =>
*/
def trySelectUnapply(qual: untpd.Tree)(fallBack: Tree => Tree): Tree = {
val genericProto = new UnapplyFunProto(WildcardType, this)
- def specificProto = new UnapplyFunProto(pt, this)
+ def specificProto = new UnapplyFunProto(selType, this)
// try first for non-overloaded, then for overloaded ocurrences
def tryWithName(name: TermName)(fallBack: Tree => Tree)(implicit ctx: Context): Tree =
tryEither {
@@ -662,20 +662,21 @@ trait Applications extends Compatibility { self: Typer =>
unapplyFn.tpe.widen match {
case mt: MethodType if mt.paramTypes.length == 1 && !mt.isDependent =>
+ val m = mt
val unapplyArgType = mt.paramTypes.head
- unapp.println(i"unapp arg tpe = $unapplyArgType, pt = $pt")
- def wpt = widenForMatchSelector(pt) // needed?
+ unapp.println(i"unapp arg tpe = $unapplyArgType, pt = $selType")
+ def wpt = widenForMatchSelector(selType) // needed?
val ownType =
- if (pt <:< unapplyArgType) {
- fullyDefinedType(unapplyArgType, "extractor argument", tree.pos)
+ if (selType <:< unapplyArgType) {
+ //fullyDefinedType(unapplyArgType, "extractor argument", tree.pos)
unapp.println(i"case 1 $unapplyArgType ${ctx.typerState.constraint}")
- pt
+ selType
} else if (isSubTypeOfParent(unapplyArgType, wpt)) {
maximizeType(unapplyArgType) match {
case Some(tvar) =>
def msg =
d"""There is no best instantiation of pattern type $unapplyArgType
- |that makes it a subtype of selector type $pt.
+ |that makes it a subtype of selector type $selType.
|Non-variant type variable ${tvar.origin} cannot be uniquely instantiated.""".stripMargin
if (fromScala2x) {
// We can't issue an error here, because in Scala 2, ::[B] is invariant
@@ -702,7 +703,7 @@ trait Applications extends Compatibility { self: Typer =>
tree.pos)
}
- val dummyArg = dummyTreeOfType(unapplyArgType)
+ val dummyArg = dummyTreeOfType(ownType)
val unapplyApp = typedExpr(untpd.TypedSplice(Apply(unapplyFn, dummyArg :: Nil)))
val unapplyImplicits = unapplyApp match {
case Apply(Apply(unapply, `dummyArg` :: Nil), args2) => assert(args2.nonEmpty); args2
@@ -726,7 +727,7 @@ trait Applications extends Compatibility { self: Typer =>
val unapplyPatterns = (bunchedArgs, argTypes).zipped map (typed(_, _))
val result = assignType(cpy.UnApply(tree)(unapplyFn, unapplyImplicits, unapplyPatterns), ownType)
unapp.println(s"unapply patterns = $unapplyPatterns")
- if ((ownType eq pt) || ownType.isError) result
+ if ((ownType eq selType) || ownType.isError) result
else Typed(result, TypeTree(ownType))
case tp =>
val unapplyErr = if (tp.isError) unapplyFn else notAnExtractor(unapplyFn)
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 1823b09fa..7b8fe3727 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1050,8 +1050,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
typed(tree, pt)(ctx retractMode Mode.PatternOrType)
def typedType(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = // todo: retract mode between Type and Pattern?
typed(tree, pt)(ctx addMode Mode.Type)
- def typedPattern(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree =
- typed(tree, pt)(ctx addMode Mode.Pattern)
+ def typedPattern(tree: untpd.Tree, selType: Type = WildcardType)(implicit ctx: Context): Tree =
+ typed(tree, selType)(ctx addMode Mode.Pattern)
def tryEither[T](op: Context => T)(fallBack: (T, TyperState) => T)(implicit ctx: Context) = {
val nestedCtx = ctx.fresh.setNewTyperState