@@ -5,6 +5,7 @@ import core._
5
5
import Contexts ._
6
6
import Types ._
7
7
import Symbols ._
8
+ import StdNames ._
8
9
import Decorators ._
9
10
import typer .ProtoTypes ._
10
11
import ast .{tpd , untpd }
@@ -24,17 +25,20 @@ import config.Printers.typr
24
25
class ReTyper extends Typer {
25
26
import tpd ._
26
27
28
+ private def assertTyped (tree : untpd.Tree )(implicit ctx : Context ): Unit =
29
+ assert(tree.hasType, i " $tree ${tree.getClass} ${tree.uniqueId}" )
30
+
27
31
/** Checks that the given tree has been typed */
28
32
protected def promote (tree : untpd.Tree )(implicit ctx : Context ): tree.ThisTree [Type ] = {
29
- assert (tree.hasType, i " $tree ${tree.getClass} ${tree.uniqueId} " )
33
+ assertTyped (tree)
30
34
tree.withType(tree.typeOpt)
31
35
}
32
36
33
37
override def typedIdent (tree : untpd.Ident , pt : Type )(implicit ctx : Context ): Tree =
34
38
promote(tree)
35
39
36
40
override def typedSelect (tree : untpd.Select , pt : Type )(implicit ctx : Context ): Tree = {
37
- assert(tree.hasType, tree)
41
+ assertTyped( tree)
38
42
val qual1 = typed(tree.qualifier, AnySelectionProto )
39
43
untpd.cpy.Select (tree)(qual1, tree.name).withType(tree.typeOpt)
40
44
}
@@ -48,11 +52,22 @@ class ReTyper extends Typer {
48
52
override def typedSuper (tree : untpd.Super , pt : Type )(implicit ctx : Context ): Tree =
49
53
promote(tree)
50
54
55
+ override def typedTyped (tree : untpd.Typed , pt : Type )(implicit ctx : Context ): Tree = {
56
+ assertTyped(tree)
57
+ val type1 = checkSimpleKinded(typedType(tree.tpt))
58
+ val tree1 = tree.expr match {
59
+ case id : untpd.Ident if (ctx.mode is Mode .Pattern ) && untpd.isVarPattern(id) && (id.name == nme.WILDCARD || id.name == nme.WILDCARD_STAR ) =>
60
+ tree.expr.withType(type1.tpe)
61
+ case _ => typed(tree.expr)
62
+ }
63
+ untpd.cpy.Typed (tree)(tree1, type1).withType(tree.typeOpt)
64
+ }
65
+
51
66
override def typedTypeTree (tree : untpd.TypeTree , pt : Type )(implicit ctx : Context ): TypeTree =
52
67
promote(tree)
53
68
54
69
override def typedBind (tree : untpd.Bind , pt : Type )(implicit ctx : Context ): Bind = {
55
- assert (tree.hasType )
70
+ assertTyped (tree)
56
71
val body1 = typed(tree.body, pt)
57
72
untpd.cpy.Bind (tree)(tree.name, body1).withType(tree.typeOpt)
58
73
}
@@ -64,6 +79,10 @@ class ReTyper extends Typer {
64
79
untpd.cpy.UnApply (tree)(fun1, implicits1, patterns1).withType(tree.tpe)
65
80
}
66
81
82
+ override def typedUnApply (tree : untpd.Apply , selType : Type )(implicit ctx : Context ): Tree = {
83
+ typedApply(tree, selType)
84
+ }
85
+
67
86
override def localDummy (cls : ClassSymbol , impl : untpd.Template )(implicit ctx : Context ) = impl.symbol
68
87
69
88
override def retrieveSym (tree : untpd.Tree )(implicit ctx : Context ): Symbol = tree.symbol
0 commit comments