Commit Graph

2624 Commits

Author SHA1 Message Date
Grigorii Kirgizov 14130be21f Relax another test in bl typechecking (Ignore error types)
It's unclear for now how exactly this case should be handled
2020-07-31 11:36:02 +03:00
Grigorii Kirgizov 856210a5ba Migrate langs extending 'convertsTo' handling from blExt types (MPSCR-63) 2020-07-31 11:36:02 +03:00
Grigorii Kirgizov 6fdc42ac78 Add script for migraiting convertsTo relation to use ConvertsContext (MPSCR-63) 2020-07-31 11:36:02 +03:00
Grigorii Kirgizov 42240e4ba7 Relax one test for bl typechecking (ignore error types)
Can't properly handle this case now.
To handle this case of no type of initializer in assignment context
need to discern cause of this "no type". If it's because of error --
then can't assign to it any type. If there were no error
(e.g. case of test) -- then type can be inferred from assignment ctx.

Anyway it's not very important corner case, can leave this test relaxed.
2020-07-31 11:36:02 +03:00
Grigorii Kirgizov e94ea9955c Refactor primitive conversion with narrowing option and fix var decl checking (MPSCR-63)
According to JLS, narrowing is allowed in assignment context,
but forbidden e.g. in invocation context.
2020-07-31 11:36:02 +03:00
Grigorii Kirgizov e2eb0f4647 Add context options to conversion relation (MPSCR-63) 2020-07-31 11:36:01 +03:00
Fedor Isakov db78950cf3 Rebuild sample. 2020-07-30 17:39:21 +02:00
Fedor Isakov 517838cbc1 Implement shortcut solution for occurrsCheck.
Make use of MutableLogical's feature to track usages count.
A logical with 1 or less usages can't be contained in
another term, so it's safe to skip unification in this case.
2020-07-30 17:14:40 +02:00
Fedor Isakov c282911a3c Provide support for tracking usages number of MutableLogical. 2020-07-30 17:14:40 +02:00
Fedor Isakov fe1df249d5 Reinstate "specific" rules in ExpectType, avoid slowdown.
Matching on two constraints without an "anchor" (origin)
is essentialy quadratic. On a large root there may be
many typeof/expectType instances and it slows down the
computation considerably.
2020-07-30 17:14:40 +02:00
Fedor Isakov 3377001494 Avoid recursing into method body when processing signature. 2020-07-30 17:14:40 +02:00
Fedor Isakov 102d13df0a Typechecking templates: use memo to cache expensive computations. 2020-07-30 17:14:40 +02:00
Fedor Isakov b5286d2671 Rely on memo to cache results of template application. 2020-07-30 17:14:40 +02:00
Fedor Isakov 32b11c0c7f Introduce memo expression to enable memoization of values.
During template application memo can be used to store results
of a computation in the session. The memo will be automatically
cleared on an event that invalidates the caches.
2020-07-30 17:14:40 +02:00
Fedor Isakov 4f74f192b4 Refactor typechecking state/results API for readability.
A bunch of renames:
TypesIndex -> TypecheckingResultsCache,
TypecheckingCache -> TypecheckingState.
Simplify methods that update caches.
2020-07-30 17:14:36 +02:00
Fedor Isakov 301c0993d7 Execute outstanding migrations. 2020-07-30 17:14:32 +02:00
Grigorii Kirgizov 43e39ca4a1 Clear LogicalState for occurrences dropped during incremental invalidation 2020-07-28 18:53:41 +03:00
Grigorii Kirgizov f13691668c Fix accidental var shadowing that led to report items not collected with IncrementalStrategy 2020-07-28 18:53:41 +03:00
Grigorii Kirgizov 2a0d4ef076 Observe all unbound logicals inside Occurrence to check contract (MPSCR-66)
Previously only logicals directly used ar occurrence args
were observed. Now terms in occurrence args are traversed
recursively and all contained logicals are observed.

