resetallattrs

The missing compatibility library for reflection in Scala 2.11/2.12 when c.untypecheck is not enough

License

License

Categories

Categories

Scala Languages
GroupId

GroupId

org.scalamacros
ArtifactId

ArtifactId

resetallattrs_2.12
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

resetallattrs
The missing compatibility library for reflection in Scala 2.11/2.12 when c.untypecheck is not enough
Project URL

Project URL

https://github.com/scalamacros/resetallattrs
Project Organization

Project Organization

org.scalamacros

Download resetallattrs_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/org.scalamacros/resetallattrs_2.12/ -->
<dependency>
    <groupId>org.scalamacros</groupId>
    <artifactId>resetallattrs_2.12</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.scalamacros/resetallattrs_2.12/
implementation 'org.scalamacros:resetallattrs_2.12:1.0.0'
// https://jarcasting.com/artifacts/org.scalamacros/resetallattrs_2.12/
implementation ("org.scalamacros:resetallattrs_2.12:1.0.0")
'org.scalamacros:resetallattrs_2.12:jar:1.0.0'
<dependency org="org.scalamacros" name="resetallattrs_2.12" rev="1.0.0">
  <artifact name="resetallattrs_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.scalamacros', module='resetallattrs_2.12', version='1.0.0')
)
libraryDependencies += "org.scalamacros" % "resetallattrs_2.12" % "1.0.0"
[org.scalamacros/resetallattrs_2.12 "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.0

provided (1)

Group / Artifact Type Version
org.scala-lang : scala-reflect jar 2.12.0

Project Modules

There are no modules declared in this project.

resetallattrs

In Scala 2.10, when macros were first introduced, our public API exposed two low-level methods: Context.resetLocalAttrs and Context.resetAllAttrs. While these methods wouldn't be needed at all if our internal implementation of the macro API were more advanced, at our past level of technology we needed them (and we still do) to deal with possible inconsistencies in partially synthetic trees.

Without going into details, experience has shown that resetLocalAttrs can deal with a majority of possible inconsistencies having a mild chance of corrupting trees as a side-effect of its operation, whereas resetAllAttrs can deal with some additional inconsistencies, but it's almost always guaranteed to corrupt trees. Go through our Macrology 201 tutorial to learn more about this topic.

Anyway, based on what we've learned about resetAttrs methods, in Scala 2.11.0 we removed resetAllAttrs and renamed resetLocalAttrs to untypecheck, branding resetLocalAttrs as the one and only public way of fixing inconsistencies in trees. When doing that, we expected that resetLocalAttrs should be enough for virtually everyone who previously used resetAllAttrs.

Unfortunately, that ended up being not the case and due to binary compatibility constraints we can't just reintroduce resetAllAttrs in 2.11.x (or even in 2.12.x, for that matter). So here we go, reinstating resetAllAttrs in a separate library for the cases when it's really necessary. Let's hope the necessity for resetAllAttrs won't last for long.

Usage

In your SBT build you need to write a one-liner:

libraryDependencies += "org.scalamacros" %% "resetallattrs" % "1.0.0"

Then in your macros you write another one-liner, and that enables you to use resetAllAttrs like in the good old days. Beware, all usual caveats apply. Please try untypecheck first, and only then reach for resetAllAttrs.

def impl(c: Context)(...) = {
  ...
  import org.scalamacros.resetallattrs._
  c.resetAllAttrs(...)
  ...
}
org.scalamacros

Versions

Version
1.0.0