From 3af838c55674c0d03e8849d8c756d6ad56c537db Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 28 Jan 2013 14:10:48 +0100 Subject: SI-7033 Be symful when creating factory methods. Implicit class factory methods were synthesizing the reference to the class as `Ident(classDef.name)`, which was unhygienic in case of `implicit class X[X]`. To use symbols without causing a cycle, I switched from `REF(symbol)` to `Ident(symbol)`. The former calls into: at scala.reflect.internal.TreeGen.mkAttributedSelect(TreeGen.scala:184) at scala.reflect.internal.TreeGen.mkAttributedRef(TreeGen.scala:124) at scala.reflect.internal.TreeGen.mkAttributedRef(TreeGen.scala:130) at scala.tools.nsc.ast.TreeDSL$CODE$.REF(TreeDSL.scala:307) which forces the info of enclosing module and forms a cycle. --- test/files/pos/t7033.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/files/pos/t7033.scala (limited to 'test') diff --git a/test/files/pos/t7033.scala b/test/files/pos/t7033.scala new file mode 100644 index 0000000000..a4d256673b --- /dev/null +++ b/test/files/pos/t7033.scala @@ -0,0 +1,15 @@ +import language.higherKinds +object Wrap { + implicit class X[X](val a: X) + + X[Int](0) +} + +class Wrap { + implicit class Y[Y](val a: Y) + Y[Int](0) + implicit class Z[Z[_]](val a: Z[Wrap.this.Z[Z]]) + Z[List](List(new Z[List](null))) +} + +case class X[X](val a: X) -- cgit v1.2.3