resetallattrs | missing compatibility library for reflection in Scala | Reflection library

 by   scalamacros Scala Version: Current License: BSD-3-Clause

kandi X-RAY | resetallattrs Summary

kandi X-RAY | resetallattrs Summary

resetallattrs is a Scala library typically used in Programming Style, Reflection applications. resetallattrs has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

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.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              resetallattrs has a low active ecosystem.
              It has 9 star(s) with 0 fork(s). There are 5 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 1 open issues and 5 have been closed. On average issues are closed in 20 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of resetallattrs is current.

            kandi-Quality Quality

              resetallattrs has 0 bugs and 0 code smells.

            kandi-Security Security

              resetallattrs has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              resetallattrs code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              resetallattrs is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              resetallattrs releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of resetallattrs
            Get all kandi verified functions for this library.

            resetallattrs Key Features

            No Key Features are available at this moment for resetallattrs.

            resetallattrs Examples and Code Snippets

            No Code Snippets are available at this moment for resetallattrs.

            Community Discussions

            QUESTION

            How to remove all inferred implicits in a macro?
            Asked 2017-Jan-14 at 05:55

            I need to really untypecheck the trees that are emitted by my macro. That means not only removing inferred types and all that, but also removing the implicit arguments that are inferred by the compiler. Not even resetAllAttrs seems to take care of that.

            Symbols appear to have a method isSynthetic that indicates whether code was generated by the compiler, but apparently that flag is only set for things like autogenerated getters and setters, not for implicit values that the compiler inserts.

            I could of course manually look for all implicit argument lists and remove them, but then I will also remove the ones that were explicitly provided by the user of my macro.

            So ideally for the following code

            ...

            ANSWER

            Answered 2017-Jan-14 at 05:55

            They have internal API to detect the implicitly supplied args, but it is commented as unstable. (They'll use a tree attachment instead of a subtype of Apply.)

            Source https://stackoverflow.com/questions/41645172

            QUESTION

            How to use Scala macros to create new partial functions or transform them?
            Asked 2017-Jan-09 at 13:05

            I am having trouble writing a macro that transforms a given partial function and creates a new partial function. For instance, I want to be able to decompose the given partial function into its elements - pattern binder, guard condition, and body; then I want to decompose the pattern binder and the guard condition into smaller pieces and reassemble new partial functions out of these pieces. However, I am getting strange errors at macro expansion that I can't debug.

            The simplest problem that gives the same error is the code that decomposes the given partial function into the binder, the guard, and the body, and reassembles it back into the same partial function.

            I can do this with a simple type PartialFunction[Int,Any] but not with types that involve case classes, PartialFunction[MyCaseClass,Any].

            Here is the code that works and the code that doesn't.

            Working code: take a partial function, destructure it using quasiquotes, assemble the same function again, and return it.

            ...

            ANSWER

            Answered 2017-Jan-09 at 13:05

            I believe you're hitting a long standing issue in the Scala compiler. Typechecking is not idempotent in several cases, specifically extractors using unapply: SI-5465. There is no easy solution for this, but I can suggest two workarounds. Let me first explain the problem briefly.

            The problem with def macros and typechecking

            Def macros are expanded during the typechecking phase. As a consequence arguments to def macros are typed trees. Returning a well-typed or untyped tree is acceptable. However, returning a partially typed (your case) or ill-typed tree is very likely to trip the compiler, causing a typechecking error at best or an error in a subsequent phase. Note that quasiquotes generate untyped trees. How can these bad trees occur?

            • Partially typed trees - usually by wrapping untyped code around the typed arguments or replacing parts of them with untyped code. In many cases you can get away with those, but not always.
            • Ill-typed trees - by rearranging the typed arguments in a way that invalidates the original type information, e.g. splicing one argument into another. These will surely cause a problem.
            Workarounds

            Hopefully you can see that the problem is conceptual and deeply rooted. But you can take one of two approaches to solve the problem:

            1. The hacky solution - do a roundtrip through a String representation of the final result:

            Source https://stackoverflow.com/questions/41539029

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install resetallattrs

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/scalamacros/resetallattrs.git

          • CLI

            gh repo clone scalamacros/resetallattrs

          • sshUrl

            git@github.com:scalamacros/resetallattrs.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Reflection Libraries

            object-reflector

            by sebastianbergmann

            cglib

            by cglib

            reflection

            by doctrine

            avo

            by mmcloughlin

            rttr

            by rttrorg

            Try Top Libraries by scalamacros

            paradise

            by scalamacrosScala

            sbt-example

            by scalamacrosScala

            sbt-example-paradise

            by scalamacrosScala

            sbt-example-newstyle

            by scalamacrosScala

            maven-example

            by scalamacrosScala