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
Type check failed with an error message "found : w.F; required: w.F" #9878
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9878?orig=1 |
@SethTisue said:
|
@Atry said: |
@SethTisue said: Your example is so complicated, I don't know what it is. I think it's unlikely it will get attention unless you can simplify it. |
@SethTisue said: The error message is confusing, I'll give you that. But I very much doubt that your code is correct. I think you may have an incorrect idea of what it means to "override" a type in a type alias. Scala will let you write e.g.: trait A { type T = Int ; def f: T = 3 }
type U = A { type T = String } but that doesn't mean that in U, you have somehow changed the type of f. The type of f is still Int. By the same token, in your code you write: type Self = W { type F = outer.F } but that doesn't mean that if I have a value w of type Self, def w.selfF is constrained to be outer.F! |
@Atry said (edited on Aug 23, 2016 6:17:30 AM UTC): Scalac does change the type in expression Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_77).
Type in expressions for evaluation. Or try :help.
scala> trait A { type T; def f: T }
defined trait A
scala> type U = A { type T = String }
defined type alias U
scala> new A { type T = String; def f = "f" }
res0: A{type T = String} = $anon$1@68f7aae2
scala> res0: U
res1: U = $anon$1@68f7aae2
scala> res1.f.substring(0, 1) // res1.f is a String
res2: String = f |
@SethTisue said: It seems to me that Self is abstract but F is not — F is a type alias. See SLS 4.3. |
The text was updated successfully, but these errors were encountered: