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

Use Scala 2 library TASTy in compilation tests #18590

Closed

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Sep 25, 2023

FIXME

  • Fix issue with AnyVal $extension methods (fix: Scala2x flag + tasty attributes)
  • Issue with inline match (fix: Scala2Tasty flag)
  • Issue with the source of Predef vs. Predef overwrites
  • Regression in pattern matching in bytecode tests (mining optimizations?)
  • Issue with initialization checker
  • Issue with capture checking
  • New pure statement warnings (update checkfiles)
  • Issue in dotty.tools.dotc.transform.PatmatExhaustivityTest (update checkfiles)
  • Issue in dotty.tools.dotc.coverage.CoverageTests

@nicolasstucki nicolasstucki self-assigned this Sep 25, 2023
@nicolasstucki nicolasstucki force-pushed the use-scala2-library-tasty-in-tests branch 2 times, most recently from cb69307 to fe7a520 Compare September 29, 2023 13:04
@nicolasstucki nicolasstucki force-pushed the use-scala2-library-tasty-in-tests branch from fe7a520 to 5fa3409 Compare October 13, 2023 10:07
This is needed if we want to do setup transforms as part of denotation transformers.
 1. Update symbols owner before recursing to children, so that new owners
    taking account of try block owners are installed.
 2. Query owner chaines at phase checkCpatures when computing enclosing level owners.
I tried several other strategies, but nothing worked.

 - update after Setup: This means we cannot to levelOwner during setup.
 - running levelOwner after Setup causes CyclicErrors when transforming symbols
   in Setup
 - having a seperate notion of ccOwner maintained in a CCState table does
   not work since there are too many hidden uses of owner everywhere that
   would ignore that table.
(except if they are updated). This is the first step towards converting
to capturing types in SymTransformer, where we have the context.
Need to copy the denotation, since denotations come with next pointers
which would get scrambled otherwise.
Makes things more regular and allows for a
non-identity mapping between declared types and infos of vals.
The new check is that a publicly visible inferred type after capture checking
must conform to the type before capture checking (which is also the type seen
by other separately compiled units).
Widen singleton types when instantiating local roots in checkConforms
Don't force info when checking whether something is a root capability while printing
Refactor everything so that now vals as well as defs can be level owners
Innstead of traversing old types at postCheck, note what needs to be done
when these types are first transformed at Setup.
With the new way to construct capturing types at Setup, we can add the correct
boxing annotations there, so the previous unmodular hack can be dropped.
Break out operation to add a single element. This makes widenCaptures
redundant.
Avoid the mutable state in CapturSet.Var
odersky and others added 27 commits October 19, 2023 15:37
In Scala 2 a setter was created at Typer for private, non-local vars. Variance
 checking then worked on the setter. But in Scala 3, the setter is only created
later, which caused a loophole for variance checking.

This PR does actually better than Scala 2 in the following sense: A private variable
counts as an invariant occurrence only if it is assigned with a selector different
from `this`. Or conversely, a variable containing a covariant type parameter in its
type can be read from different objects, but all assignments must be via this. The
motivation is that such variables effectively behave like vals for the purposes
of variance checking.
We need to mark such assigns in the phase before PostTyper since they can
appear in companion objects that come after the variable declaration.
This was printing the extra debug information when testing tests/neg-deep-subtype/i1650.scala
The `Attributes` section contains a list of UTF-8 string that represent
the attributes.
Also introduce `Scala2Tasty` flag to differentiate between Scala 2
symbols that come from class files and Scala 2 symbols that come from
TASTy.

At this point, the only Scala 2 TASTy is the one from the standard
library. To know that a TASTy contains the definitions of the standard
library, we add the `Scala2StandardLibrary` attribute to the TASTy file.
We mark all unpickled classes from those TASTy files with `Scala2x | Scala2Tasty`.
The order of `Some` and `None` seem to have reversed. Not sure why and
if we should care about it.

The following seems to be a valid error but with the wrong error message:
```
-- Error: tests/patmat/t4408.scala:3:16 ----------------------------------------
3 |    case Nil => Unit
  |                ^^^^
  |Reference to object Unit in package scala should not have survived,
  |it should have been processed and eliminated during expansion of an enclosing macro or term erasure.
```
* With the tasty library we are not tagging these methods with the Case flag
* The case accessors are listed as vals and not methods
@nicolasstucki nicolasstucki force-pushed the use-scala2-library-tasty-in-tests branch from 7b55dc2 to 8d7a901 Compare October 19, 2023 14:31
@nicolasstucki
Copy link
Contributor Author

Replaced with #18875

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.

9 participants