diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-17 10:51:45 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-17 13:00:03 +0200 |
commit | f91f030290ac817888a6249d91118f42b560ab87 (patch) | |
tree | aff75c7376ece580e77e4a2a9276e7437f7f2b67 /src/dotty/tools/dotc/typer/Typer.scala | |
parent | 90aef309eaf72ab0c09494eb030c57789955bb21 (diff) | |
download | dotty-f91f030290ac817888a6249d91118f42b560ab87.tar.gz dotty-f91f030290ac817888a6249d91118f42b560ab87.tar.bz2 dotty-f91f030290ac817888a6249d91118f42b560ab87.zip |
Disabling adapt in TreeChecker
well-typed code should not need further adapations. That's why `adapt` is
replaced by a subtype assertion in TreeChecker.
Flushed out two instances where typechecking did not produce well-adapted trees -
one in typedClosure, the other manifested itself in typedSuper.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index cd9ddb0bd..7473e76f6 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -555,20 +555,23 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def typedClosure(tree: untpd.Closure, pt: Type)(implicit ctx: Context) = track("typedClosure") { val env1 = tree.env mapconserve (typed(_)) val meth1 = typedUnadapted(tree.meth) - val target = meth1.tpe.widen match { - case mt: MethodType => - pt match { - case SAMType(meth) if !defn.isFunctionType(pt) && mt <:< meth.info => - if (!isFullyDefined(pt, ForceDegree.all)) - ctx.error(d"result type of closure is an underspecified SAM type $pt", tree.pos) - TypeTree(pt) - case _ => - if (!mt.isDependent) EmptyTree - else throw new Error(i"internal error: cannot turn dependent method type $mt into closure, position = ${tree.pos}, raw type = ${mt.toString}") // !!! DEBUG. Eventually, convert to an error? + val target = + if (tree.tpt.isEmpty) + meth1.tpe.widen match { + case mt: MethodType => + pt match { + case SAMType(meth) if !defn.isFunctionType(pt) && mt <:< meth.info => + if (!isFullyDefined(pt, ForceDegree.all)) + ctx.error(d"result type of closure is an underspecified SAM type $pt", tree.pos) + TypeTree(pt) + case _ => + if (!mt.isDependent) EmptyTree + else throw new Error(i"internal error: cannot turn dependent method type $mt into closure, position = ${tree.pos}, raw type = ${mt.toString}") // !!! DEBUG. Eventually, convert to an error? + } + case tp => + throw new Error(i"internal error: closing over non-method $tp, pos = ${tree.pos}") } - case tp => - throw new Error(i"internal error: closing over non-method $tp, pos = ${tree.pos}") - } + else typed(tree.tpt) assignType(cpy.Closure(tree)(env1, meth1, target), meth1, target) } |