Skip to content

First version of capture checker based on rechecking #13309

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
Sep 29, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Aug 17, 2021

No description provided.

@odersky odersky added the cc-experiment Intended to be merged with cc-experiment branch on origin label Aug 17, 2021
@odersky odersky force-pushed the add-cc2 branch 3 times, most recently from da5a95a to 84245ac Compare August 24, 2021 20:17
@odersky odersky force-pushed the add-cc2 branch 5 times, most recently from 7c8156f to f410498 Compare September 4, 2021 10:00
@odersky odersky force-pushed the add-cc2 branch 2 times, most recently from 4e93846 to 98f6c68 Compare September 6, 2021 11:30
@odersky odersky force-pushed the add-cc2 branch 2 times, most recently from b35eeb0 to b31a247 Compare September 18, 2021 18:23
@odersky odersky force-pushed the cc-experiment branch 2 times, most recently from f051ca7 to 8a9a37e Compare September 24, 2021 17:07
@odersky odersky force-pushed the add-cc2 branch 4 times, most recently from 0425780 to 467fc6a Compare September 28, 2021 09:17
A squashed version of the following commits:

Handle byname parameters
Don't force symbol completion when printing flags or annotations
Check overrides and disallow non-local inferred capture types
Handle `this` in capture sets
Print capture variable dependencies under -Ydebug-cc
Avoid spurious error message

Avoid spurious error message
"cannot be tracked since its capture set is empty".

This arose in lazyref.scala for a DependentTypeTree in an anaonymois function.
Dependent type trees map to normal TypeTrees, not InferredTypeTrees (and things
go wrong if we try to change that).
Drop TopType

Consider bounds of type variables to be boxed
More tests
Avoid multiple maps when creating symbol infos

Use a single BiTypeMap to map from inferred result and parameters
to method info.

This improves efficiency and debuggability by reducing the frequence of
multiple stacked maps capture sets.
Refactor with CompareResult#andAlso
Refactoring: use isOK on CompareResult
Reflect inferred parameter types in enclosing method type

The variables in the inferred parameter type of an anonymous function need
to also show up in the closure type itself, so that they can be constrained.
Don't interpolate parameters of anonymous functions

Here, we should wait until we get the info from the outside, which can
be arbitrarily much later.
Compute upper approximation of bimapped sets from both sides
Fail when trying to add new elements to mapped sets

It's the safe option.
Print full origin trail of derived capture sets under -Ycc-debug
Fix isEmpty condition in well-formedness check
Make printing capture sets dependent on -Ycc-debug
Recursion brake for upperApprox
Fixes to upperApprox
Make instantiteRT a BiTypeMap

Otherwise we will not be able to do upper approximations of parameters.
Interpolate only variables at negative polarity

Interpolating covariant variables risks restricting capture sets to early.
For instance, when a variable has the capture set of a called function in
its capture set. When we have indirectly recursive calls it could be that
the capture set of a called function is not yet fully formed.
Interpolate type variables when symbols are completed
Allow for possibility that variables are constant
Only recomplete symbols if their info changes
Add completions to Rechecker

Complete val and def definitions lazily on first access. Now,
recheckDefDef and recheckValDef are called the first time the
new info of the defined symbol is needed, or, if the info is
never needed, when the typer gets to the definitions. This
only applied to definitions with inferred types. The others
are handled in typer sequence, as before.

The motivation of the change is that some modifications to
inferred types of symbols can be made in subclasses without
running into ordering problems.
More fixes for subCapture
New setting -Ycc-debug for more info on capture variables
Fix subCapture in frozen state

Previously, we still OKed two empty variables to be compared with
subcapture in the frozen state. This should give an error.
Direct comparisons of dependent function types
Revert: Special treatment of dependent functions in TypeComparer
change test
Also treat explicit capturing type arguments as boxed
Print subcapturing steps in -explain traces
Don't decorate type variables with additional capture sets
Boxed CapturingTypes
Drop unsound capture suppression if expected type is boxed

If expected type is boxed, the expression still contributes to the captured
variables of its environment.
Re-infer result types of anonymous functions
Keep erased implicit args
Special treatment of dependent functions in TypeComparer
Fix addFunctionRefinements
Always print refined function types as dependent functions.

Makes it easier to see what goes on.
Make CaptureSet ++ and ** simplify more
Refine function types when reinferring so that they can be dependent
Fix avoidance problem when typing blocks

We should not pass en expected type when rechecking the expression
of a block since that can add local references to global capture set variables.

Also: tests for lists and pairs
Print empty variables with "?"
Fix printing untyped annotations
Fix printing annotations in trees
Drop redundant code
Refactor map operations on capture sets
Intoduce Bi-Mapped CaptureSets

Report an error is a simply mapped capture set gets new elements that do not come
from the original souurce. Introduce a new abstraction of bi-mapped sets that accept
new elements and propagate them to the original source.
Add map operation to SimpleIdentitySet
Restrict tracked class parameters to vals
Handle local classes and secondary constructors
Fix CapturingType precedence when printing
First stab at handling classes
Bug fixes

 1. Fix canBeTracked for TermRefs

    only TermRefs where prefix is NoPrefix or `this` can be tracked. The
    others have to be widened.

 2. Fix rule for comparing capture refs on the left

 3. Be more careful where comparisons are frozen
Capture checker for functions
@odersky
Copy link
Contributor Author

odersky commented Sep 29, 2021

Going to merge now, to make room for more finegrained PRs.

@odersky odersky merged commit 06f83ce into scala:cc-experiment Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cc-experiment Intended to be merged with cc-experiment branch on origin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant