diff options
author | Martin Odersky <odersky@gmail.com> | 2014-03-10 22:06:13 +0100 |
---|---|---|
committer | Tobias Schlatter <tobias@meisch.ch> | 2014-03-20 20:25:05 +0100 |
commit | 3ba0931636a5d34ca2da9588f2952af709d41ace (patch) | |
tree | cc80be514102bca1203cc6a83a8fd62c7e0ae6c8 /src/dotty/tools/dotc/typer/Typer.scala | |
parent | ce466da9fd5b2601c91e351fd1d288099ec380b2 (diff) | |
download | dotty-3ba0931636a5d34ca2da9588f2952af709d41ace.tar.gz dotty-3ba0931636a5d34ca2da9588f2952af709d41ace.tar.bz2 dotty-3ba0931636a5d34ca2da9588f2952af709d41ace.zip |
New scheme for TypeTrees that refer to others
Adds a new scheme by which a TypeTree() can refer for its type to the symbol of some other type.
Applies the scheme to setter parameters, replacing the previous ad-hoc solution.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index f961a4544..32e847757 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -635,11 +635,27 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit } def typedTypeTree(tree: untpd.TypeTree, pt: Type)(implicit ctx: Context): TypeTree = track("typedTypeTree") { - val original1 = typed(tree.original) - val ownType = - if (original1.isEmpty) { assert(isFullyDefined(pt, ForceDegree.none)); pt } - else original1.tpe - cpy.TypeTree(tree, original1) withType ownType + if (tree.original.isEmpty) { + def symbol = tree.attachment(desugar.OriginalSymbol) + // 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. + val ownType = tree.original match { + case untpd.EmptyTree => + assert(isFullyDefined(pt, ForceDegree.none)) + pt + case desugar.TypeRefOfSym => + symbol.typeRef + case desugar.InfoOfSym => + symbol.info.resultType + } + cpy.TypeTree(tree, untpd.EmptyTree).withType(ownType) + } + else { + val original1 = typed(tree.original) + cpy.TypeTree(tree, original1).withType(original1.tpe) + } } def typedSingletonTypeTree(tree: untpd.SingletonTypeTree)(implicit ctx: Context): SingletonTypeTree = track("typedSingletonTypeTree") { |