Skip to content

Error with super accessors #15702

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

Closed
liufengyun opened this issue Jul 18, 2022 · 0 comments · Fixed by #15712
Closed

Error with super accessors #15702

liufengyun opened this issue Jul 18, 2022 · 0 comments · Fixed by #15712

Comments

@liufengyun
Copy link
Contributor

Compiler version

master and 3.1.3

Minimized code

abstract class A:
  val n: Int
  def foo(): Int = n

trait B:
  val m: Int
  def foo(): Int = m

trait M extends A with B:
  val a: Int
  override def foo(): Int = a + super.foo()

trait N extends A with B:
  val b: Int
  override def foo(): Int = b * super.foo()

  class Inner:
    N.super[A].foo()
    N.super.foo()

class C extends A with M with N:
  new Inner()
  val a = 10 // error
  val b = 20 // error
  val m = 30 // error
  val n = 40

Output

-- Error: examples/super.scala:21:6 --------------------------------------------
21 |class C extends A with M with N:
   |      ^
   |Member method foo$A of mixin trait N is missing a concrete super implementation in class C.

Expectation

It should compile without errors as in Scala 2.

odersky added a commit to dotty-staging/dotty that referenced this issue Jul 20, 2022
A mixin qualifier foo$A is a qualified name. Previously these
were flattened to SimpleNames when expanding with a trait prefix.
But then ResolveSuper cannot decompose the name anymore.

To fix this, we now treat QualifiedNames specially in the replace
calls for SymDenotations#fullNameSeparated and NameOps#unexpanded.
Qualifiers are preserved and the replacement proceeds recursively
to their underlying part. For some as yet unknown reason we can't
do this for TraitSetterNames. It seems these need to be flattened.

Fixes scala#15702
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants