aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/ProtoTypes.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-08-21 12:54:22 +0200
committerMartin Odersky <odersky@gmail.com>2016-08-21 15:19:27 +0200
commitba663f7b9f2d62f08d73133dab26d978d6a4ecb7 (patch)
tree40f5271554620ae60a8b4e3042cb521d1a6c87b6 /src/dotty/tools/dotc/typer/ProtoTypes.scala
parentb3a169af0b3f33d83bbf6ce15971d2c047b036de (diff)
downloaddotty-ba663f7b9f2d62f08d73133dab26d978d6a4ecb7.tar.gz
dotty-ba663f7b9f2d62f08d73133dab26d978d6a4ecb7.tar.bz2
dotty-ba663f7b9f2d62f08d73133dab26d978d6a4ecb7.zip
Address reviewers comments.
Diffstat (limited to 'src/dotty/tools/dotc/typer/ProtoTypes.scala')
-rw-r--r--src/dotty/tools/dotc/typer/ProtoTypes.scala34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/dotty/tools/dotc/typer/ProtoTypes.scala b/src/dotty/tools/dotc/typer/ProtoTypes.scala
index 4e2134c6a..f209c99be 100644
--- a/src/dotty/tools/dotc/typer/ProtoTypes.scala
+++ b/src/dotty/tools/dotc/typer/ProtoTypes.scala
@@ -182,20 +182,6 @@ object ProtoTypes {
if ((args eq this.args) && (resultType eq this.resultType) && (typer eq this.typer)) this
else new FunProto(args, resultType, typer)
- def argsAreTyped: Boolean = myTypedArgs.size == args.length
-
- private def typedArg(arg: untpd.Tree, typerFn: untpd.Tree => Tree)(implicit ctx: Context): Tree = {
- var targ = myTypedArg(arg)
- if (targ == null) {
- targ = typerFn(arg)
- if (!ctx.reporter.hasPending) {
- myTypedArg = myTypedArg.updated(arg, targ)
- evalState = evalState.updated(arg, ctx.typerState)
- }
- }
- targ
- }
-
/** Forget the types of any arguments that have been typed producing a constraint in a
* typer state that is not yet committed into the one of the current context `ctx`.
* This is necessary to avoid "orphan" PolyParams that are referred to from
@@ -206,7 +192,7 @@ object ProtoTypes {
def allArgTypesAreCurrent()(implicit ctx: Context): Boolean = {
evalState foreachBinding { (arg, tstate) =>
if (tstate.uncommittedAncestor.constraint ne ctx.typerState.constraint) {
- println(i"need to invalidate $arg / ${myTypedArg(arg)}, ${tstate.constraint}, current = ${ctx.typerState.constraint}")
+ typr.println(i"need to invalidate $arg / ${myTypedArg(arg)}, ${tstate.constraint}, current = ${ctx.typerState.constraint}")
myTypedArg = myTypedArg.remove(arg)
evalState = evalState.remove(arg)
}
@@ -214,11 +200,24 @@ object ProtoTypes {
myTypedArg.size == args.length
}
+ private def cacheTypedArg(arg: untpd.Tree, typerFn: untpd.Tree => Tree)(implicit ctx: Context): Tree = {
+ var targ = myTypedArg(arg)
+ if (targ == null) {
+ targ = typerFn(arg)
+ if (!ctx.reporter.hasPending) {
+ myTypedArg = myTypedArg.updated(arg, targ)
+ evalState = evalState.updated(arg, ctx.typerState)
+ }
+ }
+ targ
+ }
+
/** The typed arguments. This takes any arguments already typed using
* `typedArg` into account.
*/
def typedArgs: List[Tree] = {
- if (!argsAreTyped) myTypedArgs = args.mapconserve(typedArg(_, typer.typed(_)))
+ if (myTypedArgs.size != args.length)
+ myTypedArgs = args.mapconserve(cacheTypedArg(_, typer.typed(_)))
myTypedArgs
}
@@ -226,7 +225,7 @@ object ProtoTypes {
* used to avoid repeated typings of trees when backtracking.
*/
def typedArg(arg: untpd.Tree, formal: Type)(implicit ctx: Context): Tree = {
- val targ = typedArg(arg, typer.typedUnadapted(_, formal))
+ val targ = cacheTypedArg(arg, typer.typedUnadapted(_, formal))
typer.adapt(targ, formal, arg)
}
@@ -262,7 +261,6 @@ object ProtoTypes {
*/
class FunProtoTyped(args: List[tpd.Tree], resultType: Type, typer: Typer)(implicit ctx: Context) extends FunProto(args, resultType, typer)(ctx) {
override def typedArgs = args
- override def argsAreTyped = true
}
/** A prototype for implicitly inferred views: