Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branches 'retronym/ticket/5407', 'scalamacros/t…
…opic/macrocherrypick', 'lrytz/t5626', 'lrytz/t5009', 'retronym/ticket/5029', 'retronym/ticket/4025', 'retronym/topic/quieter-nsdhnao' and 'retronym/ticket/1133' into develop
- Loading branch information
Showing
20 changed files
with
333 additions
and
136 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
c020eccb8cf37963725985f36b44d070915cf4d2 ?scala-compiler.jar | ||
5b3f50d124f84dcda869e17fb0cfd605ed40f385 ?scala-compiler.jar |
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 +1 @@ | ||
31c7188cef85c28b84b9ce35bc6780996e5dd139 ?scala-library.jar | ||
8f19876a8908e7d7d2a140a8434805cfec2c1346 ?scala-library.jar |
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
274 changes: 157 additions & 117 deletions
274
src/compiler/scala/tools/nsc/typechecker/Macros.scala
Large diffs are not rendered by default.
Oops, something went wrong.
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,32 @@ | ||
object Match | ||
{ | ||
def main(args: Array[String]) = { | ||
args(0) match { | ||
case Extractor1(Extractor2(Extractor3("dog", "dog", "dog"), x2, x3), b, c, Extractor3("b", "b", f), e) => println(e) | ||
case Extractor3(Extractor2(Extractor1("a", "aa", "aaa", "aa", "a"), Extractor2("a", "aa", "aaa"), e), y, z) => println(e) | ||
case Extractor2(Extractor3("a", "a", x), Extractor3("b", "b", y), Extractor3("c", "c", z)) => println(z) | ||
case _ => println("fail") | ||
} | ||
} | ||
|
||
object Extractor1 { | ||
def unapply(x: Any) = x match { | ||
case x: String => Some(x, x+x, x+x+x, x+x, x) | ||
case _ => None | ||
} | ||
} | ||
|
||
object Extractor2 { | ||
def unapply(x: Any) = x match { | ||
case x: String => Some(x, x+x, x+x+x) | ||
case _ => None | ||
} | ||
} | ||
|
||
object Extractor3 { | ||
def unapply(x: Any) = x match { | ||
case x: String => Some(x, x, x) | ||
case _ => None | ||
} | ||
} | ||
} |
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 @@ | ||
-Xfatal-warnings |
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,3 @@ | ||
object Test { | ||
(Vector(): Seq[_]) match { case List() => true; case Nil => false } | ||
} |
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,12 @@ | ||
class C { | ||
val blob = { | ||
new { case class Foo() } | ||
} | ||
val blub = { | ||
class Inner { case class Foo() } | ||
new Inner | ||
} | ||
|
||
val foo = blob.Foo() | ||
val bar = blub.Foo() | ||
} |
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 |
---|---|---|
|
@@ -92,7 +92,7 @@ test5 | |
test5 | ||
5 | ||
10: 2 | ||
slkdfj1 | ||
slkdfj2 | ||
1 | ||
lskfdjlk | ||
11 | ||
|
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,19 @@ | ||
Type in expressions to have them evaluated. | ||
Type :help for more information. | ||
|
||
scala> | ||
|
||
scala> class Color(val red: Int) | ||
defined class Color | ||
|
||
scala> | ||
|
||
scala> case class Red(r:Int) extends Color(r) | ||
defined class Red | ||
|
||
scala> | ||
|
||
scala> def f(c: Any) = c match { case Red(_) => () } | ||
f: (c: Any)Unit | ||
|
||
scala> |
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,12 @@ | ||
import scala.tools.nsc.Settings | ||
import scala.tools.partest.ReplTest | ||
|
||
object Test extends ReplTest { | ||
def code = """ | ||
class Color(val red: Int) | ||
case class Red(r:Int) extends Color(r) | ||
def f(c: Any) = c match { case Red(_) => () } | ||
""" | ||
} |
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,4 @@ | ||
C(1,true) | ||
10 | ||
C(7283,20) | ||
100 |
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,17 @@ | ||
object Test extends App { | ||
|
||
case class C[T, U <: String, O >: Object](x: Int, y: T)(z: U, b: Boolean)(s: O, val l: Int) | ||
|
||
val c = C(1, true)("dlkfj", true)("dlkfjlk", 10) | ||
println(c) | ||
println(c.l) | ||
|
||
val f1a = c.copy(y = 20, x = 7283) | ||
|
||
val f1b = c.copy[Int, String, Object](y = 20, x = 7283) | ||
val f2b = f1b("lkdjen", false) | ||
val res = f2b(new Object, 100) | ||
println(res) | ||
println(res.l) | ||
|
||
} |
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,2 @@ | ||
2 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
case class Foo(private val x: Int, y: Option[Int], z: Boolean) | ||
|
||
object Test extends App { | ||
def foo(x: Foo) = x match { | ||
case Foo(x, Some(y), z) => y | ||
case Foo(x, y, z) => 0 | ||
} | ||
val x = Foo(1, Some(2), false) | ||
println(foo(x)) | ||
|
||
|
||
def bar(x: Foo) = x match { | ||
case Foo(x, Some(y), z) => y | ||
case Foo(x, None, z) => 0 | ||
} | ||
println(bar(x)) | ||
} |