-
Notifications
You must be signed in to change notification settings - Fork 21
eta-expansion for method on target that needs implicit conversion #8299
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8299?orig=1 |
@adriaanm said: scala> lazy val c: CompatibleC = ???
c: CompatibleC = <lazy>
scala> println(c.foo _ )
<function1>
|
@som-snytt said: scala> c.f _
<console>:14: error: missing argument list for method f in class CC
Unapplied methods are only converted to functions when a function type is expected.
You can make this conversion explicit by writing `f _` or `f(_)` instead of `f`.
c.f _
^
scala> c.f(_)
res3: Int => Int = $$Lambda$1088/149526537@e62319f
|
@som-snytt said: Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_111).
Type in expressions for evaluation. Or try :help.
scala> List(1,3,5).map("abc".isDefinedAt)
res0: List[Boolean] = List(true, false, false)
scala> List(1,3,5).map("abc".isDefinedAt _)
<console>:12: error: _ must follow method; cannot follow Int => Boolean
List(1,3,5).map("abc".isDefinedAt _)
^
scala> List(1,3,5).map("abc".isDefinedAt(_))
res2: List[Boolean] = List(true, false, false)
|
We'll use the expected type when we type the eta-expansion that was requested. We know `m` is expected to be a method, since only methods can be followed by `_` to request eta-expansion. So, have the expected type reflect that. Since the original expected type won't be compatible with the method type that FUNmode gives us (method values are not first class), we have to defer using the given expected type until we eta-expanded, which results in a function, which is first class. When typing under FUNmode under pt=* we can let implicit conversion do its thing, before we wrap this in a function. See scala/bug#8299.
We'll use the expected type when we type the eta-expansion that was requested. We know `m` is expected to be a method, since only methods can be followed by `_` to request eta-expansion. So, have the expected type reflect that. Since the original expected type won't be compatible with the method type that FUNmode gives us (method values are not first class), we have to defer using the given expected type until we eta-expanded, which results in a function, which is first class. When typing under FUNmode under pt=* we can let implicit conversion do its thing, before we wrap this in a function. See scala/bug#8299.
We'll use the expected type when we type the eta-expansion that was requested. We know `m` is expected to be a method, since only methods can be followed by `_` to request eta-expansion. So, have the expected type reflect that. Since the original expected type won't be compatible with the method type that FUNmode gives us (method values are not first class), we have to defer using the given expected type until we eta-expanded, which results in a function, which is first class. When typing under FUNmode under pt=* we can let implicit conversion do its thing, before we wrap this in a function. See scala/bug#8299.
We'll use the expected type when we type the eta-expansion that was requested. We know `m` is expected to be a method, since only methods can be followed by `_` to request eta-expansion. So, have the expected type reflect that. Since the original expected type won't be compatible with the method type that FUNmode gives us (method values are not first class), we have to defer using the given expected type until we eta-expanded, which results in a function, which is first class. When typing under FUNmode under pt=* we can let implicit conversion do its thing, before we wrap this in a function. See scala/bug#8299.
We'll use the expected type when we type the eta-expansion that was requested. We know `m` is expected to be a method, since only methods can be followed by `_` to request eta-expansion. So, have the expected type reflect that. Since the original expected type won't be compatible with the method type that FUNmode gives us (method values are not first class), we have to defer using the given expected type until we eta-expanded, which results in a function, which is first class. When typing under FUNmode under pt=* we can let implicit conversion do its thing, before we wrap this in a function. See scala/bug#8299.
We'll use the expected type when we type the eta-expansion that was requested. We know `m` is expected to be a method, since only methods can be followed by `_` to request eta-expansion. So, have the expected type reflect that. Since the original expected type won't be compatible with the method type that FUNmode gives us (method values are not first class), we have to defer using the given expected type until we eta-expanded, which results in a function, which is first class. When typing under FUNmode under pt=* we can let implicit conversion do its thing, before we wrap this in a function. See scala/bug#8299.
We'll use the expected type when we type the eta-expansion that was requested. We know `m` is expected to be a method, since only methods can be followed by `_` to request eta-expansion. So, have the expected type reflect that. Since the original expected type won't be compatible with the method type that FUNmode gives us (method values are not first class), we have to defer using the given expected type until we eta-expanded, which results in a function, which is first class. When typing under FUNmode under pt=* we can let implicit conversion do its thing, before we wrap this in a function. See scala/bug#8299.
The error is the same if I manually create an implicit def.
The text was updated successfully, but these errors were encountered: