Skip to content

Commit 61f8c6b

Browse files
Merge pull request #6600 from dotty-staging/fail-fast-for-non-reified-quotes
Fail at compile time if quote is not reified
2 parents cc6cb05 + e0f6204 commit 61f8c6b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
package scala.internal
22

3-
import scala.annotation.Annotation
3+
import scala.annotation.{Annotation, compileTimeOnly}
44
import scala.quoted._
55

66
object Quoted {
77

88
/** A term quote is desugared by the compiler into a call to this method */
9-
def exprQuote[T](x: T): Expr[T] =
10-
throw new Error("Internal error: this method call should have been replaced by the compiler")
9+
@compileTimeOnly("Illegal reference to `scala.internal.Quoted.exprQuote`")
10+
def exprQuote[T](x: T): Expr[T] = ???
1111

1212
/** A term splice is desugared by the compiler into a call to this method */
13-
def exprSplice[T](x: Expr[T]): T =
14-
throw new Error("Internal error: this method call should have been replaced by the compiler")
13+
@compileTimeOnly("Illegal reference to `scala.internal.Quoted.exprSplice`")
14+
def exprSplice[T](x: Expr[T]): T = ???
1515

1616
/** A type quote is desugared by the compiler into a call to this method */
17-
def typeQuote[T <: AnyKind]: Type[T] =
18-
throw new Error("Internal error: this method call should have been replaced by the compiler")
17+
@compileTimeOnly("Illegal reference to `scala.internal.Quoted.typeQuote`")
18+
def typeQuote[T <: AnyKind]: Type[T] = ???
1919

2020
/** A splice in a quoted pattern is desugared by the compiler into a call to this method */
21-
def patternHole[T]: T =
22-
throw new Error("Internal error: this method call should have been replaced by the compiler")
21+
@compileTimeOnly("Illegal reference to `scala.internal.Quoted.patternHole`")
22+
def patternHole[T]: T = ???
2323

2424
/** A splice of a name in a quoted pattern is desugared by wrapping getting this annotation */
25+
@compileTimeOnly("Illegal reference to `scala.internal.Quoted.patternBindHole`")
2526
class patternBindHole extends Annotation
2627

2728
}

0 commit comments

Comments
 (0)