Skip to content

Commit b6fadd4

Browse files
committed
Add a typedUnApply method.
The method is needed to be able to survive ReTypers between frontend and pattern matching.
1 parent e7a4197 commit b6fadd4

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,16 @@ trait Applications extends Compatibility { self: Typer =>
763763
}
764764
}
765765

766+
/** A dummmy typed unapply, to make re-typers between frontend and pattern matcher
767+
* visit all subnodes of an unApply tree.
768+
*/
769+
def typedUnApply(tree: untpd.UnApply, selType: Type)(implicit ctx: Context) = {
770+
val unappType = typed(tree.fun)
771+
tree.implicits.foreach(typed(_))
772+
tree.patterns.foreach(typedPattern(_))
773+
tree.withType(selType)
774+
}
775+
766776
/** Is given method reference applicable to type arguments `targs` and argument trees `args`?
767777
* @param resultType The expected result type of the application
768778
*/

src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
10171017
case tree: untpd.PackageDef => typedPackageDef(tree)
10181018
case tree: untpd.Annotated => typedAnnotated(tree, pt)
10191019
case tree: untpd.TypedSplice => tree.tree
1020+
case tree: untpd.UnApply => typedUnApply(tree, pt)
10201021
case untpd.PostfixOp(tree, nme.WILDCARD) => typedAsFunction(tree, pt)
10211022
case untpd.EmptyTree => tpd.EmptyTree
10221023
case _ => typedUnadapted(desugar(tree), pt)

0 commit comments

Comments
 (0)