-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port typo module to 2.12 (Towards #52)
This reverts part of #92, but only for the code generation code. the generated code will not work for 2.12
- Loading branch information
1 parent
098a1bc
commit 105eacf
Showing
13 changed files
with
73 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package typo.internal | ||
|
||
import scala.collection.mutable | ||
|
||
object compat { | ||
// compat with scala 2.12 | ||
implicit class ListOps[A](as: List[A]) { | ||
def distinctByCompat[B, C](f: A => B): List[A] = { | ||
if (as.lengthCompare(1) <= 0) as | ||
else { | ||
val builder = List.newBuilder[A] | ||
val seen = mutable.HashSet.empty[B] | ||
val it = as.iterator | ||
var different = false | ||
while (it.hasNext) { | ||
val next = it.next() | ||
if (seen.add(f(next))) builder += next else different = true | ||
} | ||
if (different) builder.result() else as | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package typo.internal | ||
|
||
object forget { | ||
def apply[T](t: T): Unit = (t, ())._2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package typo.internal | ||
|
||
object quote { | ||
def apply(str: String) = s"'$str'" | ||
def double(str: String) = s"\"$str\"" | ||
val Quote = '\'' | ||
val DoubleQuote = '"' | ||
def apply(str: String) = s"$Quote${str}$Quote" | ||
def double(str: String) = s"$DoubleQuote${str}$DoubleQuote" | ||
} |