aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-01 14:02:32 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-01 14:10:20 +0100
commita5611f867c2b9e493d5f0497ddfb813b5daf347d (patch)
tree247e0111a0bd51311ce2caddcf4f8e119705354b /src/dotty/tools/dotc/typer/Typer.scala
parenta4395b48362b080dc4a896099d71ea90dc3b998c (diff)
downloaddotty-a5611f867c2b9e493d5f0497ddfb813b5daf347d.tar.gz
dotty-a5611f867c2b9e493d5f0497ddfb813b5daf347d.tar.bz2
dotty-a5611f867c2b9e493d5f0497ddfb813b5daf347d.zip
Reverting a change in `tpd` that would no longer be type-correct under dotty rules. (reverted from commit 50ab9f559ad36b916d24e733df3629994d239583)
We now admit `identity _` and, if the expected type is a function type, pass this type on to the function. If the expected type is not a function type, we pass on AnyFunctionProto.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index bb1d4dce1..b80f54458 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -872,6 +872,9 @@ class Typer extends Namer with Applications with Implicits {
cpy.Typed(tree, arg1, TypeTree(ownType)) withType ownType
}
+ def typedAsFunction(tree: untpd.Tree, pt: Type)(implicit ctx: Context): Tree =
+ typed(tree, if (defn.isFunctionType(pt)) pt else AnyFunctionProto)
+
def typedPackageDef(tree: untpd.PackageDef)(implicit ctx: Context): Tree = track("typedPackageDef") {
val pid1 = typedExpr(tree.pid, AnySelectionProto)
val pkg = pid1.symbol
@@ -947,7 +950,7 @@ class Typer extends Namer with Applications with Implicits {
case tree: untpd.PackageDef => typedPackageDef(tree)
case tree: untpd.Annotated => typedAnnotated(tree, pt)
case tree: untpd.TypedSplice => tree.tree
- case untpd.PostfixOp(tree, nme.WILDCARD) => typed(tree, AnyFunctionProto)
+ case untpd.PostfixOp(tree, nme.WILDCARD) => typedAsFunction(tree, pt)
case untpd.EmptyTree => tpd.EmptyTree
case _ => typedUnadapted(desugar(tree), pt)
}