@@ -1715,16 +1715,18 @@ trait Applications extends Compatibility {
17151715 def typedUnApply (tree : untpd.UnApply , selType : Type )(using Context ): UnApply =
17161716 throw new UnsupportedOperationException (" cannot type check an UnApply node" )
17171717
1718- def typedAppliedConstructorType (tree : untpd.Apply )(using Context ) =
1719- val Select (New (tpt), _) = tree.fun: @ unchecked // Always wrapped in `New`, see `simpleType` in `Parsers`
1720- val tree1 = typedExpr(tree)
1721- val widenSkolemsMap = new TypeMap :
1722- def apply (tp : Type ) = mapOver(tp.widenSkolem)
1723- val preciseTp = widenSkolemsMap(tree1.tpe)
1724- val classTp = typedType(tpt).tpe
1725- if ! preciseTp.isError && (preciseTp frozen_=:= classTp) then
1726- report.warning(PointlessAppliedConstructorType (tpt, tree.args, classTp), tree.srcPos)
1727- TypeTree (preciseTp)
1718+ def typedAppliedConstructorType (tree : untpd.Apply )(using Context ) = tree.fun match
1719+ case Select (New (tpt), _) =>
1720+ val tree1 = typedExpr(tree)
1721+ val widenSkolemsMap = new TypeMap :
1722+ def apply (tp : Type ) = mapOver(tp.widenSkolem)
1723+ val preciseTp = widenSkolemsMap(tree1.tpe)
1724+ val classTp = typedType(tpt).tpe
1725+ if ! preciseTp.isError && (preciseTp frozen_=:= classTp) then
1726+ report.warning(PointlessAppliedConstructorType (tpt, tree.args, classTp), tree.srcPos)
1727+ TypeTree (preciseTp)
1728+ case _ =>
1729+ throw TypeError (em " Unexpected applied constructor type: $tree" )
17281730
17291731 /** Is given method reference applicable to argument trees `args`?
17301732 * @param resultType The expected result type of the application
0 commit comments