diff options
author | Martin Odersky <odersky@gmail.com> | 2014-03-12 15:06:17 +0100 |
---|---|---|
committer | Tobias Schlatter <tobias@meisch.ch> | 2014-03-20 20:25:05 +0100 |
commit | a4516eac1be98830c99ea48e9baedf022dfcb9f7 (patch) | |
tree | 8e0e62943160fb948bf338ace7b01bd0990ad2bc /src/dotty/tools/dotc/typer/Typer.scala | |
parent | 5b687fbee23060fbed285f090e3592f2b8cb6beb (diff) | |
download | dotty-a4516eac1be98830c99ea48e9baedf022dfcb9f7.tar.gz dotty-a4516eac1be98830c99ea48e9baedf022dfcb9f7.tar.bz2 dotty-a4516eac1be98830c99ea48e9baedf022dfcb9f7.zip |
Hygienic desugaring
Made desugaring hygienic. Trees that are derived from some other tree are no longer stored as simple
untyped Ident trees, but as TypeTrees that know how to derive their types from some other type.
Test cases in pos: hygiene.scala, t0054.scala and t0085.scala.
The comment in hygiene.scala points to the difficulties we are facing. In particular, we need type
trees that can rebind some references of a source type to local occurrences with the same name. t0054.scala is similar to hygiene.scala. t0085.scala is trickier, but also related. Essentially the problem there is that we have a class
that inherits its outer class. In this case it is important to resolve an identifier in the right context. The identifier added to the copy method of a case class must be resolved outside the class (just like the same
identifier in the constructor of that case class).
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index e9a79eeb1..67e5c5902 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -637,12 +637,19 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def typedTypeTree(tree: untpd.TypeTree, pt: Type)(implicit ctx: Context): TypeTree = track("typedTypeTree") { if (tree.original.isEmpty) tree match { - case tree: desugar.DerivedTypeTree => - TypeTree(tree.derivedType(tree.attachment(desugar.OriginalSymbol))) withPos tree.pos - // btw, no need to remove the attachment. The typed - // tree is different from the untyped one, so the - // untyped tree is no longer accessed after all - // accesses with typedTypeTree are done. + case tree: untpd.DerivedTypeTree => + tree.ensureCompletions + try + TypeTree(tree.derivedType(tree.attachment(untpd.OriginalSymbol))) withPos tree.pos + // btw, no need to remove the attachment. The typed + // tree is different from the untyped one, so the + // untyped tree is no longer accessed after all + // accesses with typedTypeTree are done. + catch { + case ex: NoSuchElementException => + println(s"missing OriginalSymbol for ${ctx.owner.ownersIterator.toList}") + throw ex + } case _ => assert(isFullyDefined(pt, ForceDegree.none)) tree.withType(pt) |