Also clear occurrence contract observers on discarding occ-s.
Introduce a generic way to clear observers in LogicalState.
2020-07-28 18:53:41 +03:00
Grigorii Kirgizov 3ef1c53a85 Move TermWalker from tests package to core.internal to reuse for MPSCR-66
Also convert it to Kotlin
2020-07-28 18:53:41 +03:00
Grigorii Kirgizov b87ae4b03a Produce warning when program can't be executed incrementally, but it's requested 2020-07-28 18:53:41 +03:00
Grigorii Kirgizov 3eebe8cd03 Refactor creation of IncrProgramSpec: allow later spec config (for MPSCR-66)
IncrProgramSpec influencing program eval is built from two sources:
internal analysis results & typechecking options.
Providing spec builder instead of spec allows to combine these
sources later at program pipeline creation in TypecheckingService.

Commit accomodates to addition of IncrementalSpec.Enabled.Unsafe
Commit also simplifies ProgramAnalysis -related classes.
Renames BasicProgramAnalysis to PrincipalsAnalysis.
2020-07-28 18:53:41 +03:00
Grigorii Kirgizov 54335cb2fd Introduce incrementality-allowed levels: No, Unsafe, Yes
Instead of simple allowed/not option sometimes Unsafe
is useful. 'Unsafe' status may be present when there're
few "bad" rules.
With this level end code may resolve to go with
incrementality without strict guarantees.
2020-07-28 18:53:41 +03:00
Grigorii Kirgizov f6d7f5c4bd Refactor the way IncrPogramSpec is provided: explicitly pass as Step input 2020-07-28 18:53:41 +03:00
Grigorii Kirgizov 6339b5128b Add option to Typechecking page for enabling incremental contract assertions (MPSCR-66) 2020-07-28 18:53:41 +03:00
Grigorii Kirgizov 0d0813d352 Add logical incr contract assertions as observers (implements MPSCR-66) 2020-07-22 15:51:56 +03:00
Grigorii Kirgizov 0fd3311c04 minor: upd test model dependencies (import j.m.lang.text) 2020-07-22 15:51:56 +03:00
Grigorii Kirgizov c6a4e9ede3 Use opaque feedback keys (rule match ids) instead of rule unique tag
According to changes in prev commin in reactor
2020-07-22 15:27:46 +03:00
Grigorii Kirgizov f2d1f089ad Use rule match identity as feedback key for TypesIndex instead of rule unique tag
It seems to reflect the exact information needed: there's
one-to-one correspondence between feedback and its match.
While using rule unique tag as feedback key in TypesIndex
relied on several assumptions.
Also there's less use of MatchJournal information with this.
Previously parent principal match was passed to FeedbackConsumer.
2020-07-22 15:27:46 +03:00
Grigorii Kirgizov 53a5d2f489 Disable one test for substructural TS (most general case of MPSCR-65) 2020-07-22 15:27:46 +03:00
Grigorii Kirgizov d9b984aee9 minor: modify expectType test according to fix of MPSCR-64
Fix expands notion of principal rules so that failed rules
are now principal. It's reflected in this change to test.
2020-07-22 15:27:46 +03:00
Grigorii Kirgizov 504261014a Modify principal constraint analysis: consider rules without origin (fixes MPSCR-64)
Also output warning on rules violating contract for non-principal rules
2020-07-22 15:27:46 +03:00
Fedor Isakov 3c2b3a2ee2 Fix incremental tests by checking for error type. 2020-07-22 15:27:46 +03:00
Fedor Isakov 4fc8e0cc34 Fix tests by disabling checks that fail because of missing features.
Error type is produced where there was no type before.
2020-07-22 15:27:45 +03:00
Fedor Isakov a3a5fca318 Disable "specific" rules in favour of "generic" ones in ExpectType.
The generic rules make the code more compact and readable.
2020-07-22 15:27:45 +03:00
Grigorii Kirgizov 5bea95f1ab Change `convertsToSafe` signature so it isn't considered principal (required for MPSCR-64)
Just wrap used 'node'-typed argument in a term constructor.
It's not principal according to incrementality contract described in MPSCR-66
2020-07-22 13:09:52 +03:00
Grigorii Kirgizov 3093b4678c Implement incremental handling of discarded principal occurrences (MPSCR-65)
Matches which discard principal occurrences must be handled specially
on incremental execution. Imagine such match inserted in journal
before other matches with the same occurrence in head.
Because inserted match discards the occurrence, following matches
can't match on it. They must be invalidated. (Relevant for MPSCR-62)
See tests for substructuralTS.

