Skip to content

Code using cyclic types dependency fails to compile when using protected val in trait constructor #17021

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
WojciechMazur opened this issue Feb 27, 2023 · 0 comments · Fixed by #17062
Assignees
Labels
area:transform itype:bug regression This worked in a previous version but doesn't anymore
Milestone

Comments

@WojciechMazur
Copy link
Contributor

WojciechMazur commented Feb 27, 2023

Regression found in Open CB for 47degrees/github4s : build logs

Compiler version

3.3.1-RC1-bin-20230224-c1809bc-NIGHTLY

Last good release: 3.3.1-RC1-bin-20230218-7c9c72a-NIGHTLY
First bad release: 3.3.1-RC1-bin-20230220-e65f6a6-NIGHTLY

Bisect points to b509104 but this commit seems to introduce other regression (different errors), which probably has been fixed.

error while loading Typeable$package,
class file scala/reflect/Typeable$package.class is broken, reading aborted with class dotty.tools.tasty.UnpickleException
TASTy signature has wrong version.
 expected: {majorVersion: 28, minorVersion: 4 [unstable release: 1]}
 found   : {majorVersion: 28, minorVersion: 3 [unstable release: 1]}

This TASTy file was produced by an unstable release.
To read this TASTy file, your tooling must be at the same version.
The TASTy file was produced by Scala 3.3.0-RC2.
Note that your tooling is currently using an unstable TASTy version.
error while loading package$package,
class file scala/compiletime/package$package.class is broken, reading aborted with class dotty.tools.tasty.UnpickleException
TASTy signature has wrong version.
 expected: {majorVersion: 28, minorVersion: 4 [unstable release: 1]}
 found   : {majorVersion: 28, minorVersion: 3 [unstable release: 1]}

This TASTy file was produced by an unstable release.
To read this TASTy file, your tooling must be at the same version.
The TASTy file was produced by Scala 3.3.0-RC2.
Note that your tooling is currently using an unstable TASTy version.
-- Error: /workspace/dotty/bisect/activities.scala:3:25 ------------------------
3 |trait Activities extends github4s.utils.BaseIntegration{
  |                         ^
  |       package scala.compiletime does not have a member method erasedValue
error while loading $throws$package,
class file scala/runtime/$throws$package.class is broken, reading aborted with class dotty.tools.tasty.UnpickleException
TASTy signature has wrong version.
 expected: {majorVersion: 28, minorVersion: 4 [unstable release: 1]}
 found   : {majorVersion: 28, minorVersion: 3 [unstable release: 1]}

This TASTy file was produced by an unstable release.
To read this TASTy file, your tooling must be at the same version.
The TASTy file was produced by Scala 3.3.0-RC2.
Note that your tooling is currently using an unstable TASTy version.
error while loading Predef,
class file scala/runtime/stdLibPatches/Predef.class is broken, reading aborted with class dotty.tools.tasty.UnpickleException
TASTy signature has wrong version.
 expected: {majorVersion: 28, minorVersion: 4 [unstable release: 1]}
 found   : {majorVersion: 28, minorVersion: 3 [unstable release: 1]}

This TASTy file was produced by an unstable release.
To read this TASTy file, your tooling must be at the same version.
The TASTy file was produced by Scala 3.3.0-RC2.
Note that your tooling is currently using an unstable TASTy version.
-- Error: /workspace/dotty/bisect/activities.scala:4:9 -------------------------
4 |  println(this.ioRuntime)
  |         ^
  |        package scala.compiletime does not have a member method summonFrom
-- Error: /workspace/dotty/bisect/integration.scala:3:0 ------------------------
3 |trait Runtime
  |^
  |package scala.compiletime does not have a member method erasedValue
-- Error: /workspace/dotty/bisect/integration.scala:6:2 ------------------------
6 |  protected implicit val ioRuntime: Runtime = ???
  |  ^
  |  package scala.compiletime does not have a member method erasedValue
-- Error: /workspace/dotty/bisect/integration.scala:5:15 -----------------------
5 |abstract class BaseIntegration:
  |               ^
  |        package scala.compiletime does not have a member method summonFrom
-- Error: /workspace/dotty/bisect/integration.scala:8:26 -----------------------
8 |class Integration extends BaseIntegration, github4s.integration.Activities
  |                          ^
  |       package scala.compiletime does not have a member method erasedValue
10 errors found
The new compilation error was introduced later in 9a9834e

Overall bisect points to a range commits 7c9c72a..e65f6a6

Minimized code

// file1.scala
package  github4s.utils

trait Runtime

abstract class BaseIntegration:
  protected val ioRuntime: Runtime = ???

class Integration extends BaseIntegration, github4s.integration.Activities
// file2.scala
package github4s.integration

import github4s.utils.BaseIntegration

trait Activities extends BaseIntegration{
  println(this.ioRuntime)
}

It compiles when ioRuntime is either public or defined as def

Output

-- Error: /workspace/dotty/bisect/integration.scala:8:6 ------------------------
8 |class Integration extends BaseIntegration, github4s.integration.Activities
  |      ^
  |parent trait Activities has a super call which binds to the value github4s.utils.BaseIntegration.ioRuntime. Super calls can only target methods.
1 error found

Expectation

Probably should compile, but should be confirmed if 9a9834e works as expected. If so this issue can be used as a example of source compatibility breakage in 3.3.1 or 3.4.x

@WojciechMazur WojciechMazur added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 27, 2023
@szymon-rd szymon-rd added regression This worked in a previous version but doesn't anymore area:transform and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 28, 2023
@dwijnand dwijnand self-assigned this Mar 6, 2023
@dwijnand dwijnand linked a pull request Mar 7, 2023 that will close this issue
@Kordyjan Kordyjan added this to the 3.3.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:transform itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants