File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
compiler/src/dotty/tools/dotc/inlines Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 1+ Subproject commit 8e4a40588491608aa40099f79c881d54a5094e75
Original file line number Diff line number Diff line change @@ -1047,11 +1047,18 @@ class Inliner(val call: tpd.Tree)(using Context):
10471047 reduceInlineMatchExpr(sel)
10481048 }
10491049
1050+ private def shouldStripAscription (tree : Typed )(using Context ): Boolean =
1051+ val exprTp = tree.expr.tpe
1052+ tree.hasAttachment(PrepareInlineable .InlineResultAscription )
1053+ && exprTp.exists
1054+ && ! exprTp.widen.isRef(defn.NothingClass )
1055+ && ! exprTp.widen.isRef(defn.NullClass )
1056+ && (exprTp frozen_<:< tree.tpe)
1057+
10501058 override def typedTyped (tree : untpd.Typed , pt : Type )(using Context ): Tree =
1051- if tree.hasAttachment(PrepareInlineable .InlineResultAscription ) then
1052- typedExpr(tree.expr, pt)
1053- else
1054- super .typedTyped(tree, pt)
1059+ super .typedTyped(tree, pt) match
1060+ case typedTree : Typed if shouldStripAscription(typedTree) => typedTree.expr
1061+ case typedTree => typedTree
10551062
10561063 override def newLikeThis (nestingLevel : Int ): Typer = new InlineTyper (initialErrorCount, nestingLevel)
10571064
You can’t perform that action at this time.
0 commit comments