Skip to content

Fix #7041: Drop Annotated type trees at erasure #7099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/Erasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ object Erasure {
case Block(_, tpt) => tpt // erase type aliases (statements) from type block
case tpt => tpt
}
val tpt2 = promote(tpt1)
val tpt2 = typedType(tpt1)
val expr1 = typed(expr, tpt2.tpe)
assignType(untpd.cpy.Typed(tree)(expr1, tpt2), tpt2)
}
Expand Down Expand Up @@ -736,6 +736,9 @@ object Erasure {
override def typedTypeDef(tdef: untpd.TypeDef, sym: Symbol)(implicit ctx: Context): Tree =
EmptyTree

override def typedAnnotated(tree: untpd.Annotated, pt: Type)(implicit ctx: Context): Tree =
typed(tree.arg, pt)

override def typedStats(stats: List[untpd.Tree], exprOwner: Symbol)(implicit ctx: Context): List[Tree] = {
val stats1 =
if (takesBridges(ctx.owner)) new Bridges(ctx.owner.asClass, erasurePhase).add(stats)
Expand Down
13 changes: 13 additions & 0 deletions tests/pos/i7041.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import scala.util.control.NonLocalReturns._

inline def (op: => T) rescue[T, E <: Throwable] (fallback: PartialFunction[E, T]) =
try op
catch {
case ex: ReturnThrowable[_] => throw ex
case ex: E =>
if (fallback.isDefinedAt(ex)) fallback(ex) else throw ex
}

def test: Unit = {
9 / 0 rescue { case _: ArithmeticException => 10 }
}