-
Notifications
You must be signed in to change notification settings - Fork 21
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
consider implicits constructor params in super-ctor call #3439
Comments
Imported From: https://issues.scala-lang.org/browse/SI-3439?orig=1 |
@paulp said: object o1 {
abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg }
}
object o2 {
import o1._
case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg)
} |
@paulp said: object o {
abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg }
case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg) { }
} And trying to pass msg explicitly upward heads toward illustrating why. Is the reported version even supposed to compile? The message implies the equivalent implicit is disallowed, which would mean it's sneaking past in the context bound. // a.scala
abstract class ParametricMessage[M](msg: M)(implicit m: Manifest[M]) { def message = msg }
case class ParametricMessage1[M](msg: M, p1: Class[_])(implicit m: Manifest[M]) extends ParametricMessage(msg)(m) { }
% scalac a.scala
a.scala:3: error: `implicit' modifier cannot be used for top-level objects
case class ParametricMessage1[M](msg: M, p1: Class[_])(implicit m: Manifest[M]) extends ParametricMessage(msg)(m) { } (BTW it's the same if it's not a case class - at first I thought it was something arising from the companion object, but no.) |
@odersky said: |
@paulp said: % scalac28 a.scala % cat a.scala |
@paulp said: abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg }
case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg) |
@retronym said (edited on Jul 10, 2012 10:06:56 PM UTC): Let's examine this example: class Base[M](i: Int)
class Derived()(implicit i: Int) extends Base({println(i); 0}) Within the type completer for
Enclosing Adding an explicit type argument to the Note to future self: pinned down with |
@retronym said:
|
@retronym said (edited on Aug 13, 2013 8:13:42 AM UTC): - if (sym.isTopLevel)
+ if (sym.isTopLevel && !sym.isParameter)
fail(ImplicitAtToplevel) |
@retronym said: |
The compiler fails compiling the following code:
This same line compile without problem in the Scala console. It is possible to workaround this issue by adding the type parameter to the extended class:
The text was updated successfully, but these errors were encountered: