Skip to content
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

False positive "cannot override a concrete member without a third member..." with incremental compilation #12476

Closed
nigredo-tori opened this issue Oct 24, 2021 · 5 comments

Comments

@nigredo-tori
Copy link

nigredo-tori commented Oct 24, 2021

I've got a weird issue with incrementally compiling a project with Bloop. I have a cake setup like this:

  • trait Foo.Service with method create
  • class FooImpl extends Foo.Service with override create
  • trait LoggedFoo extends Foo.Service with Bar with Baz with abstract override create
  • trait EventFoo extends Foo.Service with Bar with abstract override create
  • an anonymous class new FooImpl with LoggedFoo with EventFoo {...} in the same source file as Foo.Service

As a whole, this is compiled OK. However, changing EventFoo after compilation leads to incremental compilation of just these sources, which results in an error like this one:

cannot override a concrete member without a third member that's overridden by both (this rule is designed to prevent ``accidental overrides'')
override def create(...): ... (defined in class FooImpl)
  with absoverride def create(...): ... (defined in trait EventFoo);

This error seems to be a false positive, since the mentioned third member is Foo.Service#create.

(Bloop 1.4.9, Scala 2.13.3)

I've failed to build a repro for this, and the repository is private. However, I can reliably reproduce this issue, and I've managed to cobble together a setup that allows me to debug this. The error message led me to this line of code in the compiler: https://github.com/scala/scala/blob/d23424cd3aa17f7ad95b81018c70ceed2566962b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala#L415. extendedOverriddenSymbols calls return collections with one element each, with values as specified below.

member.extendedOverriddenSymbols:

result = {Symbols$MethodSymbol@11083} "method create"
 mtpePre = {Types$UniqueSuperType@11094} "EventFoo.super.type"
 mtpeRunId = 1
 mtpeResult = {Types$MethodType@11095} "(<redacted>): zio.Task[<redacted>]"
 mtpeInfo = {Types$MethodType@11096} "(<redacted>): zio.Task[<redacted>]"
 _referenced = {Symbols$NoSymbol@11097} "<none>"
 initName = {Names$TermName@11098} "create"
 _rawname = {Names$TermName@11098} "create"
 _rawowner = {Symbols$ClassSymbol@11099} "trait Service"
 _rawflags = 17592186044496
 id = 29031
 _validTo = 270
 javaBinaryNameStringCache = null
 _privateWithin = {Symbols$NoSymbol@11097} "<none>"
 scala$reflect$internal$Symbols$$infos = {Symbols$TypeHistory@11100} "typer: (<redacted>): zio.Task[<redacted>]"
 _annotations = {Nil$@11101} "Nil$" size = 0
 isOverridingSymbolCache = -1
 rawatt = {NonemptyAttachments@11102} 
 $outer = {ZincCompiler@11044} 

other.extendedOverriddenSymbols:

result = {Symbols$MethodSymbol@11116} "method create"
 mtpePre = null
 mtpeRunId = 0
 mtpeResult = null
 mtpeInfo = null
 _referenced = {Symbols$NoSymbol@11097} "<none>"
 initName = {Names$TermName@11098} "create"
 _rawname = {Names$TermName@11098} "create"
 _rawowner = {Symbols$ClassSymbol@11121} "trait Service"
 _rawflags = 80
 id = 57365
 _validTo = 270
 javaBinaryNameStringCache = null
 _privateWithin = {Symbols$NoSymbol@11097} "<none>"
 scala$reflect$internal$Symbols$$infos = {Symbols$TypeHistory@11122} "namer: (<redacted>): zio.Task[<redacted>]"
 _annotations = {Nil$@11101} "Nil$" size = 0
 isOverridingSymbolCache = -1
 rawatt = {NonemptyAttachments@11123} 
 $outer = {ZincCompiler@11044} 
@nigredo-tori
Copy link
Author

Small correction: only Foo.scala and EventFoo.scala are recompiled.

@SethTisue
Copy link
Member

Is the problem reproducible on Scala 2.13.6? And I don't know Bloop version numbers; what version of Zinc is Bloop 1.4.9 using? Ultimately this is likeliest to be a Zinc bug.

@nigredo-tori
Copy link
Author

nigredo-tori commented Oct 24, 2021

Is the problem reproducible on Scala 2.13.6?

Unknown. I've run into some trouble updating the project to the newer Scala, so I haven't been able to confirm this.

what version of Zinc is Bloop 1.4.9 using?

From what I can tell, 1.3.0-M4+46-edbe573e.

Ultimately this is likeliest to be a Zinc bug.

It might be, for all I know. Although when I originally encountered this issue, I did try a Maven build with incremental compilation (w/ scala-maven-plugin 4.2.4, meaning Zinc 1.3.1 and no Bloop), and got the same error.

Are there any ideas (however general) as to what might be the issue here? To my untrained eye, it's weird that there are two ClassSymbols for trait Service, and yet FooImpl is not recompiled. But I'm just guessing.

I'll try taking another stab at building a repro I can share - I've gotten more familiar with the tooling and the compiler's source code, so I might be able to whip up something. Although I can't tell when I will be able to find time/energy for this.

@SethTisue
Copy link
Member

SethTisue commented Oct 24, 2021

Zinc is at 1.5.7 these days, so I think you may need to report this to the Bloop folks, as you aren't using current versions of either Scala or Zinc. We don't keep tickets open here in scala/bug unless or until they're shown to be reproducible in the latest Scala 2 version. We can reopen if you're able to reproduce it with the combination of Scala 2.13.6 and Zinc 1.5.7.

I don't have a good understanding of how Bloop does incremental compilation, but judging from scalacenter/bloop#1383 , they plan to move to latest Zinc but haven't done so yet. cc @tgodzik

@eed3si9n
Copy link
Member

If there's an under compilation happening (fewer source code is compiled during incremental), then likely it's a Zinc issue, so I'd be happy to keep adopt it under sbt/zinc until we can find the root cause if @nigredo-tori would like to re-report there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants