Skip to content

Add missing compileTimeOnly annotations #7930

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 2 commits into from
Jan 8, 2020
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ class Definitions {
@tu lazy val LiftableModule_CharIsLiftable: Symbol = LiftableModule.requiredMethod("CharIsLiftable")
@tu lazy val LiftableModule_StringIsLiftable: Symbol = LiftableModule.requiredMethod("StringIsLiftable")

@tu lazy val InternalQuotedModule: Symbol = ctx.requiredModule("scala.internal.Quoted")
@tu lazy val InternalQuotedModule: Symbol = ctx.requiredModule("scala.internal.quoted.CompileTime")
@tu lazy val InternalQuoted_exprQuote : Symbol = InternalQuotedModule.requiredMethod("exprQuote")
@tu lazy val InternalQuoted_exprSplice : Symbol = InternalQuotedModule.requiredMethod("exprSplice")
@tu lazy val InternalQuoted_typeQuote : Symbol = InternalQuotedModule.requiredMethod("typeQuote")
Expand Down
7 changes: 6 additions & 1 deletion library/src/scala/internal/Quoted.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// TODO remove when reference compiler is updated
package scala.internal

import scala.annotation.{Annotation, compileTimeOnly}
import scala.quoted._

@compileTimeOnly("Illegal reference to `scala.internal.Quoted`")
@deprecated("Use scala.internal.quoted.CompileTime", "0.22.0")
object Quoted {

/** A term quote is desugared by the compiler into a call to this method */
Expand All @@ -26,9 +29,11 @@ object Quoted {
class patternBindHole extends Annotation

/** A splice of a name in a quoted pattern is that marks the definition of a type splice */
@compileTimeOnly("Illegal reference to `scala.internal.Quoted.patternType`")
class patternType extends Annotation

/** A type pattern that must be aproximated from above */
@compileTimeOnly("Illegal reference to `scala.internal.Quoted.fromAbove`")
class fromAbove extends Annotation

/** Artifact of pickled type splices
Expand All @@ -39,7 +44,7 @@ object Quoted {
*
* See ReifyQuotes.scala and PickledQuotes.scala
*/
@compileTimeOnly("Illegal reference to `scala.internal.Quoted.patternBindHole`")
@compileTimeOnly("Illegal reference to `scala.internal.Quoted.quoteTypeTag`")
class quoteTypeTag extends Annotation

}
48 changes: 48 additions & 0 deletions library/src/scala/internal/quoted/CompileTime.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package scala.internal.quoted

import scala.annotation.{Annotation, compileTimeOnly}
import scala.quoted._

@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime`")
object CompileTime {

/** A term quote is desugared by the compiler into a call to this method */
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.exprQuote`")
def exprQuote[T](x: T): (given QuoteContext) => Expr[T] = ???

/** A term splice is desugared by the compiler into a call to this method */
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.exprSplice`")
def exprSplice[T](x: (given QuoteContext) => Expr[T]): T = ???

/** A type quote is desugared by the compiler into a call to this method */
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.typeQuote`")
def typeQuote[T <: AnyKind]: Type[T] = ???

/** A splice in a quoted pattern is desugared by the compiler into a call to this method */
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.patternHole`")
def patternHole[T]: T = ???

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

/** A splice of a name in a quoted pattern is that marks the definition of a type splice */
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.patternType`")
class patternType extends Annotation

/** A type pattern that must be aproximated from above */
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.fromAbove`")
class fromAbove extends Annotation

/** Artifact of pickled type splices
*
* During quote reification a quote `'{ ... F[$t] ... }` will be transformed into
* `'{ @quoteTypeTag type T$1 = $t ... F[T$1] ... }` to have a tree for `$t`.
* This artifact is removed during quote unpickling.
*
* See ReifyQuotes.scala and PickledQuotes.scala
*/
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.quoteTypeTag`")
class quoteTypeTag extends Annotation

}
Loading