Commit Graph

838 Commits

Author SHA1 Message Date
Fedor Isakov caca5e606f Fix failing CI build because of empty test case 2021-02-05 12:12:48 +01:00
Fedor Isakov dee5db0e96 Drop instances of TermFeature.final property 2021-02-04 18:01:10 +01:00
Fedor Isakov d362da6a60 Rebuild project 2021-02-04 18:01:10 +01:00
Fedor Isakov ed55370a01 Fix model imports (hamcrest lib has been moved to another solution) 2021-02-04 12:27:55 +01:00
Fedor Isakov 7fe5a5ad7a Auto-updated files after migrating to MPS 2021.1 EAP 2021-02-04 12:26:59 +01:00
Fedor Isakov ecf7eec55a SModel types: fix type of isSubtypeExpression 2021-02-04 08:51:00 +01:00
Fedor Isakov 2f0f2e5b13 BL types: support coerce to target type query kind 2021-02-04 08:51:00 +01:00
Fedor Isakov 4d1cdacfe2 BL types: avoid failure on typechecking BaseMethodCall
BaseMethodCall doesn't always have an enclosing classifier.
2021-02-04 08:51:00 +01:00
Fedor Isakov ad269bb6b5 Ensure typechecking state is properly disposed of on reload 2021-02-04 08:51:00 +01:00
Grigorii Kirgizov 40a93d5ba9 Temporarily disable one failing test in IncrClassHierarchy; Preamble tests
Preamble tests should be reviewed. It's also unclear
whether preamble feature is effective and needed at all.
2021-01-29 16:21:57 +03:00
Grigorii Kirgizov 64762bf100 Fix bl tests (several test were failing after some of changes) 2021-01-29 13:39:35 +03:00
Grigorii Kirgizov 4dac9e794a Fix assignment of 'null' ret type in closures with insufficient infer info. Add require. 2021-01-29 13:39:35 +03:00
Grigorii Kirgizov 148223a842 Add incremental tests for lambda calc. Enable ignored tests for closures. 2021-01-29 13:39:35 +03:00
Fedor Isakov 2b46ab0413 BL types: ensure any type converts to Type 2021-01-23 16:59:46 +01:00
Fedor Isakov 2b6de60ebc BL types: Drop runtimeType term and its usages 2021-01-23 16:59:42 +01:00
Fedor Isakov 1389f9429f Rebuild project 2021-01-08 11:00:02 +01:00
Fedor Isakov 62e8e7d013 Switch to MPS 2020.3 release. 2021-01-08 11:00:02 +01:00
Fedor Isakov 0a77dcb33b Coderules types: fix unifiable relation, add missing typing rules 2021-01-06 12:43:55 +01:00
Fedor Isakov a9643c03b8 Logic types: fix indexed variable, make logical a supertype of its parameter 2021-01-06 12:43:55 +01:00
Fedor Isakov aec8c3f9d9 SModel types: type for concept method call 2021-01-06 12:43:55 +01:00
Fedor Isakov 143fb9cf57 Generator lang types: fix a typo 2020-12-30 18:28:46 +01:00
Fedor Isakov 6f92d666f7 BL types: a few fixes, stabilize typechecking
Support Type type.
Simplify depdendency of var decl to its type.
Covariant subtyping for UpperBoundType.
Straightforward dependencies on type's parameters.
Specify BaseConcept as general type's concept.
Fix method reference.
2020-12-30 18:28:46 +01:00
Fedor Isakov 4acae7a1b7 SModel types: minor fixes
Support SConceptLiteralType.
Drop rogue .pointer operation.
Build proper term for enumMember type.
2020-12-30 18:28:46 +01:00
Fedor Isakov 51d5687e1a Add missing language modules to mpscore project 2020-12-30 18:28:45 +01:00
Fedor Isakov 862d7f62c2 Replace direct usages of test data with proper references, fix generation 2020-12-27 21:04:51 +01:00
Fedor Isakov 67c208a360 Drop support for a few concepts that have been dropped 2020-12-27 21:04:51 +01:00
Fedor Isakov 0584d05c4f Drop support for a concept that has been apparently dropped upstream 2020-12-27 20:42:07 +01:00
Fedor Isakov 66f04fe92a Replace direct usages of test data with proper references, fix generation 2020-12-27 20:42:07 +01:00
Fedor Isakov 435a8d4ec8 Replace direct usages of test data with proper references, fix generation 2020-12-27 20:20:21 +01:00
Fedor Isakov f5c9ed7c4b Temporarily change the extends clause of Array rule table
This particular extends clause breaks an internal invariant
of rules plan, namely the topological sorting of rule tables.
This results in broken rule index, which needs to be fixed.

Also, disable a suspect rule that relies no typeof()
*not* being present, which is a transient condition.
2020-12-27 16:39:22 +01:00
Fedor Isakov d87afd868e Closure types: use lub to compute the type of closure literal
Multiple "exit points" in closure literal may have different types.
Calculate lub of these types and use it as returned type.
2020-12-27 16:04:06 +01:00
Fedor Isakov 182ea97cc1 BL internal types: support internal class 2020-12-27 16:04:06 +01:00
Fedor Isakov 2ef3176bc2 BL types: extend lub to primitive types via boxing 2020-12-27 16:04:06 +01:00
Fedor Isakov 621cdaa912 Implement lub for sequence type
Using the fact that sequence type is covariant, just forward
to lub for parameters.
2020-12-27 16:04:06 +01:00
Fedor Isakov 70d6dfefa1 Fix failing generation by disabling typechecking of cast expression
Cast expression must check the type of the argument expression
and ensure comparabitiy of types.
2020-12-27 16:04:06 +01:00
Fedor Isakov 1228ff036b BL types: substring expression, string conversion to classifier 2020-12-27 16:04:06 +01:00
Fedor Isakov 2a5163c0f4 BL types: support concept function and Void classifier 2020-12-27 10:36:00 +01:00
Fedor Isakov 7ecad792e0 Types for generator.generationContext lang 2020-12-27 10:36:00 +01:00
Fedor Isakov 4c0a06f904 Types for generator lang 2020-12-27 10:36:00 +01:00
Fedor Isakov b2c026d74a Fix closures types to populate functional classifier's parameters
On looking up the default functional classifier corresponding to a
function type, the classifier's type parameters are to be appropriately
populated from the function type.
2020-12-27 10:36:00 +01:00
Fedor Isakov cf85151dad Types for constraints lang 2020-12-27 10:36:00 +01:00
Fedor Isakov b2abb1fda2 Types for quotation lang 2020-12-27 10:36:00 +01:00
Fedor Isakov 8ab783657c Types for typesystem lang 2020-12-27 10:35:59 +01:00
Grigorii Kirgizov 27ed01c447 refactoring: Adjust uniqueTag usages for Rule.Tag refactoring
Fix rule basetag generation to coincide with templateName

Needed for PrincipalStore (occurrence cache) which uses
info about occurrence source rule template name.
2020-12-15 17:59:09 +03:00
Grigorii Kirgizov 3eccaf81a1 Introduce occurrence store as cache for their reuse in Queries strategy
It's important that program that uses occurrences from cache
shouldn't include rules that could produce their duplicates.
So implementation of occurence cache includes 2 parts:
on reactor level & in ProrgramFactory.

