-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use PolyFunction
instead of ErasedFunction
#18295
Use PolyFunction
instead of ErasedFunction
#18295
Conversation
def880d
to
f701f28
Compare
does this include monomorphic dependent function types? (main point being raised here is if this is TASTy backwards compatible) |
ce06c7c
to
8e8bd34
Compare
No, monomorphic dependent function types will not change with this PR. However, we might want to revisit them in the future to simplify refined function types. There is no change in binary compact in this PR. Everything should be TASTy backward compatible. |
9cd35cb
to
6db6f70
Compare
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.
I think isNonRefinedFunction
could also be renamed isNonPolyFunction
@@ -197,7 +197,7 @@ extends tpd.TreeTraverser: | |||
val mt = ContextualMethodType(paramName :: Nil)( | |||
_ => paramType :: Nil, | |||
mt => if isLast then res else expandThrowsAlias(res, mt :: encl)) | |||
val fntpe = RefinedType(defn.ErasedFunctionClass.typeRef, nme.apply, mt) | |||
val fntpe = RefinedType(defn.PolyFunctionClass.typeRef, nme.apply, mt) |
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.
We could add an apply method to defn.PolyFunctionOf
that constructs refinements like this.
library/src/scala/PolyFunction.scala
Outdated
* | ||
* Marker trait for many (poly) function types. | ||
* | ||
* This is the only trait that can be refined with a method or polymorphic method, |
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.
This isn't the only trait that can be refined with a method (any trait can as long as it's not polymorphic) so the documentation needs to be reworded.
3856aa1
to
749b07c
Compare
Does this function return true for dependent refinements? |
I will have a deeper look at the uses of |
Ah no that's isFunctionNType |
7061e48
to
749b07c
Compare
I will follow up on |
We generalize the meaning of `PolyFunction` to mean any kind of refined lambda encoding. These refinements support any type with the following shape as a lambda type: ```scala PolyFunction { def apply[[T1, ..., Tn]]([given] [erased] x1: X1, ..., [erased] xn: Xn): R } ```
749b07c
to
abdc2ca
Compare
This can be removed now that the reference compiler (3.4.0) no longer tries to load the symbol of `ErasedFunction`. Follow up of scala#18295
We generalize the meaning of
PolyFunction
to mean any kind of refinedlambda encoding. These refinements support any type with the following
shape as a lambda type: