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

Conflicting base type arguments error in RC2 #11995

Closed
gzoller opened this issue Apr 5, 2021 · 3 comments · Fixed by #12000
Closed

Conflicting base type arguments error in RC2 #11995

gzoller opened this issue Apr 5, 2021 · 3 comments · Fixed by #12000
Milestone

Comments

@gzoller
Copy link
Contributor

gzoller commented Apr 5, 2021

Compiler version

RC2

Minimized code

case class IntersectionTypeAdapter[L, R](
    info: RType,
    leftTypeAdapter:  TypeAdapter[L],
    rightTypeAdapter: TypeAdapter[R])(implicit taCache: TypeAdapterCache)
  extends TypeAdapter[L & R]:

Output

[error] -- Error: /Users/gregoryzoller/git/junk/src/main/scala/co.blocke.junk/Junk.scala:17:11
[error] 17 |case class IntersectionTypeAdapter[L, R](
[error]    |           ^^^^^^^^^^^^^^^^^^^^^^^
[error]    |class IntersectionTypeAdapter cannot be instantiated since it has conflicting base type arguments L and R

Expectation

No errors expected. This code worked for all Scala 3 until RC2

@odersky
Copy link
Contributor

odersky commented Apr 5, 2021

Can you provide a self contained example?

This looks like a problem caused by some tightenings of the rules to prevent a soundness hole.

@gzoller
Copy link
Contributor Author

gzoller commented Apr 6, 2021

Surely. Here's a further-minimized, stand-alone example:

trait MyBase[A]{ 
  def foo: String
}

case class BothThing[L, R]() extends MyBase[L & R]:
  def foo: String = "blather"

This produces:

[error] 15 |case class BothThing[L, R]()
[error]    |           ^^^^^^^^^
[error]    |class BothThing cannot be instantiated since it has conflicting base type arguments L and R
[error] one error found

@adamgfraser
Copy link
Contributor

I think we are seeing a version of this in trying to upgrade ZIO to 3.0.0-RC2. Minimized example:

trait Has[A]

trait Console
trait Clock

type ConsoleWithClock = Has[Console] with Has[Clock]

class Spec[R <: Has[_]]

object MySpec1 extends Spec[Has[Console] with Has[Clock]] // does not compile
object MySpec2 extends Spec[ConsoleWithClock] // okay

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.

4 participants