@@ -1694,16 +1694,18 @@ trait Applications extends Compatibility {
16941694 def typedUnApply (tree : untpd.UnApply , selType : Type )(using Context ): UnApply =
16951695 throw new UnsupportedOperationException (" cannot type check an UnApply node" )
16961696
1697- def typedAppliedConstructorType (tree : untpd.Apply )(using Context ) =
1698- val Select (New (tpt), _) = tree.fun: @ unchecked // Always wrapped in `New`, see `simpleType` in `Parsers`
1699- val tree1 = typedExpr(tree)
1700- val widenSkolemsMap = new TypeMap :
1701- def apply (tp : Type ) = mapOver(tp.widenSkolem)
1702- val preciseTp = widenSkolemsMap(tree1.tpe)
1703- val classTp = typedType(tpt).tpe
1704- if ! preciseTp.isError && (preciseTp frozen_=:= classTp) then
1705- report.warning(PointlessAppliedConstructorType (tpt, tree.args, classTp), tree.srcPos)
1706- TypeTree (preciseTp)
1697+ def typedAppliedConstructorType (tree : untpd.Apply )(using Context ) = tree.fun match
1698+ case Select (New (tpt), _) =>
1699+ val tree1 = typedExpr(tree)
1700+ val widenSkolemsMap = new TypeMap :
1701+ def apply (tp : Type ) = mapOver(tp.widenSkolem)
1702+ val preciseTp = widenSkolemsMap(tree1.tpe)
1703+ val classTp = typedType(tpt).tpe
1704+ if ! preciseTp.isError && (preciseTp frozen_=:= classTp) then
1705+ report.warning(PointlessAppliedConstructorType (tpt, tree.args, classTp), tree.srcPos)
1706+ TypeTree (preciseTp)
1707+ case _ =>
1708+ throw TypeError (em " Unexpected applied constructor type: $tree" )
17071709
17081710 /** Is given method reference applicable to argument trees `args`?
17091711 * @param resultType The expected result type of the application
0 commit comments