Skip to content

The atom of a module class is its module val #10106

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

Merged
merged 1 commit into from
Oct 29, 2020

Conversation

smarter
Copy link
Member

@smarter smarter commented Oct 27, 2020

In firstTry we've long had the following special-case:

if (sym1.is(ModuleClass) && sym2.is(ModuleVal))
  // For convenience we want X$ <:< X.type
  // This is safe because X$ self-type is X.type
  sym1 = sym1.companionModule

It turns out that this isn't enough nowadays because atoms on a module
class returned Atoms.Unknown so X$ | Y$ <:< X.type | Y.type returned
false. This commit fixes this by special-casing atoms for module
classes. Alternatively, we could drop all special-casing of module
classes and module vals in the subtype checker, but that would require
making sure that we never widen module vals anywhere which seems tricky.

In `firstTry` we've long had the following special-case:

    if (sym1.is(ModuleClass) && sym2.is(ModuleVal))
      // For convenience we want X$ <:< X.type
      // This is safe because X$ self-type is X.type
      sym1 = sym1.companionModule

It turns out that this isn't enough nowadays because `atoms` on a module
class returned `Atoms.Unknown` so `X$ | Y$ <:< X.type | Y.type` returned
false. This commit fixes this by special-casing `atoms` for module
classes. Alternatively, we could drop all special-casing of module
classes and module vals in the subtype checker, but that would require
making sure that we never widen module vals anywhere which seems tricky.
@smarter smarter force-pushed the fix-module-class-atom branch from 43fa599 to ef468bc Compare October 27, 2020 18:30
@odersky odersky merged commit 72a8809 into scala:master Oct 29, 2020
@odersky odersky deleted the fix-module-class-atom branch October 29, 2020 15:13
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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

Successfully merging this pull request may close these issues.

3 participants