-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #492. Traits that require an outer pointer are not SAMs. #496
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
Conversation
def app[T, U](x: T)(f: F[T, U]): U = f(x) | ||
app(1)(x => List(x)) | ||
def app1[T, U](x: T)(f: F1[T, U]): U = f(x) | ||
def app2[T, U](x: T)(f: F2[T, U]): U = f(x) |
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.
Should be T.F2
instead of F2
, or add import T._
fe328ee
to
dee1152
Compare
@smarter please review. Does this unblock you? |
It should yes, though I have a fix/workaround to avoid test failures on #411 I'll push soon. |
LGTM but this does not prevent all the "fake" SAMs, as noted in #492 (comment) trait X {
def foo(): Int = 3
}
trait FakeSAM extends X {
def apply(x: Int): Int
override def foo(): Int = super.foo()
// Get extra abstract method "private def super$foo(): Int"
} And trait FakeSAM2 {
def apply(x: Int): Int
val dummy: Int = 3
// the val becomes:
// <accessor> def dummy(): Int <--- extra abstract method
// protected def initial$dummy(): Int = 3
} I don't actually require this to be merged for #411 as I can easily avoid the test failure, so don't feel forced to merge it now. |
I am aware of super-calls. But I do not want to make changes to handling of |
Second example is not a SAM - SAMs cannot have fields. |
That's not a requirement of https://docs.oracle.com/javase/8/docs/api/java/lang/FunctionalInterface.html, static fields are allowed. |
there's no such thing as |
LGTM also |
Fix #492. Traits that require an outer pointer are not SAMs.
No description provided.