When RuleBuilders are produced, cache is queried whether
there're already  occurrences associated with the rule template
in question. If so -- then those RuleBuilders are not included
into the program (as well as all RuleBuilders required by it).
2020-12-15 17:59:05 +03:00
Grigorii Kirgizov 0dc072413e minor fix in BL typesystem: always check returns, it can influence resultiing type 2020-12-15 17:51:27 +03:00
Grigorii Kirgizov 61dccfd2d9 BL types: simplify array typing & fix minor errors 2020-12-15 17:51:27 +03:00
Grigorii Kirgizov b4c441a41e Add few incremental tests, tried reproduce MPSCR-82
Unsuccessfully. Algorithm is ok, problem is in UpdatesRecorder.
2020-12-15 17:51:23 +03:00
Fedor Isakov 1acd35baca SModel types: support conversion of SConcept to concept<> type 2020-12-15 13:30:13 +01:00
Fedor Isakov c7dd00bb7e Sequence types: support covariant subtyping of sequence<> type 2020-12-15 13:29:24 +01:00
Fedor Isakov 034f7afa98 BL types: add rules for NPE-safe comparison operators 2020-12-15 13:28:44 +01:00
Fedor Isakov c5fed5f2e0 BL and closure types: add necessary explicit dependencies. Fix tests.
In order to ensure properly functioning incremental typechecking
some explicit dependencies are to be declared.
2020-12-11 12:03:17 +01:00
Fedor Isakov 415590f2b2 Minor optimization: memoize calculation of functional methods. 2020-12-11 12:03:17 +01:00
Fedor Isakov c7eaa1dbf3 Clean up ProgramEvaluator API. Straighten up passing of session token. Drop RulesDiff usages. 2020-12-08 22:57:36 +01:00
Fedor Isakov 2ee4c30233 Add explicit dependencies to required sources. 2020-12-08 22:57:35 +01:00
Fedor Isakov b35aab4912 Minor types optimization: change memoizer key. 2020-12-01 22:50:01 +01:00
Fedor Isakov 60f59a7a80 Fix BL types: anonymous class creator has optional ref to constructor. 2020-11-29 00:16:51 +01:00
Fedor Isakov 044b707b77 Implement handlers for typeOf query in all types aspects. 2020-11-24 13:41:25 +01:00
Fedor Isakov a6fe5327ff Rebuild project. 2020-11-24 13:41:24 +01:00
Fedor Isakov 8691da9ad7 Update build script. 2020-11-24 13:41:24 +01:00
Fedor Isakov f313c1af9a Smodel types: support (unchecked) conversion classifier to node/nodeptr. 2020-11-24 13:41:24 +01:00
Fedor Isakov 80d2152df1 BL types: support as and instanceof 2020-11-24 13:41:24 +01:00
Fedor Isakov 17ad3b0ff7 Tuples types: conversions to unknown tuple and to classifier. 2020-11-24 13:41:24 +01:00
Fedor Isakov f627773585 Collections types: support coercion to sequence type, fix multi foreach.
Coerce to sequence type w/o element type is needed to find out
the element type of a collection.
2020-11-24 13:41:24 +01:00
Fedor Isakov 29f5992ff9 Fix logical type's conversion to classifier; fix generation.
Specifically treat convertsTo of LogicalType to ClassifierType, support
convertsTo classifier type w/o specified classifier.
Fix typeOf LogicalItemValueExpression by to rely on logical's type.
Accept LogicalItem in LogicalItemValueExpression's logical slot to enable
replacement of it with an expression at generation time.
2020-11-24 13:41:24 +01:00
Fedor Isakov fe16b80132 Refactor types in all mps foundation langs. Drop node-ptr usage as anchor in terms.
Drop node-ptr in node features, macro calls.
Drop node-ptr types in rule templates and recover closures,
fix BiConsumer params
Drop node-ptr// refs where appropriate.
Drop pointer operations from macro calls and term ctor's; add resolve to FunctionTypeLookup static table.
Drop node pointer operations from constraints, add require statements in SModel types macro table.
2020-11-24 13:41:24 +01:00
Fedor Isakov ba39d7d047 Fix NPE during processing of classifier type with null classifier. 2020-11-24 13:41:24 +01:00
Fedor Isakov bb5bddcc36 Add missing rules in coderules types. 2020-11-24 13:41:24 +01:00
Fedor Isakov 75f97618c9 Introduce cancelContravariance in closures types, fix type inference.
When inferencing the type of a closure within a method call context,
it's important to strip occasional contravariant indicator from the
closure's input variable.

A method may declare its argument to be an SMI with the type(s) of
its functional method's arguments as ? super T to facilitate subtyping.
This must not affect the inferred type of the closure's input variable.
2020-11-24 13:41:24 +01:00
Fedor Isakov 1180f33ef4 Add missing rule in BL internal types. 2020-11-24 13:41:24 +01:00
Fedor Isakov 24ed929715 Fix default class creator typechecking in baseLang.
Ensure valid list of context type var decls is passed to
instantiateScheme macro.

The code in MethodCall needs to be fixed in order to respect
context type variables in case of instantiation of a non-static inner class.
2020-11-24 13:41:24 +01:00
Grigorii Kirgizov f9239e4e40 minor: upd build.xml 2020-11-20 12:19:57 +03:00
Grigorii Kirgizov c44e3a7fd8 Upd buildscripts 2020-11-18 11:36:28 +03:00
Grigorii Kirgizov 271c93abfa Implement hashCode() in Hierarchy.Vertex classes to adhere to contract of constraint args
Contract stems from the fact that constraint args influence Rules hashes (unique tags)
and so must be stable under irrelevant changes for incremental logic
2020-11-18 11:36:28 +03:00
Grigorii Kirgizov 42bc7a88fd Modify incremental tests to allow testing other queries, add test 2020-11-18 11:36:28 +03:00
Grigorii Kirgizov 15cfd8a51b Refactor bl queries: separate "independent" query parts for Preamble 2020-11-18 11:36:28 +03:00
Fedor Isakov 51606b56c7 Rebuild project. 2020-10-23 12:26:31 +02:00
Grigorii Kirgizov 8bd1ba6590 Fix require statements given restriction of their semantics
Also explicitly require classifiers in Hierarchy rule table
2020-10-23 12:26:30 +02:00
Grigorii Kirgizov 9476f4bba5 Revert introduction of 'runtimeType" superterm (fixes MPSCR-74) 2020-10-23 12:26:30 +02:00
Grigorii Kirgizov 544e630ecb minor fixes in bl typesystem rules
Remove spurious input oriigin in dpromote_induction rule.
Remove unneeded CheckAll extends TypeBound.
Drop several unused rules.
2020-10-23 12:26:30 +02:00
Grigorii Kirgizov d9a35005e2 Fix cycle in coersion of functional type to unknown classifier (fixes MPSCR-72)
Use statically built FunctionTypes table in closures for
finding canonical functional type for a given closure.
2020-09-24 11:43:17 +03:00
Fedor Isakov 9886f0ec25 Re-saved models -- update resolve info. 2020-09-10 09:59:42 +02:00
Fedor Isakov 6da0ebee3f Update coderules/logic type templates (unfinished). 2020-08-20 15:02:54 +02:00
Fedor Isakov caa13a3533 Minor update: smodel type templates (unfinished). 2020-08-20 15:02:54 +02:00
Fedor Isakov e4a23ee50f Keep "types" model from deletion with a placeholder. 2020-08-20 15:02:54 +02:00
Fedor Isakov 89843bfac4 Fix build script for mpscore sample. 2020-08-17 20:30:01 +02:00
Fedor Isakov c9e4ddccbf Initial support for baseLanguageInternal types. 2020-08-17 17:19:34 +02:00
Fedor Isakov 8df7783b5b Typechecking BL: introduce templates for GenericLValueExpression. 2020-08-17 17:19:34 +02:00
Fedor Isakov 54439e255e Refactor typechecking state/cache subsystem.
Refactor whe way TypecheckingResultsCache is updated:
all mutatiting methods extracted to Update subclass, which is
only available to the updater.

Make TypecheckingState a regular container for (unit) caches.
Make TypecheckingService responsible for managing caches.

