diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-01-30 10:01:31 +0300 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-14 23:51:22 +0100 |
commit | 2155ca4bba9de396bde32588e63736042178ca49 (patch) | |
tree | aecc2f712969d67e8d2931303205b8fa4725d658 /src/reflect/scala/reflect/macros/Universe.scala | |
parent | 114c99691674873393223a11a9aa9168c3f41d77 (diff) | |
download | scala-2155ca4bba9de396bde32588e63736042178ca49.tar.gz scala-2155ca4bba9de396bde32588e63736042178ca49.tar.bz2 scala-2155ca4bba9de396bde32588e63736042178ca49.zip |
reflection API compatibility with 2.10.x
This is just one of the possible strategies for compatibility with
reflection API of 2.10.x family. Here’s the discussion:
1) Do nothing.
Document the fact that we’ve organized internal APIs in a separate module
and let people figure out themselves.
Pros: no boilerplate on our side.
Cons: potential for confusion, major upfront migration effort.
2) (This commit). Introduce a compatibility pack with a manual import.
Compatibility pack lives in a separate module that has to be manually imported.
People will get compilation errors when trying to compile macros using
internal APIs against 2.11, but those will be quenched by a single
`import compat._` import. Compatibility stubs would still produce
deprecation warnings, but people can choose to ignore them to alleviate
migration costs.
Pros: brings attention of the users to the fact that they are using
internal APIs by providing a more powerful nudge than just deprecation.
Cons: even though migration effort is trivial, it is still non-zero.
3) Deprecate internal APIs in-place.
Pros: zero migration effort required.
Cons: those who ignore deprecations will be unaware about using internal APIs,
there will be some naming conflicts between Universe.xxxType and internal.xxxType
type factories.
Diffstat (limited to 'src/reflect/scala/reflect/macros/Universe.scala')
-rw-r--r-- | src/reflect/scala/reflect/macros/Universe.scala | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/macros/Universe.scala b/src/reflect/scala/reflect/macros/Universe.scala index 17eb17cee3..9840295c95 100644 --- a/src/reflect/scala/reflect/macros/Universe.scala +++ b/src/reflect/scala/reflect/macros/Universe.scala @@ -186,6 +186,115 @@ abstract class Universe extends scala.reflect.api.Universe { def mkRuntimeUniverseRef: Tree } + /** @see [[internal.gen]] */ + @deprecated("Use `internal.gen` instead", "2.11.0") + val treeBuild: TreeGen + + /** @inheritdoc */ + type Compat <: MacroCompatApi + + /** @see [[compat]] + * @group Internal + */ + trait MacroCompatApi extends CompatApi { + /** Scala 2.10 compatibility enrichments for Symbol. */ + implicit class MacroCompatibleSymbol(symbol: Symbol) { + /** @see [[InternalMacroApi.attachments]] */ + @deprecated("Use `internal.attachments` instead", "2.11.0") + def attachments: Attachments { type Pos = Position } = internal.attachments(symbol) + + /** @see [[InternalMacroApi.updateAttachment]] */ + @deprecated("Use `internal.updateAttachment` instead", "2.11.0") + def updateAttachment[T: ClassTag](attachment: T): Symbol = internal.updateAttachment[T](symbol, attachment) + + /** @see [[InternalMacroApi.removeAttachment]] */ + @deprecated("Use `internal.removeAttachment` instead", "2.11.0") + def removeAttachment[T: ClassTag]: Symbol = internal.removeAttachment[T](symbol) + + /** @see [[InternalMacroApi.pos]] */ + @deprecated("Use `internal.pos` instead", "2.11.0") + def pos: Position = internal.pos(symbol) + + /** @see [[InternalMacroApi.setTypeSignature]] */ + @deprecated("Use `internal.setTypeSignature` instead", "2.11.0") + def setTypeSignature(tpe: Type): Symbol = internal.setTypeSignature(symbol, tpe) + + /** @see [[InternalMacroApi.setAnnotations]] */ + @deprecated("Use `internal.setAnnotations` instead", "2.11.0") + def setAnnotations(annots: Annotation*): Symbol = internal.setAnnotations(symbol, annots: _*) + + /** @see [[InternalMacroApi.setName]] */ + @deprecated("Use `internal.setName` instead", "2.11.0") + def setName(name: Name): Symbol = internal.setName(symbol, name) + + /** @see [[InternalMacroApi.setPrivateWithin]] */ + @deprecated("Use `internal.setPrivateWithin` instead", "2.11.0") + def setPrivateWithin(sym: Symbol): Symbol = internal.setPrivateWithin(symbol, sym) + } + + /** Scala 2.10 compatibility enrichments for TypeTree. */ + implicit class MacroCompatibleTree(tree: Tree) { + /** @see [[InternalMacroApi.attachments]] */ + @deprecated("Use `internal.attachments` instead", "2.11.0") + def attachments: Attachments { type Pos = Position } = internal.attachments(tree) + + /** @see [[InternalMacroApi.updateAttachment]] */ + @deprecated("Use `internal.updateAttachment` instead", "2.11.0") + def updateAttachment[T: ClassTag](attachment: T): Tree = internal.updateAttachment[T](tree, attachment) + + /** @see [[InternalMacroApi.removeAttachment]] */ + @deprecated("Use `internal.removeAttachment` instead", "2.11.0") + def removeAttachment[T: ClassTag]: Tree = internal.removeAttachment[T](tree) + + /** @see [[InternalMacroApi.setPos]] */ + @deprecated("Use `internal.setPos` instead", "2.11.0") + def pos_=(pos: Position): Unit = internal.setPos(tree, pos) + + /** @see [[InternalMacroApi.setPos]] */ + @deprecated("Use `internal.setPos` instead", "2.11.0") + def setPos(newpos: Position): Tree = internal.setPos(tree, newpos) + + /** @see [[InternalMacroApi.setType]] */ + @deprecated("Use `internal.setType` instead", "2.11.0") + def tpe_=(t: Type): Unit = internal.setType(tree, t) + + /** @see [[InternalMacroApi.setType]] */ + @deprecated("Use `internal.setType` instead", "2.11.0") + def setType(tp: Type): Tree = internal.setType(tree, tp) + + /** @see [[InternalMacroApi.defineType]] */ + @deprecated("Use `internal.defineType` instead", "2.11.0") + def defineType(tp: Type): Tree = internal.defineType(tree, tp) + + /** @see [[InternalMacroApi.setSymbol]] */ + @deprecated("Use `internal.setSymbol` instead", "2.11.0") + def symbol_=(sym: Symbol): Unit = internal.setSymbol(tree, sym) + + /** @see [[InternalMacroApi.setSymbol]] */ + @deprecated("Use `internal.setSymbol` instead", "2.11.0") + def setSymbol(sym: Symbol): Tree = internal.setSymbol(tree, sym) + } + + /** Scala 2.10 compatibility enrichments for TypeTree. */ + implicit class CompatibleTypeTree(tt: TypeTree) { + /** @see [[InternalMacroApi.setOriginal]] */ + @deprecated("Use `internal.setOriginal` instead", "2.11.0") + def setOriginal(tree: Tree): TypeTree = internal.setOriginal(tt, tree) + } + + /** @see [[InternalMacroApi.captureVariable]] */ + @deprecated("Use `internal.captureVariable` instead", "2.11.0") + def captureVariable(vble: Symbol): Unit = internal.captureVariable(vble) + + /** @see [[InternalMacroApi.captureVariable]] */ + @deprecated("Use `internal.referenceCapturedVariable` instead", "2.11.0") + def referenceCapturedVariable(vble: Symbol): Tree = internal.referenceCapturedVariable(vble) + + /** @see [[InternalMacroApi.captureVariable]] */ + @deprecated("Use `internal.capturedVariableType` instead", "2.11.0") + def capturedVariableType(vble: Symbol): Type = internal.capturedVariableType(vble) + } + /** The type of compilation runs. * @see [[scala.reflect.macros.Enclosures]] * @template |