diff options
author | Martin Odersky <odersky@gmail.com> | 2016-12-17 18:14:15 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-12-17 18:14:15 +0100 |
commit | 0a07f7f3385e5cc65fe58db753d2781ecf14ec41 (patch) | |
tree | 7ca6b4df926eb0e1833949476d9e94f8698d06c2 /compiler/src/dotty/tools/dotc/typer/Namer.scala | |
parent | d69e8490dc66f98719fa1483e57d824c3a61f99c (diff) | |
download | dotty-0a07f7f3385e5cc65fe58db753d2781ecf14ec41.tar.gz dotty-0a07f7f3385e5cc65fe58db753d2781ecf14ec41.tar.bz2 dotty-0a07f7f3385e5cc65fe58db753d2781ecf14ec41.zip |
Infer type parameters of anonymous class parents from expected type
If a parent type of an anonymous class is an Ident or Select which refers
to a parameterized type, use the expected type to infer its type parameters.
Fixes #1803.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/Namer.scala | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 4bcdd5071..1b6e437b5 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -852,23 +852,23 @@ class Namer { typer: Typer => } } - /** Typecheck tree during completion, and remember result in typedtree map */ - private def typedAheadImpl(tree: Tree, pt: Type)(implicit ctx: Context): tpd.Tree = { + /** Typecheck `tree` during completion using `typed`, and remember result in TypedAhead map */ + def typedAheadImpl(tree: Tree, typed: untpd.Tree => tpd.Tree)(implicit ctx: Context): tpd.Tree = { val xtree = expanded(tree) xtree.getAttachment(TypedAhead) match { case Some(ttree) => ttree case none => - val ttree = typer.typed(tree, pt) + val ttree = typed(tree) xtree.putAttachment(TypedAhead, ttree) ttree } } def typedAheadType(tree: Tree, pt: Type = WildcardType)(implicit ctx: Context): tpd.Tree = - typedAheadImpl(tree, pt)(ctx retractMode Mode.PatternOrType addMode Mode.Type) + typedAheadImpl(tree, typer.typed(_, pt)(ctx retractMode Mode.PatternOrType addMode Mode.Type)) def typedAheadExpr(tree: Tree, pt: Type = WildcardType)(implicit ctx: Context): tpd.Tree = - typedAheadImpl(tree, pt)(ctx retractMode Mode.PatternOrType) + typedAheadImpl(tree, typer.typed(_, pt)(ctx retractMode Mode.PatternOrType)) def typedAheadAnnotation(tree: Tree)(implicit ctx: Context): Symbol = tree match { case Apply(fn, _) => typedAheadAnnotation(fn) |