@@ -842,7 +842,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
842
842
val proto2 = // the computed type of the `elemtpt` field
843
843
if (! tree.elemtpt.isEmpty) WildcardType
844
844
else if (isFullyDefined(proto1, ForceDegree .none)) proto1
845
- else if (tree.elems.isEmpty && tree.isInstanceOf [Trees .JavaSeqLiteral [_]])
845
+ else if (tree.elems.isEmpty && tree.isInstanceOf [Trees .JavaSeqLiteral [_]])
846
846
defn.ObjectType // generic empty Java varargs are of type Object[]
847
847
else ctx.typeComparer.lub(elems1.tpes)
848
848
val elemtpt1 = typed(tree.elemtpt, proto2)
@@ -961,13 +961,23 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
961
961
assignType(cpy.TypeBoundsTree (tree)(lo1, hi1), lo1, hi1)
962
962
}
963
963
964
- def typedBind (tree : untpd.Bind , pt : Type )(implicit ctx : Context ): Bind = track(" typedBind" ) {
964
+ def typedBind (tree : untpd.Bind , pt : Type )(implicit ctx : Context ): Tree = track(" typedBind" ) {
965
965
val pt1 = fullyDefinedType(pt, " pattern variable" , tree.pos)
966
966
val body1 = typed(tree.body, pt1)
967
967
typr.println(i " typed bind $tree pt = $pt1 bodytpe = ${body1.tpe}" )
968
- val flags = if (tree.isType) BindDefinedType else EmptyFlags
969
- val sym = ctx.newSymbol(ctx.owner, tree.name, flags, body1.tpe, coord = tree.pos)
970
- assignType(cpy.Bind (tree)(tree.name, body1), sym)
968
+ body1 match {
969
+ case UnApply (fn, Nil , arg :: Nil ) if tree.body.isInstanceOf [untpd.Typed ] =>
970
+ // A typed pattern `x @ (_: T)` with an implicit `ctag: ClassTag[T]`
971
+ // was rewritten to `x @ ctag(_)`.
972
+ // Rewrite further to `ctag(x @ _)`
973
+ assert(fn.symbol.owner == defn.ClassTagClass )
974
+ tpd.cpy.UnApply (body1)(fn, Nil ,
975
+ typed(untpd.Bind (tree.name, arg).withPos(tree.pos), arg.tpe) :: Nil )
976
+ case _ =>
977
+ val flags = if (tree.isType) BindDefinedType else EmptyFlags
978
+ val sym = ctx.newSymbol(ctx.owner, tree.name, flags, body1.tpe, coord = tree.pos)
979
+ assignType(cpy.Bind (tree)(tree.name, body1), sym)
980
+ }
971
981
}
972
982
973
983
def typedAlternative (tree : untpd.Alternative , pt : Type )(implicit ctx : Context ): Alternative = track(" typedAlternative" ) {
0 commit comments