We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d4cd2c0 commit 538b5ddCopy full SHA for 538b5dd
compiler/src/dotty/tools/dotc/transform/TreeExtractors.scala
@@ -19,11 +19,15 @@ object TreeExtractors {
19
}
20
21
22
- /** Match new C(args) and extract (C, args) */
+ /** Match new C(args) and extract (C, args).
23
+ * Also admit new C(args): T and {new C(args)}.
24
+ */
25
object NewWithArgs {
26
def unapply(t: Tree)(using Context): Option[(Type, List[Tree])] = t match {
27
case Apply(Select(New(_), nme.CONSTRUCTOR), args) =>
28
Some((t.tpe, args))
29
+ case Typed(expr, _) => unapply(expr)
30
+ case Block(Nil, expr) => unapply(expr)
31
case _ =>
32
None
33
0 commit comments