forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reflection now correctly processes classes, objects and inner classes that are declared in classes and objects. However classToType still crashes on compound types and local classes. For more information on those, follow the links: * Compound types: https://issues.scala-lang.org/browse/SI-5430 * Local classes: https://issues.scala-lang.org/browse/SI-5431 Fixes https://issues.scala-lang.org/browse/SI-5256. Review by @paulp, @odersky.
- Loading branch information
Showing
19 changed files
with
247 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
A | ||
true |
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,9 @@ | ||
import scala.reflect.mirror._ | ||
|
||
class A | ||
|
||
object Test extends App { | ||
val c = classToType(classOf[A]) | ||
println(c) | ||
println(c.typeSymbol == classToSymbol(classOf[A])) | ||
} |
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 @@ | ||
Test.A | ||
true |
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,8 @@ | ||
import scala.reflect.mirror._ | ||
|
||
object Test extends App { | ||
class A | ||
val c = classToType(classOf[A]) | ||
println(c) | ||
println(c.typeSymbol == classToSymbol(classOf[A])) | ||
} |
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,20 @@ | ||
Type in expressions to have them evaluated. | ||
Type :help for more information. | ||
|
||
scala> | ||
|
||
scala> import scala.reflect.mirror._ | ||
import scala.reflect.mirror._ | ||
|
||
scala> class A | ||
defined class A | ||
|
||
scala> val c = classToType(classOf[A]) | ||
c: reflect.mirror.Type = A | ||
|
||
scala> println(c.typeSymbol == classToSymbol(classOf[A])) | ||
true | ||
|
||
scala> | ||
|
||
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,10 @@ | ||
import scala.tools.partest.ReplTest | ||
|
||
object Test extends ReplTest { | ||
def code = """ | ||
import scala.reflect.mirror._ | ||
class A | ||
val c = classToType(classOf[A]) | ||
println(c.typeSymbol == classToSymbol(classOf[A])) | ||
""" | ||
} |
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 @@ | ||
C.this.A | ||
true |
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,9 @@ | ||
import scala.reflect.mirror._ | ||
|
||
class C { class A } | ||
|
||
object Test extends App { | ||
val c = classToType(classOf[C#A]) | ||
println(c) | ||
println(c.typeSymbol == classToSymbol(classOf[C#A])) | ||
} |
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 @@ | ||
Test.A1 | ||
true | ||
Test.this.A2 | ||
true |
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 @@ | ||
import scala.reflect.mirror._ | ||
|
||
object Test extends App { | ||
class A1 | ||
|
||
val c1 = classToType(classOf[A1]) | ||
println(c1) | ||
println(c1.typeSymbol == classToSymbol(classOf[A1])) | ||
|
||
new Test | ||
} | ||
|
||
class Test { | ||
class A2 | ||
|
||
val c2 = classToType(classOf[A2]) | ||
println(c2) | ||
println(c2.typeSymbol == classToSymbol(classOf[A2])) | ||
} |
Empty file.
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,10 @@ | ||
import scala.reflect.mirror._ | ||
|
||
object Test extends App { | ||
{ | ||
class A | ||
val c = classToType(classOf[A]) | ||
println(c) | ||
println(c.typeSymbol == classToSymbol(classOf[A])) | ||
} | ||
} |
Empty file.
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,11 @@ | ||
import scala.reflect.mirror._ | ||
|
||
class A | ||
trait B | ||
|
||
object Test extends App { | ||
val mutant = new A with B | ||
val c = classToType(mutant.getClass) | ||
println(c) | ||
println(c.typeSymbol == classToSymbol(mutant.getClass)) | ||
} |
Oops, something went wrong.