-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #3947: Support lifting of java.lang.Class #4193
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
96629a0
Fix #3947: Support lifting of java.lang.Class
nicolasstucki b9ea4a6
Workaround #4198
nicolasstucki 137af87
Use Class.isPrimitive for perfomance
nicolasstucki fb7ffc3
Support array classes
nicolasstucki b5b7f1b
Remove unnecesarry code from tests
nicolasstucki 2d7653a
Split tests to avoid timeout on CI
nicolasstucki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
|
||
classOf[Object].getCanonicalName() | ||
java.lang.Object | ||
|
||
classOf[Object].getCanonicalName() | ||
java.lang.Object | ||
|
||
classOf[Object].getCanonicalName() | ||
java.lang.Object | ||
|
||
classOf[Object].getCanonicalName() | ||
java.lang.Object |
This file contains hidden or 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,24 @@ | ||
|
||
import scala.quoted._ | ||
import dotty.tools.dotc.quoted.Toolbox._ | ||
|
||
object Test { | ||
|
||
def main(args: Array[String]): Unit = { | ||
|
||
def test[T](clazz: java.lang.Class[T]): Unit = { | ||
val lclazz = clazz.toExpr | ||
val name = '{ (~lclazz).getCanonicalName } | ||
println() | ||
println(name.show) | ||
println(name.run) | ||
} | ||
|
||
// classOf[Object] | ||
test(classOf[Object]) | ||
test(classOf[Any]) | ||
test(classOf[AnyRef]) | ||
test(classOf[AnyVal]) | ||
} | ||
|
||
} |
This file contains hidden or 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,27 @@ | ||
|
||
classOf[Boolean].getCanonicalName() | ||
boolean | ||
|
||
classOf[Byte].getCanonicalName() | ||
byte | ||
|
||
classOf[Char].getCanonicalName() | ||
char | ||
|
||
classOf[Short].getCanonicalName() | ||
short | ||
|
||
classOf[Int].getCanonicalName() | ||
int | ||
|
||
classOf[Long].getCanonicalName() | ||
long | ||
|
||
classOf[Float].getCanonicalName() | ||
float | ||
|
||
classOf[Double].getCanonicalName() | ||
double | ||
|
||
classOf[Unit].getCanonicalName() | ||
void |
This file contains hidden or 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,29 @@ | ||
|
||
import scala.quoted._ | ||
import dotty.tools.dotc.quoted.Toolbox._ | ||
|
||
object Test { | ||
|
||
def main(args: Array[String]): Unit = { | ||
|
||
def test[T](clazz: java.lang.Class[T]): Unit = { | ||
val lclazz = clazz.toExpr | ||
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. Same. 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. Done |
||
val name = '{ (~lclazz).getCanonicalName } | ||
println() | ||
println(name.show) | ||
println(name.run) | ||
} | ||
|
||
// primitives | ||
test(classOf[Boolean]) | ||
test(classOf[Byte]) | ||
test(classOf[Char]) | ||
test(classOf[Short]) | ||
test(classOf[Int]) | ||
test(classOf[Long]) | ||
test(classOf[Float]) | ||
test(classOf[Double]) | ||
test(classOf[Unit]) | ||
} | ||
|
||
} |
This file contains hidden or 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 @@ | ||
|
||
classOf[scala.runtime.Null$].getCanonicalName() | ||
scala.runtime.Null$ | ||
|
||
classOf[scala.runtime.Nothing$].getCanonicalName() | ||
scala.runtime.Nothing$ | ||
|
||
classOf[String].getCanonicalName() | ||
java.lang.String |
This file contains hidden or 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 @@ | ||
|
||
import scala.quoted._ | ||
import dotty.tools.dotc.quoted.Toolbox._ | ||
|
||
object Test { | ||
|
||
def main(args: Array[String]): Unit = { | ||
|
||
def test[T](clazz: java.lang.Class[T]): Unit = { | ||
val lclazz = clazz.toExpr | ||
val name = '{ (~lclazz).getCanonicalName } | ||
println() | ||
println(name.show) | ||
println(name.run) | ||
} | ||
|
||
test(classOf[Null]) | ||
test(classOf[Nothing]) | ||
|
||
test(classOf[String]) | ||
} | ||
|
||
} |
This file contains hidden or 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,18 @@ | ||
|
||
classOf[Foo].getCanonicalName() | ||
Foo | ||
|
||
classOf[Foo#Bar].getCanonicalName() | ||
Foo.Bar | ||
|
||
classOf[Foo.Baz].getCanonicalName() | ||
Foo.Baz | ||
|
||
classOf[foo.Foo].getCanonicalName() | ||
foo.Foo | ||
|
||
classOf[foo.Foo#Bar].getCanonicalName() | ||
foo.Foo.Bar | ||
|
||
classOf[foo.Foo.Baz].getCanonicalName() | ||
foo.Foo.Baz |
This file contains hidden or 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,43 @@ | ||
|
||
import scala.quoted._ | ||
import dotty.tools.dotc.quoted.Toolbox._ | ||
|
||
object Test { | ||
|
||
def main(args: Array[String]): Unit = { | ||
|
||
def test[T](clazz: java.lang.Class[T]): Unit = { | ||
val lclazz = clazz.toExpr | ||
val name = '{ (~lclazz).getCanonicalName } | ||
println() | ||
println(name.show) | ||
println(name.run) | ||
} | ||
|
||
test(classOf[Foo]) | ||
test(classOf[Foo#Bar]) | ||
test(classOf[Foo.Baz]) | ||
|
||
test(classOf[foo.Foo]) | ||
test(classOf[foo.Foo#Bar]) | ||
test(classOf[foo.Foo.Baz]) | ||
} | ||
|
||
} | ||
|
||
class Foo { | ||
class Bar | ||
} | ||
|
||
object Foo { | ||
class Baz | ||
} | ||
|
||
package foo { | ||
class Foo { | ||
class Bar | ||
} | ||
object Foo { | ||
class Baz | ||
} | ||
} |
This file contains hidden or 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 @@ | ||
|
||
classOf[Object].getCanonicalName() | ||
java.lang.Object | ||
|
||
classOf[Array[Foo]].getCanonicalName() | ||
Foo[] | ||
|
||
classOf[Array[Array[Foo]]].getCanonicalName() | ||
Foo[][] |
This file contains hidden or 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,29 @@ | ||
|
||
import scala.quoted._ | ||
import dotty.tools.dotc.quoted.Toolbox._ | ||
|
||
object Test { | ||
|
||
def main(args: Array[String]): Unit = { | ||
|
||
def test[T](clazz: java.lang.Class[T]): Unit = { | ||
val lclazz = clazz.toExpr | ||
val name = '{ (~lclazz).getCanonicalName } | ||
println() | ||
println(name.show) | ||
println(name.run) | ||
} | ||
|
||
// class Object | ||
test(classOf[Array[_]]) | ||
|
||
// class Array[Foo] | ||
test(classOf[Array[Foo]]) | ||
|
||
// class Array[Array[Foo]] | ||
test(classOf[Array[Array[Foo]]]) | ||
} | ||
|
||
} | ||
|
||
class Foo |
This file contains hidden or 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 @@ | ||
|
||
classOf[Array[Object]].getCanonicalName() | ||
java.lang.Object[] | ||
|
||
classOf[Array[Object]].getCanonicalName() | ||
java.lang.Object[] | ||
|
||
classOf[Array[Object]].getCanonicalName() | ||
java.lang.Object[] | ||
|
||
classOf[Array[Object]].getCanonicalName() | ||
java.lang.Object[] |
This file contains hidden or 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,26 @@ | ||
|
||
import scala.quoted._ | ||
import dotty.tools.dotc.quoted.Toolbox._ | ||
|
||
object Test { | ||
|
||
def main(args: Array[String]): Unit = { | ||
|
||
def test[T](clazz: java.lang.Class[T]): Unit = { | ||
val lclazz = clazz.toExpr | ||
val name = '{ (~lclazz).getCanonicalName } | ||
println() | ||
println(name.show) | ||
println(name.run) | ||
} | ||
|
||
// class Array[Object] | ||
test(classOf[Array[Any]]) | ||
test(classOf[Array[AnyVal]]) | ||
test(classOf[Array[AnyRef]]) | ||
test(classOf[Array[Object]]) | ||
} | ||
|
||
} | ||
|
||
class Foo |
This file contains hidden or 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 @@ | ||
|
||
classOf[Array[Boolean]].getCanonicalName() | ||
boolean[] | ||
|
||
classOf[Array[Byte]].getCanonicalName() | ||
byte[] | ||
|
||
classOf[Array[Char]].getCanonicalName() | ||
char[] | ||
|
||
classOf[Array[Short]].getCanonicalName() | ||
short[] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What's the purpose of
lclazz
in the test?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.
Lift a class and then splice it in some quote that will run in next stage.
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.
Oh, I see. I lifted it directly in the quote. I will remove it or use it instead.
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.
Done