Skip to content

Regression in ist-dsi/scala-keystone-client #18351

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 Aug 7, 2023 · 2 comments · Fixed by #18467
Closed

Regression in ist-dsi/scala-keystone-client #18351

WojciechMazur opened this issue Aug 7, 2023 · 2 comments · Fixed by #18467
Assignees
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore

Comments

@WojciechMazur
Copy link
Contributor

WojciechMazur commented Aug 7, 2023

Regression found in Open CB for ist-dsi/scala-keystone-client - build logs

Compiler version

3.3.1-RC1-bin-20230204-a356581-NIGHTLY
3.3.1-RC4
Bisect points to 11854bb

If you're not sure what version you're using, run print scalaVersion from sbt
(if you're running scalac manually, use scalac -version instead).

Minimized code

abstract class Service[F[_]](val name: String)
abstract class CrudService[F[_]](name: String) extends Service[F](name)

trait Foo[F[_]] { self: CrudService[?] =>
  val x = self.name
}

Output

-- [E008] Not Found Error: /Users/wmazur/projects/dotty/bisect/main.scala:6:15 -
6 |  val x = self.name
  |          ^^^^^^^^^
  |value name is not a member of CrudService[?[_$2]] & Foo[F] - did you mean (Foo.this : CrudService[?[_$2]] & Foo[F]).name?

Expectation

I'm not sure if it's a fix of corner case or real regression, it's only present when using at least 1 wildcard type. When defining self: CrudService[F] => it fails with every stable Scala version

> scala-cli compile  --server=false bisect/main.scala -S 3.0 
-- [E008] Not Found Error: /Users/wmazur/projects/dotty/bisect/main.scala:6:15 -
6 |  val x = self.name
  |          ^^^^^^^^^
  |value name is not a member of CrudService[F] & Foo[F] - did you mean (Foo.this : CrudService[F] & Foo[F]).name?
@WojciechMazur WojciechMazur added itype:bug area:typer regression This worked in a previous version but doesn't anymore labels Aug 7, 2023
@prolativ
Copy link
Contributor

prolativ commented Aug 8, 2023

It looks like the type parameters were only hiding the original problem. The snippet below compiles in scala 2 but doesn't compile in any release of scala 3

class Service(val name: String)
class CrudService(name: String) extends Service(name)

trait Foo { self: CrudService =>
  val x = self.name
}

It seems like the problem is in the clash of names between the parameter name: String of the subclass CrudService and the parameter member val name: String of the superclass Service.
If we remove the clash, e.g.

class Service(val name: String)
class CrudService(name1: String) extends Service(name1)

trait Foo { self: CrudService =>
  val x = self.name
}

the code compiles successfully

@odersky
Copy link
Contributor

odersky commented Aug 28, 2023

@prolativ Great minimization! That helped me not going down some other rabbit holes.

Kordyjan added a commit that referenced this issue Aug 29, 2023
Previously, we rejected the case where a symbol of a self type selection
was private if it was not of the enclosing class. But that symbol could
shadow a non-private symbol in a base class, so have to treat that case
as well.

Fixes #18351
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typer 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.

3 participants