aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-07 21:45:47 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-07 21:45:47 +0100
commit0067358e702ba7995e534a2272c569c4e2e4e80a (patch)
treea18f7937da6bb43c3ebf0c4164cc4bfc1e3443ad /src/dotty/tools/dotc/typer/Typer.scala
parent394c0a7439820fc18665be182fa9839b41d28164 (diff)
downloaddotty-0067358e702ba7995e534a2272c569c4e2e4e80a.tar.gz
dotty-0067358e702ba7995e534a2272c569c4e2e4e80a.tar.bz2
dotty-0067358e702ba7995e534a2272c569c4e2e4e80a.zip
Fixes to type-checking (_: T)
Also, widening before computing an annotated type.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index fd97c2c22..968d385b0 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -396,18 +396,25 @@ class Typer extends Namer with Applications with Implicits {
}
def typedTyped(tree: untpd.Typed, pt: Type)(implicit ctx: Context): Tree = track("typedTyped") {
+ def regularTyped(isWildcard: Boolean) = {
+ val tpt1 = typedType(tree.tpt)
+ val expr1 =
+ if (isWildcard) tree.expr withType tpt1.tpe
+ else typedExpr(tree.expr, tpt1.tpe)
+ cpy.Typed(tree, expr1, tpt1).withType(tpt1.tpe)
+ }
tree.expr match {
- case id: Ident if (ctx.mode is Mode.Pattern) && isVarPattern(id) && id.name != nme.WILDCARD =>
- import untpd._
- typed(Bind(id.name, Typed(Ident(nme.WILDCARD), tree.tpt)).withPos(id.pos))
+ case id: Ident if (ctx.mode is Mode.Pattern) && isVarPattern(id) =>
+ if (id.name == nme.WILDCARD) regularTyped(isWildcard = true)
+ else {
+ import untpd._
+ typed(Bind(id.name, Typed(Ident(nme.WILDCARD), tree.tpt)).withPos(id.pos))
+ }
case _ =>
if (untpd.isWildcardStarArg(tree))
seqToRepeated(typedExpr(tree.expr, defn.SeqType))
- else {
- val tpt1 = typedType(tree.tpt)
- val expr1 = typedExpr(tree.expr, tpt1.tpe)
- cpy.Typed(tree, expr1, tpt1).withType(tpt1.tpe)
- }
+ else
+ regularTyped(isWildcard = false)
}
}
@@ -767,7 +774,8 @@ class Typer extends Namer with Applications with Implicits {
def typedAnnotated(tree: untpd.Annotated, pt: Type)(implicit ctx: Context): Tree = track("typedAnnotated") {
val annot1 = typed(tree.annot, defn.AnnotationClass.typeRef)
val arg1 = typed(tree.arg, pt)
- val ownType = AnnotatedType(Annotation(annot1), arg1.tpe)
+ val underlyingType = if (arg1.isTerm) arg1.tpe.widen else arg1.tpe
+ val ownType = AnnotatedType(Annotation(annot1), underlyingType)
if (ctx.mode is Mode.Type)
cpy.Annotated(tree, annot1, arg1) withType ownType
else