Skip to content

Commit e3b1779

Browse files
Merge remote-tracking branch 'upstream/master' into dotty-community-build
2 parents 00ec51f + 0068669 commit e3b1779

File tree

8 files changed

+50
-19
lines changed

8 files changed

+50
-19
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ SourceCode [![Build Status](https://travis-ci.org/lihaoyi/sourcecode.svg?branch=
22
==========
33

44
```scala
5-
"com.lihaoyi" %% "sourcecode" % "0.1.7" // Scala-JVM
6-
"com.lihaoyi" %%% "sourcecode" % "0.1.7" // Scala.js / Scala Native
5+
"com.lihaoyi" %% "sourcecode" % "0.1.9" // Scala-JVM
6+
"com.lihaoyi" %%% "sourcecode" % "0.1.9" // Scala.js / Scala Native
77
```
88

99
`sourcecode` is a small Scala library for that provides common "source code"
@@ -228,8 +228,8 @@ object Implicits {
228228
}
229229
```
230230

231-
By default, the various implicits all ignore any synthetic `<init>` or
232-
`<local Foo>` methods that might be present:
231+
By default, the various implicits all ignore any synthetic `<init>`,
232+
`<local Foo>` or `$anonfun` methods that might be present:
233233

234234
```scala
235235
package sourcecode
@@ -620,6 +620,11 @@ in its `.toString` method.
620620
Version History
621621
===============
622622

623+
0.1.9
624+
-----
625+
626+
- `$anonfun` segments are now ignored by `sourcecode.Enclosing`
627+
623628
0.1.8
624629
-----
625630

build.sc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import mill._, scalalib._, scalajslib._, scalanativelib._, publish._
44
trait SourcecodeModule extends PublishModule {
55
def artifactName = "sourcecode"
66

7-
def publishVersion = "0.1.8"
7+
def publishVersion = "0.2.0"
88

99
def pomSettings = PomSettings(
1010
description = artifactName(),
@@ -64,8 +64,7 @@ trait SourcecodeTestModule extends ScalaModule {
6464
}
6565

6666
object sourcecode extends Module {
67-
val dottyVersion = Option(sys.props("dottyVersion"))
68-
object jvm extends Cross[JvmSourcecodeModule]((List("2.11.12", "2.12.8", "2.13.0") ++ dottyVersion): _*)
67+
object jvm extends Cross[JvmSourcecodeModule]("2.11.12", "2.12.10", "2.13.1", "0.21.0-RC1")
6968
class JvmSourcecodeModule(val crossScalaVersion: String)
7069
extends SourcecodeMainModule with ScalaModule with SourcecodeModule {
7170

@@ -86,7 +85,8 @@ object sourcecode extends Module {
8685
}
8786

8887
object js extends Cross[JsSourcecodeModule](
89-
("2.11.12", "0.6.28"), ("2.12.8", "0.6.28"), ("2.13.0", "0.6.28")/*, ("2.12.8", "1.0.0-M8"), ("2.13.0", "1.0.0-M8")*/
88+
("2.11.12", "0.6.28"), ("2.12.10", "0.6.28"), ("2.13.1", "0.6.28"),
89+
("2.11.12", "1.0.0-RC2"), ("2.12.10", "1.0.0-RC2"), ("2.13.1", "1.0.0-RC2")
9090
)
9191
class JsSourcecodeModule(val crossScalaVersion: String, crossJSVersion: String)
9292
extends SourcecodeMainModule with ScalaJSModule with SourcecodeModule {
@@ -117,4 +117,4 @@ object sourcecode extends Module {
117117
val crossScalaVersion = NativeSourcecodeModule.this.crossScalaVersion
118118
}
119119
}
120-
}
120+
}

mill

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This is a wrapper script, that automatically download mill from GitHub release pages
44
# You can give the required mill version with MILL_VERSION env variable
55
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
6-
DEFAULT_MILL_VERSION=0.5.0
6+
DEFAULT_MILL_VERSION=0.5.7
77

88
set -e
99

@@ -17,13 +17,24 @@ if [ -z "$MILL_VERSION" ] ; then
1717
fi
1818
fi
1919

20-
MILL_DOWNLOAD_PATH="$HOME/.mill/download"
21-
MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/$MILL_VERSION"
20+
if [ "x${XDG_CACHE_HOME}" != "x" ] ; then
21+
MILL_DOWNLOAD_PATH="${XDG_CACHE_HOME}/mill/download"
22+
else
23+
MILL_DOWNLOAD_PATH="${HOME}/.cache/mill/download"
24+
fi
25+
MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/${MILL_VERSION}"
26+
27+
version_remainder="$MILL_VERSION"
28+
MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
29+
MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
2230

2331
if [ ! -x "$MILL_EXEC_PATH" ] ; then
2432
mkdir -p $MILL_DOWNLOAD_PATH
33+
if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then
34+
ASSEMBLY="-assembly"
35+
fi
2536
DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download
26-
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION-assembly"
37+
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION${ASSEMBLY}"
2738
curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL"
2839
chmod +x "$DOWNLOAD_FILE"
2940
mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH"

sourcecode/src-0/sourcecode/Macros.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ trait ArgsMacros {
6767
object Util{
6868
def isSynthetic(c: Reflection)(s: c.Symbol) = isSyntheticName(getName(c)(s))
6969
def isSyntheticName(name: String) = {
70-
name == "<init>" || (name.startsWith("<local ") && name.endsWith(">"))
70+
name == "<init>" || (name.startsWith("<local ") && name.endsWith(">")) || name == "$anonfun"
7171
}
7272
def getName(c: Reflection)(s: c.Symbol) = {
7373
import c.given

sourcecode/src-2/sourcecode/Macros.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ trait ArgsMacros {
5454
object Util{
5555
def isSynthetic(c: Compat.Context)(s: c.Symbol) = isSyntheticName(getName(c)(s))
5656
def isSyntheticName(name: String) = {
57-
name == "<init>" || (name.startsWith("<local ") && name.endsWith(">"))
57+
name == "<init>" || (name.startsWith("<local ") && name.endsWith(">")) || name == "$anonfun"
5858
}
5959
def getName(c: Compat.Context)(s: c.Symbol) = s.name.decoded.toString.trim
6060
}

sourcecode/test/src/sourcecode/Apply.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ object Apply {
2424
assert(line == 23)
2525

2626
lazy val myLazy = {
27-
trait Bar{
27+
/* Bar used to be a trait, but that ran into the upstream bug
28+
* https://github.com/scala-js/scala-js/issues/3918 in Scala.js 1.0.0-RC2
29+
* and Scala 2.12+. We use an abstract class as a workaround.
30+
*/
31+
abstract class Bar{
2832
val name = sourcecode.Name()
2933
assert(name == "name")
3034

@@ -38,7 +42,7 @@ object Apply {
3842
assert(fileName == "Apply.scala")
3943

4044
val line = sourcecode.Line()
41-
assert(line == 40)
45+
assert(line == 44)
4246

4347
val enclosing = sourcecode.Enclosing()
4448
assert(

sourcecode/test/src/sourcecode/Implicits.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ object Implicits {
2424
assert(line.value == 23)
2525

2626
lazy val myLazy = {
27-
trait Bar{
27+
/* Bar used to be a trait, but that ran into the upstream bug
28+
* https://github.com/scala-js/scala-js/issues/3918 in Scala.js 1.0.0-RC2
29+
* and Scala 2.12+. We use an abstract class as a workaround.
30+
*/
31+
abstract class Bar{
2832
val name = implicitly[sourcecode.Name]
2933
assert(name.value == "name")
3034

@@ -41,7 +45,7 @@ object Implicits {
4145
assert(fileName.value == "Implicits.scala")
4246

4347
val line = implicitly[sourcecode.Line]
44-
assert(line.value == 43)
48+
assert(line.value == 47)
4549

4650
val enclosing = implicitly[sourcecode.Enclosing]
4751
assert(

sourcecode/test/src/sourcecode/NoSynthetic.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ object NoSynthetic {
1313
assert(sourcecode.Name() == "Bar")
1414
assert(sourcecode.FullName() == "sourcecode.NoSynthetic.Bar")
1515
assert(sourcecode.Enclosing() == "sourcecode.NoSynthetic.run Bar")
16+
assert(
17+
(for {
18+
_ <- Option(1)
19+
_ <- Option(2)
20+
foo <- Option(sourcecode.Enclosing())
21+
} yield foo) == Some("sourcecode.NoSynthetic.run Bar")
22+
)
1623
}
1724
Bar
1825
}

0 commit comments

Comments
 (0)