Extract TypeModuleOwner and TypeModelHandler classes.
Get rid of QueryResultsCache, merge into TypecheckingResultsCache.
TypeModuleOwner to manage "repository" cache.
2020-08-14 16:57:36 +02:00
Fedor Isakov 905e11ac33 Refactor TypecheckingService API: simplify usage, extract Request.
Request is to keep all the parameters of a given API call,
whereas TypecheckingService is to handle the state between
calls.
2020-08-14 16:17:23 +02:00
Fedor Isakov 02182f4f2f Closures lang types: add template for ClosureArgReference concept. 2020-08-12 12:38:51 +02:00
Fedor Isakov 3bac60215e Rebuild samples. 2020-08-06 17:53:20 +02:00
Grigorii Kirgizov f138e725f2 minor: provide ConvertsContexts constructors for common scenarios (eg assignment, invocation contexts) (MPSCR-63) 2020-08-04 12:38:24 +03:00
Grigorii Kirgizov ef2b299124 Refactor unchecked conversion for raw types (MPSCR-63)
Now whether unchecked conversion is allowed is controlled
by ConvertsContext.Options of convertsTo relation.
Introduce 'erased()' term to be used in raw type params.
Drop 'uncheckedConversion' parameter in all macros.
Classifier kind:"raw" is now used only for Recover.
Allow unchecked conversions by default. Forbid for sequences.
2020-08-04 12:06:07 +03:00
Grigorii Kirgizov 8c1234519f minor: substitute several usages of unification-as-inference for optional maybeUni (MPSCR-63) 2020-07-31 17:50:41 +03:00
Grigorii Kirgizov 5257e4e627 minor: rename customizable 'convertsToAlt' to 'convertsTo' (MPSCR-63)
convertsTo is now defaultConvertsTo
2020-07-31 12:36:47 +03:00
Grigorii Kirgizov 59da240fd6 Enable back some of the relaxed typechecking tests after fix for MPSCR-63 2020-07-31 11:36:02 +03:00
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 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 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 0fd3311c04 minor: upd test model dependencies (import j.m.lang.text) 2020-07-22 15:51:56 +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
Fedor Isakov 24a471a2c9 Re-save models. 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 90e90540dc Initial support for j.m.lang.typesystem lang's types. 2020-07-21 17:02:17 +02:00
Fedor Isakov 028ddfe93c Fix typechecking tests. 2020-07-16 10:33:44 +02:00
Fedor Isakov 2119fbc591 Introduce explicit dependency on SRepository, stop trying to recover it from node.
TypecheckingService and provider component are explicitly dependent
on SRepository.
The repository instance comes from the first opened project, which
is a dirty hack and is temporary until Typechecking Facade API
is fixed to provide appropriate instance.
2020-07-16 10:33:44 +02:00
Fedor Isakov d5a259bbde Re-apply all re-runnable migrations (one fix). 2020-07-11 15:59:51 +02:00
Fedor Isakov 936190bca9 Apply migrations. 2020-07-11 15:13:08 +02:00
Fedor Isakov 2bfcdba6d9 Fix tests for "raw" sequence type and raw Iterator.
TBD. This is a temporary fix, still unclear what "raw" sequence is.
2020-07-09 13:41:26 +02:00
Fedor Isakov 42ae077945 Use free var for type parameter when allowUncheckedConversion=true.
Drop the obsolete "null" type hack in case allowUncheckedConversion=true.
Ensure the flag doesn't work recursively.
2020-07-09 13:41:26 +02:00
Fedor Isakov a8907bedf2 Add types for blTypes lang. For the sake of PrimitiveType. Fix mpscore project. 2020-07-09 11:50:16 +02:00
Fedor Isakov ca973ddc51 Fix test compilation. 2020-07-07 13:50:43 +02:00
Fedor Isakov 8731ca0fce Fix typechecking baseMethodCall: correctly idenify this type. 2020-07-03 16:23:00 +02:00
Fedor Isakov d2b270b14c Rebuild mpscore buildscript. 2020-07-03 16:23:00 +02:00
Grigorii Kirgizov 7e996c8772 Disable checking local types in 2 tests (in anticipation of MPSCR-63 fix) 2020-07-01 14:36:48 +03:00
Grigorii Kirgizov 2df90d00c5 minor: fix buildscript depndencies 2020-07-01 14:36:48 +03:00
Grigorii Kirgizov cba5ff86ed Remove 'error' type-like term from bl typesystem
It was aimed at precluding cascading typechecking failures.
(There was some case with typechecking 'hasBound' after incorrect bind.)

It seems controversial. Typechecking with it is no more predictable
than with free variables left unbound in case of error.
With current tests almost nothing changes after removing it.
2020-07-01 14:36:48 +03:00
Grigorii Kirgizov 424b473b8d Fix error on checking recursive type var bounds (Recursion root) 2020-07-01 14:36:48 +03:00
Grigorii Kirgizov ebddf94c42 minor: remove unnecessary head dependencies in few rules
These unused in bodies constraints were for tracking certain
cases of incremental dependencies. Now it's handled by minor
algorithm extension introduced in several previous commits.
2020-07-01 14:36:48 +03:00
Grigorii Kirgizov a37bd44de0 disable tests on inremental typechecking of recursive closure 'invoke'
To fix them need either extending incr algo to handle rules which
postpone binding logicals in principal constraints (i.e. typeOf)
(see rules in Closures for 'invoke' expression)
or rewriting these rules to not produce typeOf with free logicals.
2020-07-01 14:36:48 +03:00
Grigorii Kirgizov f9ca9f2766 Handle usedDataHash computation for macros
Fixes IncrClosureInference.changeFunctionalInterfaceParam test.
Temporary rules built as macro applications weren't computing hash
due to origin!=null condition. Also macro inputs weren't processed.

