Skip to content

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

Closed
@WojciechMazur

Description

@WojciechMazur

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions