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
repeated chain of "(in X)(in X)..." in type error #8777
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8777?orig=1 |
@retronym said: trait ApiUniverse {
protected trait TreePrinter
protected def newCodePrinter: TreePrinter
}
trait InternalSymbolTable extends ApiUniverse {
class TreePrinter extends super.TreePrinter
def newCodePrinter: TreePrinter = null
}
abstract class Global extends InternalSymbolTable {
class TreePrinter extends super.TreePrinter
}
trait Broke extends Global {
override def newCodePrinter: TreePrinter = super.newCodePrinter
}
trait Okay extends Global {
override def newCodePrinter /*: super[InternalSymbolTable].TreePrinter !!! */
= super.newCodePrinter
} Firstly, CodePrinter is not designed for reuse in a virtual-class-like setup. It's a class, rather than a trait, and as such can never conform to Secondly, return type inference based on inheritance lets you express a type that isn't expressible directly.
Note the reference to |
@retronym said: I fixed that over on another WIP branch recently: retronym/scala@scala:2.11.x...topic/existential-in-compound |
@paulp said: class A1 {
trait C
protected[A1] def make(): C = new C { }
}
class A2 extends A1 {
class C extends super.C
}
class A3 extends A2 {
class C extends super.C
}
class A4 extends A3 {
override protected[A4] def make(): C = super.make()
// ./a.scala:12: error: type mismatch;
// found : A4.this.C(in class A1)
// required: A4.this.C(in class A3)
// override protected[A4] def make(): C = super.make()
// ^
// ./a.scala:12: error: overriding method make in class A1 of type ()A4.this.C;
// method make has weaker access privileges; it should be at least protected[A1]
// override protected[A4] def make() = super.make()
// ^
// one error found
} |
@retronym said: |
It compiles if I don't declare the return type. If this is "expected behavior" somehow, then the bug is the design.
The text was updated successfully, but these errors were encountered: