Skip to content

Commit 62990d9

Browse files
Apply suggestions from code review
Co-authored-by: Eugene Flesselle <[email protected]>
1 parent c43b83d commit 62990d9

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

compiler/src/dotty/tools/dotc/inlines/InlineReducer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class InlineReducer(inliner: Inliner)(using Context):
176176

177177
/** Adjust internaly generated value definitions;
178178
* - If the RHS refers to an erased symbol, mark the val as erased
179-
* - If the RHS refers to an erased symbol, mark the val as unsuable
179+
* - If the RHS refers to an unusable symbol, mark the val as unusable
180180
*/
181181
def adjustErased(sym: TermSymbol, rhs: Tree): Unit =
182182
rhs.foreachSubTree:

docs/_docs/reference/experimental/erased-defs-spec.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ nightlyOf: https://docs.scala-lang.org/scala3/reference/experimental/erased-defs
88

99
1. `erased` is a soft modifier. It can appear in a `val` definition or in a parameter.
1010

11-
2. A reference to an `erased` value can only be used
12-
* Inside the expression of argument to an `erased` parameter
13-
* Inside the body of an `erased` `val` or `def`
11+
2. A reference to an `erased` value can only be used in an *erased context*:
12+
* Inside the expression of an argument to an `erased` parameter
13+
* Inside the body of an `erased` `val`
14+
* Inside the path of a dependent type expression
1415

1516
3. `erased` can also be used in a function type, e.g.
1617

@@ -25,7 +26,7 @@ nightlyOf: https://docs.scala-lang.org/scala3/reference/experimental/erased-defs
2526

2627
5. Erasure semantics
2728
* All `erased` parameters are removed from the function
28-
* All argument to `erased` parameters are not passed to the function
29+
* All arguments to `erased` parameters are not passed to the function
2930
* All `erased` value definitions are removed
3031
* All `erased` argument types are removed from a function type
3132

tests/neg/i23406.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ inline def problem[T]: String =
1313
inline def ok[T]: String =
1414
inline compiletime.erasedValue[T] match
1515
case x: String => "hi"
16+
inline def alsoOk[T](erased x: T): String =
17+
inline x match
18+
case x: String => "hi again"
1619

1720
def Test =
1821
funny[String] // error
1922
problem[String] // error
20-
ok[String]
23+
ok[String]
24+
alsoOk[String](compiletime.erasedValue)

tests/neg/magic-canthrow.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class CanThrow[-E <: Exception]
55

66
def foo[E <: Exception](e: E)(using erased CanThrow[E]): Nothing = throw e
77

8-
erased def magic[E]: E = magic // error
8+
inline def magic[E]: E = magic
99

10-
def Test = foo(new IOException)(using magic)
10+
def Test = foo(new IOException)(using magic) // error
1111

tests/pos/erased-conforms.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class <::<[-From, +To] extends ErasedTerm
55

66
class =::=[From, To] extends (From <::< To)
77

8-
inline given [X] => (X =::= X) = scala.caps.unsafe.unsafeErasedValue
8+
inline given [X] => (X =::= X) = new =::=
99

1010
extension [From](x: From)
1111
inline def cast[To](using From <::< To): To = x.asInstanceOf[To] // Safe cast because we know `From <:< To`

tests/pos/phantom-Evidence.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ object WithNormalState {
2727

2828
object Utils {
2929
type =::=[From, To]
30-
inline given tpEquals: [A] => (A =::= A) = caps.unsafe.unsafeErasedValue
30+
inline given tpEquals: [A] => (A =::= A) = compiletime.erasedValue
3131
}

0 commit comments

Comments
 (0)