Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix problem when erasing erased context functions
  • Loading branch information
odersky committed Mar 17, 2021
commit 513e95d0083cde3fbcf207cc66aeef3ab57ac4e4
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/Erasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,9 @@ object Erasure {
case closureDef(meth) =>
val contextParams = meth.termParamss.head
for param <- contextParams do
param.symbol.copySymDenotation(owner = sym).installAfter(erasurePhase)
vparams ++= contextParams
if !param.symbol.is(Flags.Erased) then
param.symbol.copySymDenotation(owner = sym).installAfter(erasurePhase)
vparams = vparams :+ param
if crCount == 1 then meth.rhs.changeOwnerAfter(meth.symbol, sym, erasurePhase)
else skipContextClosures(meth.rhs, crCount - 1)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scala.annotation
package internal

/** An annotation that's aitomatically added for methods
/** An annotation that's automatically added for methods
* that have one or more nested context closures as their right hand side.
* The parameter `n` is an Int Literal that tells how many nested closures
* there are.
Expand Down
11 changes: 11 additions & 0 deletions tests/pos/CanThrow.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package canThrowStrawman
import language.experimental.erasedTerms

class CanThrow[E <: Throwable]

infix type throws1[R, E <: Throwable] = (erased CanThrow[E]) ?=> R

class Fail extends Exception

def foo(x: Boolean): Int throws1 Fail =
if x then 1 else throw Fail()