Skip to content
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

@ instance doesn't create by-name param #5

Open
DmytroMitin opened this issue Jul 21, 2019 · 0 comments
Open

@ instance doesn't create by-name param #5

DmytroMitin opened this issue Jul 21, 2019 · 0 comments
Labels
bug Something isn't working macros

Comments

@DmytroMitin
Copy link
Owner

DmytroMitin commented Jul 21, 2019

https://github.com/DmytroMitin/AUXify/blob/master/core/src/test/scala/com/github/dmytromitin/InstanceMonoidTest.scala

Warning:scalac: {
  abstract trait Monoid[A] extends scala.AnyRef {
    def empty: A;
    def combine(a: A, a1: A): A
  };
  object Monoid extends scala.AnyRef {
    def <init>() = {
      super.<init>();
      ()
    };
    def instance[A](f$macro$1: A, f$macro$2: _root_.scala.Function2[A, A, A]): Monoid[A] = {
      final class $anon extends Monoid[A] {
        def <init>() = {
          super.<init>();
          ()
        };
        override def empty: A = f$macro$1;
        override def combine(a: A, a1: A): A = f$macro$2(a, a1)
      };
      new $anon()
    };
    implicit val int: Monoid[Int] = instance(0, ((x$1, x$2) => x$1.$plus(x$2)));
    implicit val str: Monoid[String] = instance("", ((x$3, x$4) => x$3.$plus(x$4)))
  };
  ()
}
Block(List(ClassDef(Modifiers(ABSTRACT | INTERFACE | DEFAULTPARAM/TRAIT), TypeName("Monoid"), List(TypeDef(Modifiers(PARAM), TypeName("A"), List(), TypeBoundsTree(EmptyTree, EmptyTree))), Template(List(Select(Ident(scala), TypeName("AnyRef"))), noSelfType, List(DefDef(Modifiers(DEFERRED), TermName("empty"), List(), List(), Ident(TypeName("A")), EmptyTree), DefDef(Modifiers(DEFERRED), TermName("combine"), List(), List(List(ValDef(Modifiers(PARAM), TermName("a"), Ident(TypeName("A")), EmptyTree), ValDef(Modifiers(PARAM), TermName("a1"), Ident(TypeName("A")), EmptyTree))), Ident(TypeName("A")), EmptyTree)))), ModuleDef(Modifiers(), TermName("Monoid"), Template(List(Select(Ident(scala), TypeName("AnyRef"))), noSelfType, List(DefDef(Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))), DefDef(Modifiers(), TermName("instance"), List(TypeDef(Modifiers(PARAM), TypeName("A"), List(), TypeBoundsTree(EmptyTree, EmptyTree))), List(List(ValDef(Modifiers(PARAM), TermName("f$macro$1"), Ident(TypeName("A")), EmptyTree), ValDef(Modifiers(PARAM), TermName("f$macro$2"), AppliedTypeTree(Select(Select(Ident(termNames.ROOTPKG), scala), TypeName("Function2")), List(Ident(TypeName("A")), Ident(TypeName("A")), Ident(TypeName("A")))), EmptyTree))), CompoundTypeTree(Template(List(AppliedTypeTree(Ident(TypeName("Monoid")), List(Ident(TypeName("A"))))), noSelfType, List())), Block(List(ClassDef(Modifiers(FINAL), TypeName("$anon"), List(), Template(List(AppliedTypeTree(Ident(TypeName("Monoid")), List(Ident(TypeName("A"))))), noSelfType, List(DefDef(Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))), DefDef(Modifiers(OVERRIDE), TermName("empty"), List(), List(), Ident(TypeName("A")), Ident(TermName("f$macro$1"))), DefDef(Modifiers(OVERRIDE), TermName("combine"), List(), List(List(ValDef(Modifiers(PARAM), TermName("a"), Ident(TypeName("A")), EmptyTree), ValDef(Modifiers(PARAM), TermName("a1"), Ident(TypeName("A")), EmptyTree))), Ident(TypeName("A")), Apply(Ident(TermName("f$macro$2")), List(Ident(TermName("a")), Ident(TermName("a1"))))))))), Apply(Select(New(Ident(TypeName("$anon"))), termNames.CONSTRUCTOR), List()))), ValDef(Modifiers(IMPLICIT), TermName("int"), AppliedTypeTree(Ident(TypeName("Monoid")), List(Ident(TypeName("Int")))), Apply(Ident(TermName("instance")), List(Literal(Constant(0)), Function(List(ValDef(Modifiers(PARAM | SYNTHETIC), TermName("x$1"), TypeTree(), EmptyTree), ValDef(Modifiers(PARAM | SYNTHETIC), TermName("x$2"), TypeTree(), EmptyTree)), Apply(Select(Ident(TermName("x$1")), TermName("$plus")), List(Ident(TermName("x$2")))))))), ValDef(Modifiers(IMPLICIT), TermName("str"), AppliedTypeTree(Ident(TypeName("Monoid")), List(Ident(TypeName("String")))), Apply(Ident(TermName("instance")), List(Literal(Constant("")), Function(List(ValDef(Modifiers(PARAM | SYNTHETIC), TermName("x$3"), TypeTree(), EmptyTree), ValDef(Modifiers(PARAM | SYNTHETIC), TermName("x$4"), TypeTree(), EmptyTree)), Apply(Select(Ident(TermName("x$3")), TermName("$plus")), List(Ident(TermName("x$4")))))))))))), Literal(Constant(())))
@DmytroMitin DmytroMitin self-assigned this Jul 21, 2019
@DmytroMitin DmytroMitin added the bug Something isn't working label Jul 25, 2019
@DmytroMitin DmytroMitin removed their assignment Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working macros
Projects
None yet
Development

No branches or pull requests

1 participant