Commit refactors machinery of `dropDiscardingMatchesFor` in
ConstraintsProcessing that was incomplete, as revealed by MPSCR-64.

Relaxes small memory opt introduced in commit a2675351:
Now justifications in Occurrences are not shared with their
activating matches. See JustifiedOccurrenceCreator.
Introduced machinery requires that Occurrences had their own
Evidence (because `dropDiscarding` invalidates by Occurrences).
Previously algorithm was invalidating Chunks only by Evidence
from rule matches, that's why only RuleMatches had to have
unique Evidence, while Occurrences could bear less info.
2020-07-22 13:09:52 +03:00
Grigorii Kirgizov 8cb6aa72d3 minor refactorings in engine (some moves & renames) 2020-07-22 13:09:52 +03:00
Grigorii Kirgizov 3bdc1123ad Incr engine: refine reexecution position for reactivated occurrences
In short, this change restricts information algo needs from journal.
It restricts how far invalidation stage goes into journal.
Previously it fed ExecQueue with position arbitrarily far in 'past',
whereas now it feeds the closest valid position (the 'present').
2020-07-22 13:09:52 +03:00
Grigorii Kirgizov 76b37c3f3e minor refactorings in engine
Refine interface of RuleMatchEx to use Occurrence,
move one of its function as ext fun (as in TODO).
Fix duplication of extension functions for IncrSpec.
Ensure some contracts in ExecutionQueue.
2020-07-22 13:09:52 +03:00
Grigorii Kirgizov ef7f66dd3e Minor fix: always reset journal in incremental session.
Without it in certain cases ConcurrentModificationException
(on internal journal linked list) could arise.
2020-07-22 13:09:52 +03:00
Grigorii Kirgizov f402ce33c8 Don't clear Dispatcher state for discarded match heads: it's unnecessary 2020-07-22 13:09:52 +03:00
Grigorii Kirgizov 53d0bd2060 Add tests for substructural typesystems (MPSCR-65) & reproduce MPSCR-64
These typesystems will probably extensively use discarded constraints.
So need more tests for these cases.
2020-07-22 13:09:52 +03:00
Fedor Isakov 24a471a2c9 Re-save models. 2020-07-21 17:03:41 +02:00
Fedor Isakov a0df862186 Temporary support for generation mode: use calcTypeLocally. 2020-07-21 17:03:41 +02:00
Fedor Isakov 0088532d87 Temporary fix for "raw" types: set allowUncheckedConversion=true in coerceTo query.
In with the above flag set to false a conversion of list<T> to list (raw type)
fails, because the latter is represented as list<Object>. (T is any type).
This situation usually arises from queries like coerce(T to concept=ListType).
2020-07-21 17:02:17 +02:00
Fedor Isakov 96918d0e1d Support for processing input nodes recursively or not. Optimizing local typechecking.
The flag "recursive" is passed down to ProgramFactory to control whether
the input nodes are to be walked recursively.
This flag is set to false when calculating a node's type in isolation.
2020-07-21 17:02:17 +02:00
Fedor Isakov 90e90540dc Initial support for j.m.lang.typesystem lang's types. 2020-07-21 17:02:17 +02:00
Fedor Isakov 49f81cbd9b Fix Show Type action to use checkTypeLocally() and report trace/errors properly. 2020-07-21 17:02:17 +02:00
Fedor Isakov 8e1bd7b931 Minor refactoring in TypecheckingCache. Provide separate non-tracking cache.
TypecheckingCache maintains two maps of root-to-cache: tracking and non-tracking.
Tracking cache is used in "watching" mode, caching mode doesn't require tracking.
Always merge the results of typechecking, avoid replacing the cached data.
Reimplement calcTypeLocally() to rely on cache for storing the resulting type.
Simplify cache API.
Fix TypecheckingTestHelper.
2020-07-21 17:02:17 +02:00