-
Notifications
You must be signed in to change notification settings - Fork 185
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
Add symbol-based type shortener #42
Changes from all commits
9f891dc
8f8270a
9c41f1d
7d35b92
373b67b
6cbba37
19ba2d5
e6b7df2
36a4120
a5c07a2
b52e51b
fafc9fc
25f4949
d3a7a68
71f922d
4745229
29f6dd6
304ff3c
b6fee12
bf341f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,30 @@ class A { | |
} | ||
>>> | ||
class A { | ||
implicit val x: scala.collection.immutable.Map[Int, String] = | ||
implicit val x: Map[Int, String] = | ||
Map(1 -> "STRING") | ||
} | ||
<<< renamed map | ||
import scala.collection.immutable.{Map => MyMap} | ||
class A { | ||
implicit val x = MyMap(1 -> "STRING") | ||
} | ||
>>> | ||
import scala.collection.immutable.{Map => MyMap} | ||
class A { | ||
implicit val x: MyMap[Int, String] = | ||
MyMap(1 -> "STRING") | ||
} | ||
<<< local map definition | ||
class A { | ||
case class Map[K](elem: (K, String)) | ||
implicit val x = Map(1 -> "STRING") | ||
} | ||
>>> | ||
class A { | ||
case class Map[K](elem: (K, String)) | ||
implicit val x: Map[Int] = Map(1 -> "STRING") | ||
} | ||
<<< def works | ||
class A { | ||
implicit def x = 2 | ||
|
@@ -52,6 +73,162 @@ class A { | |
implicit val x: B = new B | ||
implicit val y: x.C = new x.C | ||
} | ||
<<< NOWRAP higher kinded cats | ||
package cats { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move this into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to limit the test to where the rewrite happens There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just a reproduction of an intricate scenario. Even though it has the names cats, I would leave it here. If you disagree, please point to concrete file you'd like to have it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries, let's keep it here. It's just such a big input, would be nice to have it smaller. |
||
package laws { | ||
package discipline { | ||
trait CartesianTests[F[_]] | ||
object CartesianTests { | ||
trait Isomorphisms[F[_]] | ||
object Isomorphisms { | ||
def id[T[_]]: Isomorphisms[T] = ??? | ||
} | ||
} | ||
} | ||
} | ||
} | ||
package cats { | ||
trait Id[T] | ||
} | ||
package cats { | ||
package tests { | ||
import cats.laws.discipline._ | ||
class IdTests { | ||
implicit val iso = CartesianTests.Isomorphisms.id[Id] | ||
} | ||
} | ||
} | ||
>>> | ||
package cats { | ||
package laws { | ||
package discipline { | ||
trait CartesianTests[F[_]] | ||
object CartesianTests { | ||
trait Isomorphisms[F[_]] | ||
object Isomorphisms { | ||
def id[T[_]]: Isomorphisms[T] = ??? | ||
} | ||
} | ||
} | ||
} | ||
} | ||
package cats { | ||
trait Id[T] | ||
} | ||
package cats { | ||
package tests { | ||
import cats.laws.discipline._ | ||
class IdTests { | ||
implicit val iso: CartesianTests.Isomorphisms[Id] = CartesianTests.Isomorphisms.id[Id] | ||
} | ||
} | ||
} | ||
<<< higher kinded | ||
import scala.concurrent.Future | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this line needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this line is needed. If you have a look at the shortened There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aha, gotcha. Maybe update the test name |
||
package hello { | ||
trait Id[F[_]] | ||
object Id { | ||
def ident[F[_]]: Id[F] = ??? | ||
} | ||
} | ||
object World { | ||
import hello._ | ||
implicit val futureId = Id.ident[scala.concurrent.Future] | ||
} | ||
>>> | ||
import scala.concurrent.Future | ||
package hello { | ||
trait Id[F[_]] | ||
object Id { | ||
def ident[F[_]]: Id[F] = ??? | ||
} | ||
} | ||
object World { | ||
import hello._ | ||
implicit val futureId: Id[Future] = Id.ident[scala.concurrent.Future] | ||
} | ||
<<< path dependent type | ||
class A { | ||
trait C { | ||
class B | ||
} | ||
val c = new C {} | ||
implicit val x = new c.B | ||
} | ||
>>> | ||
class A { | ||
trait C { | ||
class B | ||
} | ||
val c = new C {} | ||
implicit val x: c.B = new c.B | ||
} | ||
<<< path dependent type II | ||
class A { | ||
object D { | ||
val c = new C {} | ||
} | ||
trait C { | ||
class B | ||
} | ||
implicit val x = new D.c.B | ||
} | ||
>>> | ||
class A { | ||
object D { | ||
val c = new C {} | ||
} | ||
trait C { | ||
class B | ||
} | ||
implicit val x: D.c.B = new D.c.B | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bravo 👏 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💃 |
||
} | ||
<<< renamed term in type selection | ||
package E { | ||
object D { | ||
class C | ||
} | ||
} | ||
class A { | ||
import E.{D => d} | ||
implicit val x = new d.C | ||
} | ||
>>> | ||
package E { | ||
object D { | ||
class C | ||
} | ||
} | ||
class A { | ||
import E.{D => d} | ||
implicit val x: d.C = new d.C | ||
} | ||
<<< renamed term in deeper type selection | ||
package E { | ||
object D { | ||
object C { | ||
class B | ||
} | ||
} | ||
} | ||
class A { | ||
import E.{D => d} | ||
import d.{C => c} | ||
implicit val x = new c.B | ||
} | ||
>>> | ||
package E { | ||
object D { | ||
object C { | ||
class B | ||
} | ||
} | ||
} | ||
class A { | ||
import E.{D => d} | ||
import d.{C => c} | ||
implicit val x: c.B = new c.B | ||
} | ||
<<< two classes | ||
class A[T](e: T) | ||
class B { | ||
|
@@ -172,15 +349,15 @@ object A { | |
implicit val x: List[D.B] = List(new D.B) | ||
} | ||
} | ||
<<< SKIP slick tuple | ||
<<< slick tuple | ||
object slick { | ||
case class Supplier(id: Int, name: String) | ||
implicit val supplierGetter = (arg: (Int, String)) => Supplier(arg._1, arg._2) | ||
} | ||
>>> | ||
object slick { | ||
case class Supplier(id: Int, name: String) | ||
implicit val supplierGetter: ((Int, String)) => slick.Supplier = (arg: (Int, String)) => Supplier(arg._1, arg._2) | ||
implicit val supplierGetter: ((Int, String)) => Supplier = (arg: (Int, String)) => Supplier(arg._1, arg._2) | ||
} | ||
<<< NOWRAP package import | ||
package scala.concurrent { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some tricky examples that come to mind: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the code snippets, will add to tests. Forgot about our beloved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome tests! Very nice 👍 |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressive! 😍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look at the other two tests checking renames.