-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Contextualize type splices #6958
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import scala.quoted._ | ||
|
||
object Test { | ||
given as QuoteContext = ??? | ||
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. It's not obvious to me why this is needed, given that all implicits are available and type check, and there are no quotes nor splices. 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. The calls to |
||
|
||
def a[A: Type](): Unit = { | ||
b[Expr[A]]() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
|
||
scala.Predef.classOf[java.lang.Object].getCanonicalName() | ||
java.lang.Object | ||
|
||
scala.Predef.classOf[java.lang.Object].getCanonicalName() | ||
java.lang.Object | ||
|
||
scala.Predef.classOf[java.lang.Object].getCanonicalName() | ||
java.lang.Object | ||
|
||
scala.Predef.classOf[java.lang.Object].getCanonicalName() | ||
java.lang.Object | ||
java.lang.Object | ||
java.lang.Object | ||
java.lang.Object |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
|
||
scala.Predef.classOf[scala.runtime.Null].getCanonicalName() | ||
scala.runtime.Null$ | ||
|
||
scala.Predef.classOf[scala.runtime.Nothing].getCanonicalName() | ||
scala.runtime.Nothing$ | ||
|
||
scala.Predef.classOf[java.lang.String].getCanonicalName() | ||
scala.runtime.Null$ | ||
scala.runtime.Nothing$ | ||
java.lang.String |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
|
||
scala.Predef.classOf[Foo].getCanonicalName() | ||
Foo | ||
|
||
scala.Predef.classOf[Foo#Bar].getCanonicalName() | ||
Foo.Bar | ||
|
||
scala.Predef.classOf[Foo.Baz].getCanonicalName() | ||
Foo | ||
Foo.Bar | ||
Foo.Baz |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
|
||
scala.Predef.classOf[foo.Foo].getCanonicalName() | ||
foo.Foo | ||
|
||
scala.Predef.classOf[foo.Foo#Bar].getCanonicalName() | ||
foo.Foo.Bar | ||
|
||
scala.Predef.classOf[foo.Foo.Baz].getCanonicalName() | ||
foo.Foo | ||
foo.Foo.Bar | ||
foo.Foo.Baz |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
|
||
scala.Predef.classOf[java.lang.Object].getCanonicalName() | ||
java.lang.Object | ||
|
||
scala.Predef.classOf[scala.Array[Foo]].getCanonicalName() | ||
Foo[] | ||
|
||
scala.Predef.classOf[scala.Array[scala.Array[Foo]]].getCanonicalName() | ||
java.lang.Object | ||
Foo[] | ||
Foo[][] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
|
||
scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() | ||
java.lang.Object[] | ||
|
||
scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() | ||
java.lang.Object[] | ||
|
||
scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() | ||
java.lang.Object[] | ||
|
||
scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() | ||
java.lang.Object[] | ||
java.lang.Object[] | ||
java.lang.Object[] | ||
java.lang.Object[] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
|
||
scala.Predef.classOf[scala.Array[scala.Boolean]].getCanonicalName() | ||
boolean[] | ||
|
||
scala.Predef.classOf[scala.Array[scala.Byte]].getCanonicalName() | ||
byte[] | ||
|
||
scala.Predef.classOf[scala.Array[scala.Char]].getCanonicalName() | ||
char[] | ||
|
||
scala.Predef.classOf[scala.Array[scala.Short]].getCanonicalName() | ||
boolean[] | ||
byte[] | ||
char[] | ||
short[] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
|
||
scala.Predef.classOf[scala.Array[scala.Int]].getCanonicalName() | ||
int[] | ||
|
||
scala.Predef.classOf[scala.Array[scala.Long]].getCanonicalName() | ||
long[] | ||
|
||
scala.Predef.classOf[scala.Array[scala.Float]].getCanonicalName() | ||
float[] | ||
|
||
scala.Predef.classOf[scala.Array[scala.Double]].getCanonicalName() | ||
int[] | ||
long[] | ||
float[] | ||
double[] |
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.
Just curious, what's the recommended practice to use
given
: as parameters or contextual function types. Semantically the two are equivalent, and performance-wise they should be almost the same due to the optimization for implicit functions via direct methods.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.
Here the desison was taken to have the symmetry between the quote and splices. The splice takes a contextual function, therefore the quote returns a contextual function. In this particular case, the alignment also helped to implement the quo/splice cancellation.