Stable hash for TypeVarSubstitution is defined because it's used in macro args.
In general, any classes used as constraint/predicate/macro args
must adhere to stable hashCode() contract: hash should change
if there're important changes that may influence typechecking result.
Otherwise there may be unnecessary incremental recomputations.
Relevant for MPSCR-62
2020-07-01 14:36:48 +03:00
Grigorii Kirgizov 672b46dc65 minor: fix mistake in IncrClosureInference.changeFunctionalInterfaceParams test 2020-07-01 14:36:48 +03:00
Grigorii Kirgizov 1943157cd0 update samples test models dependencies & regen build.xml 2020-07-01 14:36:48 +03:00
Grigorii Kirgizov a16756bfdb Fix error reporting in bl.closures for conversion to functional interface
Add 'genDecl' constraint in heads of toFunctionalCls* rules
to handle incremental changes to respective classifier.
Also fail instead of just reporting error to break execution and
report on correct node according to calling rule.
2020-07-01 14:36:48 +03:00
Grigorii Kirgizov 8ccfa63111 Add test methods for ensuring incremental logic for rules diff 2020-07-01 14:36:48 +03:00
Grigorii Kirgizov 51b0438888 Add tests for incremental processing of closure type inference 2020-07-01 14:36:45 +03:00
Grigorii Kirgizov 827d2e5c42 Add tests for generic method calls 2020-07-01 14:36:45 +03:00
Grigorii Kirgizov 36e4e01f2e Аdd tests for changes to class hierarchy with generics 2020-07-01 14:36:45 +03:00
Fedor Isakov d4602c50d6 Ensure relevant input concepts are in query scope. 2020-06-28 17:14:35 +02:00
Fedor Isakov 9c1d3aad92 Move Result class to commonly-used runtime solution. 2020-06-25 14:30:30 +02:00
Fedor Isakov 11b9709ab1 Provide lift type macro for UndefinedType.
UndefinedType should leave the logical variable unassigned.
Type is an abstract superconcept, so reaching it means
there should have an override for lift macro.
2020-06-24 14:36:31 +02:00
Fedor Isakov 82b37d8103 Add module dependencies to test modules.
This ensures the tests can be launched on a test module in isolation.
2020-06-24 13:59:58 +02:00
Fedor Isakov ecb2569bad Types for smodel lang. 2020-06-22 13:38:09 +02:00
Fedor Isakov ab99a0245c Introduce runtime support module j.m.coderules.runtime. 2020-06-21 23:17:33 +02:00
Fedor Isakov 8441ebc5e1 Minor refactoring in HierarchyGraph: introduce OriginPath.
Use OriginPath for origin vertices instead of InstPath.
Also separate buildPath into two methods for clarity.
2020-06-19 17:34:18 +02:00
Fedor Isakov 3c46f210ca Rebuild build script. 2020-06-18 13:12:02 +02:00
Fedor Isakov be76070914 Replace unification with match where applicable, minor cleanup.
Replace unification with the intent of capturing term feature
with match constraint.
Drop unused term feature from head pattern.
Provide better context for failed class inheritance test.
2020-06-18 13:05:24 +02:00
Fedor Isakov 19994dab9f Introduce comparable constraint.
Comparable should only check if the two
types are in any relation (one converts
to the other) and report error if check fails.
2020-06-18 13:05:23 +02:00
Grigorii Kirgizov 4876c22282 Refactor single root of incremental tests into several, move IncrTestBuilder 2020-06-16 14:14:46 +03:00
Grigorii Kirgizov a03651dd31 Refactor IncrementalLauncher in tests to use TypeIndex (as on runtime) 2020-06-15 13:03:09 +03:00
Grigorii Kirgizov 62d31743ed Refactor incremental tests 2020-06-15 11:14:47 +03:00
Grigorii Kirgizov f81d8ac44e Fix missing lang import on tests model 2020-06-09 12:00:37 +03:00
Grigorii Kirgizov dcb8e5ac53 Fix "link out of search scope" in collections types 2020-06-09 02:19:42 +03:00
Grigorii Kirgizov 1631f77e74 Implement typechecking for j.m.bl.collections & tests for it 2020-06-08 12:29:37 +03:00
Grigorii Kirgizov 5004dc2340 Abstract into bl typechecking of types having runtime representation (e.g. sequence)
See term 'runtimeType' and corresponding rule in ConversionMain
2020-06-05 21:11:37 +03:00
Grigorii Kirgizov 3b456a9063 minor refactorings in bl typesystem 2020-06-05 21:11:27 +03:00
Fedor Isakov 490eb66a3e Disable Thinlet test, too many timeouts. 2020-06-04 12:40:34 +02:00
Fedor Isakov 161beb6a4d Refactoring in hierarchy graph. Introduce various abstractions.
Hierarchy graph vertex can represent LUB as a simple
collection of inheritance paths.
Abstract intefaces allow to model operations such as finding
the LUB in an abstract way.
Greatly simplify code.
2020-06-01 10:18:04 +02:00
Fedor Isakov f96a014543 Minor refactoring: code simplification and cleanup. 2020-05-25 13:15:29 +02:00
Fedor Isakov 3ff038e4a3 Drop obsolete and unused code. Tests superceded by new tests. 2020-05-25 13:15:25 +02:00
Fedor Isakov 71fd7d7301 Switch typechecking templates to use the refactored facade. 2020-05-25 12:38:05 +02:00
Fedor Isakov fc10afdae0 Fix typo in typechecking rule. 2020-05-25 11:03:39 +02:00
Fedor Isakov 35b09d3e2e Fix build script and regenerate. 2020-05-25 11:03:39 +02:00
Fedor Isakov b4a5b4cec4 Refactor various utilities into facade class.
Introduce HierarchyGraph and its specialization,
ClassHierarchyGraph, as a facade to all tasks related to
finding paths and LUB of types.
2020-05-25 11:03:39 +02:00
Fedor Isakov 1aa5608b34 Move files for wrongly placed coderulesExt lang. 2020-05-23 15:25:59 +02:00
Grigorii Kirgizov 6f9337e5cf minor: consider error() term in containedIn relation
This term marks that somewhere error has been already handled
and serves to avoid further errors.
2020-05-22 22:37:48 +03:00
Grigorii Kirgizov 00dc426f43 Consider case of NestedNewExpression for class creators (MPSCR-29) 2020-05-22 22:36:10 +03:00
Grigorii Kirgizov a4901bb730 Change signature of `typeVarBound` constraint to treat it as principal
Recent commit with change to def of pr. constraint
made typeVarBound non-principal. so fix it.
2020-05-22 21:40:03 +03:00
Grigorii Kirgizov 1aa07397d4 minor: document one type inference rule to avoid confusion 2020-05-22 21:39:15 +03:00
Grigorii Kirgizov 42f0d06063 Refactor duplicate code for checking method call into call macro
Also typecheck method call arguments with macro instead of a rule
2020-05-22 21:39:15 +03:00
Grigorii Kirgizov c3cf1e5111 Complete type inference for closure params wit inst macro, add tests, fix few minor issues
Related to MPSCR-20 & MPSCR-29.
2020-05-22 21:39:14 +03:00
Grigorii Kirgizov fe58f39b56 Introduce macro for type scheme instantiation, refactor existing rules with it
Now rules concerned with generics handle type vars from enclosing scope.
Complete typechecking of BaseMethodCall: consider static/nonstatic cases.
Complete typechecking for class creators, handling type vars from cls & ctor.
Refactor rules for EnumConstantDeccl & ClassifierType.
Related to MPSCR-20 & MPSCR-29.
2020-05-22 21:38:55 +03:00
Grigorii Kirgizov 4e43c924c6 Inherit classifier term from `parameterized` and migrate ListFeature role usages 2020-05-21 16:38:44 +03:00
Grigorii Kirgizov 1ac16ed0b9 Fix left usages of classifier term to explicitly provide type parameters 2020-05-21 16:38:39 +03:00
Grigorii Kirgizov e2b3c21b2f Change semantics of implicit ListFeature: treat as wildcard, not as empty list
Motivation is that implicit (non-overriden) list features must unify
with list of any length. Consider an example:
`classifier(cls: node-ptr/A/) = classifier(cls: node-ptr/A/ param: [B,C])`
With previous approach it would fail, which seems counter-intuitive to me.
So, if empty list (e.g. of type parameters) is meant, then it must be
specified explicitly.

There's one thing to remember, though: such wildcard list features
won't match with MetaLogicalArrays in rule heads.
(e.g. see dpromote_* rules and consider what happens when
a classifier with unbound `parameter` feature comes in)
2020-05-21 16:38:36 +03:00
Grigorii Kirgizov 3a99a1569a Add typechecking for AlternativeType. Move & refactor genDecl macro a bit.
Introduce common 'parameterized(child typeParams)' term
to allow unifying processing of GenericDeclarations.
Collect type variables from enclosing GenericDeclaration.
Will be needed to simplify instantiation of nested generic decls
(e.g. generic method inside generic class) using `genDecl`
machinery instead of TypeVarSubstitution.
2020-05-21 16:38:30 +03:00
Grigorii Kirgizov 3047926ce4 Fix typechecking for vararg param decls: treat them as arrays. 2020-05-21 16:31:41 +03:00
Grigorii Kirgizov 8b07402d48 Refactor checking type arguments into call macro. Fix type decls for checkArgs rules 2020-05-21 16:31:34 +03:00
Grigorii Kirgizov 9051e71f84 Handle case of type vars having other type vars as bounds for inference
Also uncomment hasBound_check rule which now is required
to check such type vars when their bounds become ground.
2020-05-21 16:31:27 +03:00
Grigorii Kirgizov 08743b444c Avoid producing typeOf in checkVariableDecl for unknown types (types without macros) 2020-05-21 16:31:18 +03:00
Grigorii Kirgizov ac2e3f97d2 Add typechecking for implicitly typed closure arg, add tests 2020-05-14 20:07:01 +03:00
Fedor Isakov 9c234cac2a Quickfix: add support for AlternativeType. 2020-05-09 16:05:48 +02:00
Fedor Isakov 82f0229aca Rebuild project. 2020-05-09 15:08:47 +02:00
Fedor Isakov 14780b5561 Apply automatic migrations. 2020-05-09 15:04:25 +02:00
Fedor Isakov d1163fc883 Open and rebuild the project with MPS 2020.1. 2020-05-09 15:02:20 +02:00
Fedor Isakov f3b16186e6 Fix build scripts and regenerate. 2020-05-09 10:54:18 +02:00
Fedor Isakov acd6234415 Force save all. 2020-05-09 10:54:18 +02:00
Grigorii Kirgizov e1af32b97c Add tests for closuresExt concerned with yield and sequence, reproduces MPSCR-60 2020-05-07 01:28:14 +03:00
Grigorii Kirgizov e6b1fe12a7 Don't generate main closureLiteral rule when there's error with return vs. yield 2020-05-07 01:28:14 +03:00
Fedor Isakov 76991aabe7 Fix dependencies among rule tables.
Observing the invariant: whenever a constraint is used in
rule's head, the rule table containing it must extend the
one that constraint.

