From a5611f867c2b9e493d5f0497ddfb813b5daf347d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 1 Jan 2014 14:02:32 +0100 Subject: 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. --- src/dotty/tools/dotc/typer/Typer.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') 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) } -- cgit v1.2.3