forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scala#4863: support @compileTimeOnly
- Loading branch information
1 parent
25a3773
commit 35c01fe
Showing
6 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import scala.annotation.compileTimeOnly | ||
|
||
sealed trait Nat | ||
case class S(n: Nat) extends Nat | ||
case object Z extends Nat | ||
|
||
inline def pred(n: Nat) = inline n match { | ||
case S(m) => m | ||
case Z => | ||
@compileTimeOnly("n cannot be Z") val res = ??? | ||
res | ||
} | ||
|
||
class Test { | ||
pred(Z) // error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import scala.annotation.compileTimeOnly | ||
|
||
sealed trait Nat | ||
case class S(n: Nat) extends Nat | ||
case object Z extends Nat | ||
|
||
inline def pred(n: Nat) = inline n match { | ||
case S(m) => m | ||
case Z => | ||
@compileTimeOnly("n cannot be Z") val res = ??? | ||
res | ||
} | ||
|
||
class Test { | ||
pred(S(Z)) | ||
} |