-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Added in reflect Select.overloaded parameter for expected result type [WIP] #10054
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
13 commits
Select commit
Hold shift + click to select a range
1fdacc7
added retry-type to overloaded argument
rssh 103ed7c
Merge branch 'master' into overloaded-with-retry-path
rssh 043c9b4
fixed tests
rssh 1acb7fd
added test for case, decribed in #10053
rssh bed9f6a
add TypeBounds constructors
rssh 8d9bc59
Update tests/neg-staging/i5941/macro_1.scala
rssh 30daf2c
overload overloaded
rssh 14dfa14
add TypeBound constructor compiler/src/dotty/tools/dotc/quoted/QuoteC…
rssh 2b1c0ee
overload overloaded
rssh 44dddbb
Apply suggestions from code review (form without returnType in tests)
rssh 54dfe29
typo fix
rssh 8c7aeb7
remove empty lines from tests
rssh cbde5bd
removed unused line (cosmetics to trigger stalled build)
rssh 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,4 +217,4 @@ object GenPrism { | |
* }(jstr => jstr) | ||
*/ | ||
inline def apply[S, A <: S]: Prism[S, A] = ${ Prism.impl[S, A] } | ||
} | ||
} |
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,2 @@ | ||
partialFunction | ||
partialFunction |
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,34 @@ | ||
import scala.quoted._ | ||
|
||
object X: | ||
|
||
def andThen[A,B](a:A)(f: A => B): B = | ||
println("totalFunction") | ||
f(a) | ||
|
||
def andThen[A,B](a:A)(f: PartialFunction[A,B]): Option[B] = | ||
println("partialFunction") | ||
f.lift.apply(a) | ||
|
||
|
||
object Macro: | ||
|
||
inline def mThen[A,B](inline x:A=>B):B = ${ | ||
mThenImpl[A,B,A=>B,B]('x) | ||
} | ||
|
||
inline def mThen[A,B](inline x:PartialFunction[A,B]): Option[B] = ${ | ||
mThenImpl[A,B,PartialFunction[A,B],Option[B]]('x) | ||
} | ||
|
||
def mThenImpl[A:Type, B:Type, S<:(A=>B) :Type, R:Type](x:Expr[S])(using qctx: QuoteContext):Expr[R]= | ||
import qctx.reflect._ | ||
val fun = '{X}.unseal | ||
val returnType = quoted.Type[(S) => ?].unseal.tpe | ||
val firstPart = Select.overloaded(fun,"andThen", | ||
List(TypeIdent(defn.IntClass).tpe, TypeIdent(defn.IntClass).tpe), | ||
List(Literal(Constant.Int(1))), | ||
quoted.Type[(S) => R].unseal.tpe | ||
) | ||
val r = Apply(firstPart,List(x.unseal)) | ||
r.seal.cast[R] |
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,5 @@ | ||
object Test: | ||
|
||
def main(args:Array[String]):Unit = | ||
val x1 = X.andThen(1){case x if (x%2 == 0) => x} | ||
val x2 = Macro.mThen{case x:Int if (x%2 == 0) => x} |
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.
Uh oh!
There was an error while loading. Please reload this page.