Also drop unused constraint from the head in ConversionFunctionIFace.
2020-05-05 16:23:13 +02:00
Fedor Isakov 2c363f85f4 Tidy up helper methods contract, drop unnecessary method.
BaseHelper.getListContents() accepts a dataform that must be
an instance of ListNode or be resolved to one via DataFormUtil.ground().
2020-05-05 15:58:48 +02:00
Grigorii Kirgizov 54c9af37a3 Add checking of loop statements in blExt 2020-05-05 16:45:27 +03:00
Grigorii Kirgizov c388aa25b6 Reorganise rule table extends dependencies in blExt
Mainly, avoid extending TypeOf by ConversionMain (unnecessary dependency).
It's also more logical structure: tables defining declarations go first, then typeOf-related.
So rule tables which require only decls can depend only on such tables.

Core tables extends relationship now:
TypeBound <- CheckAll <- Generics <- TypeOf
TypeBound <- ConversionMain [<- other langs' conversions]
2020-05-05 16:45:27 +03:00
Fedor Isakov 66d2896fff Ensure type variable bounds are processed in coerce query.
This fixes constraint errors in model check while running
typechecking with coderules.
2020-05-05 13:20:59 +02:00
Fedor Isakov a15a6b3f1d Fix target statement (not allowed within constraint rule). 2020-05-05 10:19:38 +02:00
Fedor Isakov ab9a22a013 Rebuild project. 2020-05-05 10:19:38 +02:00
Fedor Isakov ea687efb21 Types for j.m.logic language. 2020-05-05 10:19:32 +02:00
Grigorii Kirgizov 27b7917a1a Add conversion of closures to functional classifiers, add tests 2020-05-04 16:38:00 +03:00
Grigorii Kirgizov c6e20d00c2 Handle case of free vars for ternary operation and primitive subtyping (needed for closures) 2020-05-04 15:16:47 +03:00
Grigorii Kirgizov 590f3ed6ed Fix usages of OriginSpec: can't use them inside ConstraintRule bodies. Use convertsToSafe instead 2020-05-04 15:16:47 +03:00
Grigorii Kirgizov aa40ca0e01 Fix function conversion to allow coerceTo queries pass 2020-05-04 15:16:47 +03:00
Grigorii Kirgizov 36a85d5c2c Add bl.collectionsExt dependency on bl.function lang; upd mpscore build script and build.xml 2020-05-04 15:16:47 +03:00
Grigorii Kirgizov f7a9c73199 Refactor out lang dependency on function type analogously to sequence type
As closures typesystem depends on collections due to sequence type,
so collections typesystem depends on closures due to function type.
E.g. consider typechecking of SequenceCreator.
2020-05-04 15:16:47 +03:00
Grigorii Kirgizov 898087f427 Fix term table in closuresExt to extend blExt term table and use imported sequence type 2020-05-04 15:15:35 +03:00
Grigorii Kirgizov 72d48d76e3 Add typechecking for recursive closure invoke expression, add tests & fix older ones 2020-05-04 15:15:28 +03:00
Grigorii Kirgizov 3284d2c331 Add typechecking of ClosureLiteral and invoke expressions 2020-05-02 14:04:34 +03:00
Grigorii Kirgizov 19ab82586f Add function type subtyping 2020-05-02 14:04:34 +03:00
Grigorii Kirgizov b9fe7439bb Add empty closuresExt files for lang and test solution, upd bulid script 2020-05-02 14:04:34 +03:00
Grigorii Kirgizov 3101d22a5b Upd mpscore build script and build.xml 2020-05-02 13:44:19 +03:00
Grigorii Kirgizov 735276d2a2 Add import/export constructs for sequence type in collectionsExt to enable basic tests 2020-05-02 13:43:03 +03:00
Grigorii Kirgizov 8921c44a8e Add first tests for sequence type conversions 2020-05-02 13:43:03 +03:00
Grigorii Kirgizov 451b892b9f Add empty models for collectionsExt lang and tests 2020-05-02 13:43:03 +03:00
Grigorii Kirgizov 625ea8c049 Add j.m.bl.sequenceBase language with basic sequence typing rules
This lang doesn't depend on collections lang and extracts
common dependencies of closures and collections langs:
sequence term and its basic typing rules.
2020-05-02 13:43:03 +03:00
Grigorii Kirgizov 69457dc747 minor fix: extend term tabl from blExt in tuplesExt 2020-05-02 13:43:03 +03:00
Grigorii Kirgizov bd1e0b61e5 minor: rewrite errorType constraint in blExt as call macro 2020-05-02 13:43:03 +03:00
Grigorii Kirgizov a2f3a5b824 Avoid leaving logicals unassigned in case of error: assign error type explicitly
Needed to disambiguate free variables that are not yet inferred
from those which has been already processed with error.

Also more properly handle case of trivial return type inference
2020-04-30 15:38:34 +03:00
Grigorii Kirgizov aca2b3b8d9 BL typesystem: forbid conversion to/from void type
There's special constraint 'isCompatbile' to handle void.
Conversions with void can arise from closure types returning nothing.
2020-04-30 15:38:34 +03:00
Grigorii Kirgizov 125d051534 Fix check for return statements given possibility of nested method-like decls
Also fuse two bl rules for return statement and last expr.
Output feedback on return stmt, not returned expr,
because it also handles case of erroneous void return
2020-04-30 15:38:34 +03:00
Grigorii Kirgizov 5dcc71d2a5 Separate typing or return statement from checking its compatibility with method type
For convenience: to always get typeOf(return)
to unconditionally match on it (eg in closures lang)
2020-04-30 15:38:34 +03:00
Fedor Isakov 77d35bfaa2 Manually migrate all queries to new table format. 2020-04-23 10:15:39 +02:00
Fedor Isakov f23ea05b65 Update query templates to not use QueryParameterReference.
QueryParameter is always referring to Query instance passed
to the template.
Drop QueryKind and parameter declarations from query templates.
2020-04-22 11:43:37 +02:00
Fedor Isakov 46fe463118 Update instances of query templates to include reference to Query type. 2020-04-22 11:25:14 +02:00
Fedor Isakov 98f1a0a6d2 Apply one outstanding migration. Force save all models. 2020-04-19 16:30:11 +02:00
Grigorii Kirgizov 22921b9b17 Clean unneded require statements
Relies on facts that children of origin are always processed and
that all nodes mentioned in rule bodies are required implicitly.
2020-04-19 13:43:05 +03:00
Grigorii Kirgizov 0e0438cf3c Provide necessary dependencies for correct incr typechecking of cls hierarchies, fixes MPSCR-55
Now subclassPaths rule depends on a declaration of classifier,
which allows to track justifications dependency and invalidate
rule on incremental typechecking.
Similarly, rule for declaration now depends on all super classifiers.
2020-04-19 13:43:05 +03:00
Grigorii Kirgizov b07fdd6735 Reproduce MPSCR-55 2020-04-19 13:43:01 +03:00
Grigorii Kirgizov 4bb1b9d3d8 Apply some migrations after rebase on master 2020-04-19 13:42:53 +03:00
Fedor Isakov 9f7d60e7c1 Reorder macro template declarations: move abstract concept to the bottom. 2020-04-16 12:25:59 +02:00
Fedor Isakov 7cc19bdece Minor code fix: remove unnecessary wrapping of logical var. 2020-04-15 11:14:38 +02:00
Fedor Isakov eb4862eb48 Force save all models -- update resolve info. 2020-04-14 16:20:05 +02:00
Fedor Isakov fcbdbe7e47 Attempt to fix gradle task deps graph. 2020-04-13 18:00:15 +02:00
Fedor Isakov 35fd816cbc Update all usages of moved concepts. 2020-04-13 18:00:15 +02:00
Fedor Isakov fd2043e047 Update build scripts. 2020-04-13 18:00:15 +02:00
Fedor Isakov 1336e82065 Fix wrongly used logical item expression. 2020-04-13 17:58:34 +02:00
Fedor Isakov 5b1449fa82 Update all usages of moved concepts. 2020-04-13 17:58:34 +02:00
Fedor Isakov 296b3e9271 Re-apply all rerunnable migrations. 2020-04-13 17:58:33 +02:00
Fedor Isakov a1c98b5bf0 Apply all outstanding migrations. 2020-04-13 17:58:33 +02:00
Fedor Isakov 52bca36d32 Rebuild project. 2020-04-13 17:58:33 +02:00
Fedor Isakov 7413e9e387 Force save all models. 2020-04-13 17:58:33 +02:00
Fedor Isakov cac5573cb9 Drop instances of deprecated concepts in baseLangExt
.
2020-04-13 17:58:33 +02:00
Grigorii Kirgizov 145aa79753 Regenerate build.xml for mpscore 2020-04-13 15:10:37 +03:00
Grigorii Kirgizov bd87873160 Move baseLanguage.tuplesExt lang to 'samples' and upd build script 2020-04-13 14:36:37 +03:00
Grigorii Kirgizov 8dfcff1844 Add typechecking for indexed tuples (new language .tuplesExt and tests) 2020-04-08 23:24:55 +03:00
Fedor Isakov 4e12f7bf3b Migrate baseLanguageExt sample to new expand/call macros. 2020-03-31 18:44:07 +02:00
Fedor Isakov 6a431fcb49 Rebuild project. 2020-03-31 18:44:07 +02:00
Grigorii Kirgizov 79952036cd Fix ternary operator typechecking 2020-03-26 18:17:06 +03:00
Grigorii Kirgizov 6a53d15a21 Refactor: move logic related to tracking parent match from ControllerImpl to MatchJournal
Relates to machinery introduced in MPSCR-47.
Previously parent match was maintained in Controller on Java call stack.
Now this stack of parent matches is maintained manually in MatchJournal.

So MatchJournal gains new invariant: parentChunk()
returns correct parent after each logMatch() call.
Several tests fail, also need to maintain this
invariant after logActivation() calls.
2020-03-26 13:40:41 +03:00
Grigorii Kirgizov c51d767926 Add typechecking for all missing operators. Refine missing cases, check compatibility. Properly handle ternary op. Add tests. (MPSCR-3) 2020-03-25 20:11:52 +03:00
Grigorii Kirgizov b6aaec8870 Revert temporary workaround for MPSCR-51 from 16e39a93 2020-03-23 14:39:54 +03:00
Grigorii Kirgizov 91e4d2b582 Revive 'principal' rule feature for MPSCR-51. Mark those rules in BL typesystem.
Introduce 'auxiliary/essential' notions instead of 'principal/not principal'.
2020-03-23 14:28:14 +03:00
Grigorii Kirgizov 8874e8eb2c Complete checking rules for overriding methods (add signature clash check, JLS12 8.4.8). Add tests for that. (MPSCR-3) 2020-03-18 19:50:17 +03:00
Grigorii Kirgizov 7a5a5388b1 minor fix: suppress out of scope error in node test code 2020-03-17 18:36:41 +03:00
Grigorii Kirgizov 16e39a9345 Check applicable scope for certain checking rules in BL (workaround for BL for MPSCR-51). Fix SubclassingUtil.
Modified TYPECHECK query to include "checkingScope" query parameter:
it is a root node for which program is generated (for local typechecking it's local node).
Rules additionally match on a constraint `checkDecls(node<>)` bearing this node,
so while rules will be generated for all scopes, only those in applicable scopes will run.

Also split rule for EnumConstantDeclaration on declration checking and just typing rule.
2020-03-17 17:54:38 +03:00
Grigorii Kirgizov 8d1f086562 Rewrite check_ClassifierOverridingMethods checking rule in Coderules. Rename several rules. (MPSCR-3) 2020-03-17 13:14:41 +03:00
Grigorii Kirgizov 455aea18d0 Refactor: compute instantiated subclass paths in SubclassingUtil more efficiently and allow resolving type vars with it 2020-03-16 17:59:19 +03:00
Grigorii Kirgizov 873d04c907 Add typechecking of Enums (MPSCR-3). Also avoid getting Classifier types with prim types as type args
Now primitive types in conversion relation are handled before processing of free inference vars.
So primitive types first get boxed and only then these terms can be unified with inference vars.
2020-03-16 16:42:03 +03:00
Grigorii Kirgizov 7c40295948 Add test cases for boxing/unboxing, complete typechecking for boxing (MPSCR-3) 2020-03-12 18:02:21 +03:00
Grigorii Kirgizov a5cc88aeef Fix typechecking for qualified this expr (MPSCR-3) 2020-03-12 14:54:40 +03:00
Grigorii Kirgizov 73fd59e58e Add more test code for checking some cases of BL method overriding logic. Muted for now. (MPSCR-3)
It's unclear who should handle this: coderules or old typesystem checking rules.
2020-03-12 14:01:30 +03:00
Grigorii Kirgizov a2d28e566a Tried to reproduce MPSCR-50 -- typechecking works okey, problem lies elsewhere 2020-03-12 10:36:26 +03:00
Grigorii Kirgizov a4d561b5a4 Drop now unused subclassing / promote rules operating on raw Classifier values 2020-03-11 15:51:26 +03:00
Grigorii Kirgizov 88a433584b Simplify subclassPaths rule, add a test for now used SubclassingUtil's method
Previously type substitution in subclssing path is computed
by helper method instead of a code inside rule template.
2020-03-11 15:46:16 +03:00
Grigorii Kirgizov fea3d5d021 minor: align NestedGenerics test with javac 2020-03-11 15:22:54 +03:00
Grigorii Kirgizov 7b143bdb6f Ensure typeVarBound constraint is produced once for each tv decl. Fix capture of type var.
Fixes typechecking tests.
Type var bounds are produced together with genDecls at program start.
Now bound of type var is captured only when needed --
inside convertsTo check, leaving typeVarBound intact.
2020-03-11 12:29:43 +03:00
Fedor Isakov 253a7609a3 Introduce typeVarBound constraint to handle typevar bounds.
Since it's no longer possible to have cyclic terms,
the term for type variable type has to be refactored:
the bound information is attached via typeVarBound constraint
on the type.
2020-03-11 12:29:19 +03:00
Fedor Isakov 4020989bde Defensive copying of argument list.
SModel returns a model-based list by default.
Since it is used w/o a read action, we need to copy the list
to be used as constraint's argument.
2020-03-11 12:28:22 +03:00
Grigorii Kirgizov e1ac188023 Produce proper type erasure for raw classifiers: type variables are erased to their bounds 2020-03-11 09:41:18 +03:00
Grigorii Kirgizov d3d567101f Add typechecking for return type covariance and tests for it (MPSCR-3) 2020-03-11 09:41:08 +03:00
Grigorii Kirgizov 92f95674b3 Refactor: drop meaningless DataForm.asRoot (used symbolPath which is deprecated) 2020-03-06 14:04:18 +03:00
Fedor Isakov f2bb87e1b0 Apply migration to replace deprecated concept. 2020-02-26 15:03:31 +01:00
Fedor Isakov 7ba7c983cb Apply migration to use logical variable ref expression. 2020-02-24 22:57:05 +01:00
Fedor Isakov e1c5f68e3e Typechecking templates: minor refactoring, optimizing code.
Replace node-ptr<> type with node<> where applicable.
Use node<> type is ok in constraint arguments.
Replace instances of LateExpressionItem $() with ExpressionItem.
2020-02-20 14:52:28 +01:00
Fedor Isakov 2c43762f93 Replace all instances of .pointer in constraints to node reference.
SNode is supported now directly as an argument to constraint/predicate.
Pointer operation is no longer necessary, as is node-ptr<> type for logical vars.
2020-02-20 11:59:28 +01:00
Fedor Isakov 8ec26b4e94 Support node<> argument in constraints. Prepare to get rid of node-ptr<>. Minor refactoring. 2020-02-20 11:59:28 +01:00
Fedor Isakov 3758971194 Fix the only instance of ExpressionItem that doesn't wrap .pointer op. 2020-02-20 11:59:28 +01:00
Fedor Isakov 9a6859a5d9 Refactor usages of TargetSpec parameter to target{} block.
TargetSpec is to be reduced to a reference to logical variable,
simplifying the feedback predicate.
When a node can be specified directly, use target{} block.
2020-02-17 12:49:26 +01:00
Fedor Isakov 417fc45933 Restore origin ref in RuleEx interface, fix terminology in templates API.
To avoid confusion, a rule defines "target ref", which is supposed
to indicate the source code location for possible errors.
The origin node is to be referred as "origin" as before.
Temporarily rename OriginSpec's alias to "target" to reflect change
in semantics.
2020-02-17 11:57:14 +01:00
Grigorii Kirgizov 9001286ebe Add incremental test. Tried reproduce MPSCR-42 with auto-test, but it appeared only from Editor action. 2020-02-13 17:12:33 +03:00
Grigorii Kirgizov c004ef888a Avoid producing typeVariable term with null decl inside (MPSCR-40) 2020-02-12 20:24:04 +03:00
Grigorii Kirgizov 2aeadaf63f Always silently handle wildcard classifiers to avoid errors while handling 'promote' relation (fixes MPSCR-41) 2020-02-12 20:15:07 +03:00
Fedor Isakov 796ad9ad2c Apply migration to drop ValueOfExpression. 2020-02-12 12:26:09 +01:00
Fedor Isakov 66cf34ae80 Drop instances of ExpressionItem that don't contain a node ref.
ExpressionItem is to be ousted. It has no real use aside from
containing a .pointer op.
2020-02-12 10:53:40 +01:00
Grigorii Kirgizov 516ecd594f Fix incr test failure due to incorrect flow from duplicated line 2020-02-11 16:00:18 +03:00
Grigorii Kirgizov c87a2741fe Add test for incrementality in BL to reproduce MPSCR-36 2020-02-11 15:52:30 +03:00
Fedor Isakov 1a6b107a76 Apply migration to replace condition block with if statement. 2020-02-07 13:14:46 +01:00
Fedor Isakov 73219399f4 Deprecate unused flag "principal" in rule template, drop usages. 2020-02-07 12:05:45 +01:00
Fedor Isakov 4a84ebce5f Apply migration to switch to BodyBlock. 2020-02-06 12:55:32 +01:00
Fedor Isakov c353f89ea0 Apply migration to drop ParameterContainer. 2020-02-05 17:02:32 +01:00
Fedor Isakov 3f51c1e5c1 Apply migration that replaces empty logical type with term type. 2020-02-05 12:34:20 +01:00
Grigorii Kirgizov 54fc91a031 Fix and reenable 3 tests on incremental typechecking disabled in fa7532f3, enable few older tests for previously missing bl machinery 2020-02-05 12:29:33 +03:00
Fedor Isakov 5b7bdc5838 Add error annotations on test data where errors are expected. 2020-02-03 12:00:44 +01:00
Fedor Isakov 391c9053b5 Apply migrations after switch to MPS 193. Regenerate project. 2020-02-03 11:24:22 +01:00
Fedor Isakov 5ebdea0714 Add necessary module dependency. 2020-01-20 10:52:40 +01:00
Fedor Isakov 85cf6888d5 Typechecking BL: introduce type term, reorganize terms to extend type, drop kind value from prim.
Temprorarily use classifier type String for internal string type.
Restore eq predicate in converts_ground_id body.
Remove origin{} block from var decl, doubtful idea.
2020-01-20 10:52:40 +01:00
Fedor Isakov fa7532f34f Include origin features's hash to requiredHash when building rules.
This enables to adequately reflect changes in the model when it is updated
by editor actions, such as "side transform".

Three tests was broken as the result of this fix and are disabled
http://127.0.0.1:63320/node?ref=r%3A8d22f6d9-72f0-49ec-92ee-027a87fbedd4%28jetbrains.mps.baseLanguageExt.test.incremental%40tests%29%2F3095008005741803340
2020-01-02 17:42:38 +01:00
Fedor Isakov efd19aa45b Implement incremental generation of coderules program.
Introduce SessionData, allow to keep arbitrary data with the session.
Extend RulesListTable with support for invalidation based on rule unique tags.
Introduce UpdatesRecorder to keep track of invalidated nodes.
Extend ApplyTemplatesStep with invalidate logic for typechecking.
Simplify design, drop unnecessary fields, minor refactorings.
2020-01-02 17:20:13 +01:00
Fedor Isakov 1e9e41601a Add method to RuleEx that had been removed from the superclass. 2020-01-02 17:20:13 +01:00
Grigorii Kirgizov 955c814c3c Add test for now failing cases of nested generics (filed MPSCR-29) 2019-12-26 19:13:17 +03:00
Grigorii Kirgizov 6399859f8e fix one incorrectly removed rulesList extends 2019-12-26 18:44:17 +03:00
Grigorii Kirgizov 846dbed182 Minor refactor: Split Conversion rulesList to general convertsTo rules and other conversions. Drop intro_hasBound 2019-12-26 18:32:00 +03:00
Grigorii Kirgizov 1b79c2b548 Check compatability for eq/neq operators, forbid null to prim conversion (MPSCR-3)
Introduced a variation of conversion relation with a bit stricter boxing, needed for eq/neq.
e.g. suppose { (Number n, float f) => n == f } here f shouldn't be boxed.
2019-12-26 17:57:59 +03:00
Grigorii Kirgizov 52af2d527a Complete subtyping for array types (A[] <: Serializable, Cloneable; JLS 4.10.3) (MPSCR-3) 2019-12-25 14:11:01 +03:00
Grigorii Kirgizov e4b927e6e6 stringType: make it a sub-dataform of classifierType, don't add new rules. Add tests for conversion to/from classifierType and binstr promote. (MPSCR-3)
Everywhere where we don't care whether it's <String> or <string> it will be handled just as String.
Where we need to discern between the cases (as in Recover), 'stringType()' dataform can be matched first.
2019-12-25 14:09:48 +03:00
Grigorii Kirgizov 171671161f Remove unused promoteUnchecked rule, add "shortcut" promote_reflexive rule which avoids computing subtype paths 2019-12-24 19:57:46 +03:00
Grigorii Kirgizov a2f8f5e6f3 Handle cases with free & inference variables in containment, remove few unneeded rules (MPSCR-11)
Remove rules which handle capture+inference var case separately: it's already handled.
Remove rule with error on bound which shouldn't be triggered with new hasBound semantics.
Add symmetric rule for case value+inference var: types can be inferred nevermind relation direction.
Add rules for free vars without bounds (these ain't inference vars). Need in such vars arise when
e.g. params in classifierType terms must be somehow accessed. It's used in MethodCall rules.
2019-12-24 19:21:33 +03:00
Grigorii Kirgizov 8744263cb4 Add more tests for containment relation, remove some found unsound rules (MPSCR-11)
Rules removed are concerned with type variables. JLS [4.5.1] doesn't define containment for them.
2019-12-24 17:27:52 +03:00
Grigorii Kirgizov 9d35064db5 Provide better explanation of capture/typevar inference rule (relates to MPSCR-13) 2019-12-24 13:54:10 +03:00
Grigorii Kirgizov 76859dc69a Provide required info for return ty inference or assign Object type. Fixes minor MPSCR-27
During investigation a different issue has been found.
Currently, e.g. when checking args to a method call, if there's an error then inference variable remains free.
It allows to continue typechecking without spurious additional errors triggered by former ones,
but with this approach all relations must gracefully handle free vars, and it's more difficult to avoid "no type".
There's an alternative to always assign to inference var a type at hand, even it doesn't pass checks
-- but then there're more unneccessary errors. Both approaches seem valid, no action is taken now.
2019-12-24 13:48:06 +03:00
Grigorii Kirgizov 2a15404753 Disable hasBound_check rule aimed at reactivation. All cases are now handled without it.
Enabling it with working reactivation causes spurious errors on method calls
because now it's impossible to specify feedback target for such errors fired
from reactivated rules.
2019-12-23 21:18:41 +03:00
Grigorii Kirgizov ef5959dcdc Fix failing checkModels test because of var out of scope 2019-12-19 02:42:04 +03:00
Grigorii Kirgizov 455f69f499 Fix miising import of lang.text in tests 2019-12-19 00:59:09 +03:00
Grigorii Kirgizov 3495cb4c2a Fix checking of raw new class / anon class. Thinlet now passes. 2019-12-18 21:47:07 +03:00
Grigorii Kirgizov e8cb6f9ad2 Add rule for determining correct type to bind inference variable to. Fixes MPSCR-13.
The inferred type can be either capture or type variable.
This logic is covered by a new rule 'inferFromCapture'.
For examples see 'Bounds' test sample.

This inference is used in call arguments type inference.
It happens on cases when bounds arise from several places:
 (a) bounds for inference variables from type vars declared in method signature (hasBound constraint)
 (b) bounds of type vars used as arguments to call (typeVariableType term wiht bounds inside)
 (c) bounds from captures on type variables from case (b), which come in the form of 'captureOf' term
2019-12-18 21:47:07 +03:00
Grigorii Kirgizov f2b35764d9 Explicitly match on hasBound in convertsTo rules (it's not reactivated as should) 2019-12-18 21:47:07 +03:00
Grigorii Kirgizov 7d582df9dc Extend and clean up tests for bounds/capture type checking (Bounds sample) 2019-12-18 21:47:07 +03:00
Grigorii Kirgizov 9347cbf8ca Fix captureOf_upperBound_check rule to handle typeVariableType case. Add check for captureOf_lowerBound
Errors are now reported on ClassifierType instead of type argument, because some checks must be done
in captures and there's no proper way to specify origin of arg here.
2019-12-18 21:47:07 +03:00
Grigorii Kirgizov bced911edf Add tests for capture logic of bl typesystem 2019-12-18 21:47:07 +03:00
Grigorii Kirgizov 4e948ab70e Handle 'cls==null' case in ClassifierType macro. Fixes error in "Typechecking:scopes" test. 2019-12-18 21:47:07 +03:00
Grigorii Kirgizov 6ac8390e77 Remove error feedback from classifierType altogether: always produce some type 2019-12-18 21:47:07 +03:00
Grigorii Kirgizov f51d351e06 Avoid generating checkClsTy rule for ClassifierType-s without model
Workarounds unclear test failure in genericNewExpression with "Unadvised error on 'null/null': ..."
2019-12-18 21:47:07 +03:00
Grigorii Kirgizov b66ba51084 minor: unify instanceMethoCall and baseMethodCall rules so they are almost duplicates
Isn't posssible to merge them because of ClassCreator rule
2019-12-18 21:47:07 +03:00
Grigorii Kirgizov a460459702 Require declared type check for local tc of Expression.
E.g. method calls can rely on it for return type inference.
2019-12-18 21:47:07 +03:00
Grigorii Kirgizov 9138c8e817 Rewrite rules converned with class creation. Add check for args count in ClassifierType check. 2019-12-18 21:47:07 +03:00
Grigorii Kirgizov 489ce56d70 Fix subclassPaths given updated TypeVarSubstitution behavior 2019-12-18 21:47:07 +03:00
Grigorii Kirgizov 85142e52f8 Switch error annotation place on checking classiferi. Correctly handle convertsTo to capture context tvs in instanceMethodCall 2019-12-18 21:47:07 +03:00
Grigorii Kirgizov be2bb09811 Remove incorrect convertsTo rule (any to upperBoundType can't be converted) 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 76c6ee052a Switch error reporting on arg types from 'origin' to 'convertsToSafe' in method call rules.
'origin' works only when wrapping whole ConstraintRule-s, not individual constraint activation statements.
2019-12-18 21:47:06 +03:00
Grigorii Kirgizov b0c0f1b118 Remove unneded constraint toTypeVariableType 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov e13ca7ad33 Make TypeVarSubs usage precondition weaker: don't require substs for declared vars to be set. Drop vacuous type var resolution. 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 2e0feb670e Fix baseMethodCall rule accroding to instanceMethodCallOperation rule 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 62d76dea9f Check type arguments on instanceMethodCall. Rename captureWildcard to captureBound 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov dc6ffbdbad Fix forwarding to GenericDeclaration macro by using 'call' instead of expand. Check mismatched num of args in ClassifierType. 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov a887328d4a Process case of convertsTo(X,T) when isFree(X) in priority to correctly bind inference vars.
Fixes case described in MPSCR-13, but not all tests now pass.
2019-12-18 21:47:06 +03:00
Grigorii Kirgizov af14f31090 Handle capture for bounds of type var types. Add additional example for that case in Samples_bad2 (MPSCR-13) 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 6305578b25 Simplify captureWildcard by using tv bounds from type scheme instead of hasBound. Fix inferring bounds for captures.
Concerned with MPSCR-13 and MPSCR-16.
Previous decision that bounds on lowerBoundType must be "refined" (see 'capture' rulesList) proved to be wrong.
The source of typesystem errors is that capture isn't performed properly on arguments which has type variable type.
2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 52f708908b Fix captureWildcard to correctly work with hasBound and type vars. Produce hasBound where needed. (MPSCR-16) 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov f33d94dead Add default classifierType macro expansion for ThisExpression. Fix calls to this macro. (MPSCR-16) 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 99d386c3ef Switch Capture from using TVSubs to type scheme instantiation. Fix checking clsType. (MPSCR-16) 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 0604a69789 Remove older versions of rules and macros for generics. Introduce additional Typecheck stage of "checkGenerics". (MPSCR-16) 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 31dd2a3644 Handle raw & unparameterized classifiers in new macros (MPSCR-16) 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 6f5746a31d Extract checks from macros to separate rules. Add notion of typeScheme (genDecl dataform). Remove type inference logic from capture. (MPSCR-16) 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 78358bfc1c Partly rework 'capture' given new hasBound semantics. Produce hasBound in typeVariable macro for Object bound too. (MPSCR-16) 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 8a2aa76252 Allow default type var decl expansion to typeVariableType() in classifierType macro (MPSCR-16)
e.g. needed for ThisExpression
2019-12-18 21:47:06 +03:00
Grigorii Kirgizov c3aba49059 Fix PathHelper to pass a test for SubtypePaths which uses raw types in subclass paths 2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 0e4e6fe8df Redefine typeVariableDeclaration macro. Use TypeVariableSubstitution more consistently (MPSCR-16). Fix SubclassPaths.
'typeVariableDeclaration' now returns substituted vars or creates new subst.
Earlier it created created a new susbst which led to infinite recursion in specific cases.
Now macro expects tvdecl to be declared in TypeVariableSubstitution.
Accordingly modify usages of TypeVariableSubstitution.

Also fix (apparently broken?) SubclassPaths rulesList (used in lub relation)
and switch 'dpromote' implementation to use it
2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 0bc053fe63 Fix classifierType macro condition, fix typeVariable macro & add tmp forwarding macros (MPSCR-16)
Macros currently don't handle subconcepts expansions.
2019-12-18 21:47:06 +03:00
Grigorii Kirgizov 2a71743895 Handle cases when inference variables must be instantiated into typeVariableType (MPSCR-16) 2019-12-18 21:47:05 +03:00