Commit Graph

540 Commits

Author SHA1 Message Date
Fedor Isakov fceef17a64 Fix typechecking errors 2021-04-28 08:54:25 +02:00
Fedor Isakov 7d0e765381 Fix coderules types
Require statement accepts node-ptr
Fix coderules types: fix logical type in LateParameter
2021-04-28 08:54:25 +02:00
Fedor Isakov 118602b2fd Fix BL types: classifier type with other types as parameters
Also fix code constructs that caused typechecking errors.
2021-04-28 08:54:25 +02:00
Fedor Isakov c0154026ef WIP Fix smodel types: reflective conversion 2021-04-28 08:54:25 +02:00
Fedor Isakov a204df222a Optimize BL types and queries
Make expectType optional (auxiliary).
Drop checkDecls from typeof query (unnecessary).
2021-04-28 08:54:25 +02:00
Fedor Isakov d918fa5c12 Optimize BL types
Switch to pull style boundOf instead of typeVarBound.
Drop importDecls.
2021-04-21 10:45:09 +02:00
Fedor Isakov bf7939b350 Fix logic types: check for null reference 2021-04-19 22:55:09 +02:00
Fedor Isakov 09149fd688 Types for j.m.l.smodel.query lang 2021-04-15 18:06:07 +02:00
Fedor Isakov 2f4f3dae6f Minor optimization in smodel types: pull-style constraint
Instead of reactively create push-style constraint conceptHierarchy,
make it available on request, pull-style.
2021-04-15 16:56:11 +02:00
Fedor Isakov ff6b5ec6ae Apply migrations and rebuild project 2021-04-14 13:19:50 +02:00
Fedor Isakov 6ed5c3329d Fix typing errors: specify correct type annotations 2021-04-14 11:59:09 +02:00
Fedor Isakov 700a7f56b4 Fix generator types 2021-04-14 10:55:29 +02:00
Fedor Isakov 8dbe0c212d Fix smodel types 2021-04-14 10:54:10 +02:00
Fedor Isakov 3a70382202 Fix typesystem types: support for meet/join 2021-04-14 10:53:41 +02:00
Fedor Isakov e76dab0d84 Fix logic and coderules types 2021-04-14 10:53:17 +02:00
Fedor Isakov c0601cb099 Optimizing types for more efficient evaluation
Replace "push" style genDecl constraint with "pull" schemeOf.
Mark rules as "auxiliary" to avoid these being included in
processing as dependencies.
2021-04-12 12:47:44 +02:00
Fedor Isakov 3793b78efb Types for j.m.baseLanguage.classifiers 2021-04-08 08:55:33 +02:00
Fedor Isakov 27420433dc Types for j.m.lang.behavior 2021-04-08 08:55:33 +02:00
Fedor Isakov 5c13129daa Fix type of logical variables in coderules types 2021-04-08 08:55:32 +02:00
Fedor Isakov 65b32a4f48 Fix lub processing in BL types 2021-04-08 08:54:46 +02:00
Fedor Isakov 1eadb46611 Fix smodel types: assign void type to operations w/o returned value 2021-04-08 08:54:22 +02:00
Fedor Isakov d7ff661670 Types for j.m.l.test lang 2021-04-08 08:53:29 +02:00
Fedor Isakov 105fe1dd7e Fix dataform type conversion to term/termlist 2021-04-08 08:51:39 +02:00
Fedor Isakov 6b3e74dda2 Fix conversions in tuple types 2021-04-08 08:50:50 +02:00
Fedor Isakov f5b4b0edb0 Fix binary op in collections lang 2021-04-08 08:50:28 +02:00
Fedor Isakov 693c760618 Add types for j.m.l.test language. 2021-03-23 12:48:07 +01:00
Fedor Isakov 5fc019caca Mark an exhastive check rule as "auxiliary" to avoid including it as dependency. 2021-03-08 12:34:40 +01:00
Fedor Isakov a9ff6730ca Fix concept type conversion to classifier with undefined concept. 2021-03-08 12:34:40 +01:00
Fedor Isakov c36679bcc6 Fix logic inconsistent type error
Naive check won't suffice to ensure multilogical are used properly.
Need more sophisticated type check.
2021-03-08 12:34:39 +01:00
Fedor Isakov 81831db86a Move experimental controlflow aspect to a separate language 2021-02-06 15:28:03 +01:00
Fedor Isakov dee5db0e96 Drop instances of TermFeature.final property 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
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
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 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 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 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 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
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 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 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 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 15cfd8a51b Refactor bl queries: separate "independent" query parts for Preamble 2020-11-18 11:36:28 +03: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 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 02182f4f2f Closures lang types: add template for ClosureArgReference concept. 2020-08-12 12:38:51 +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 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 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 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 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 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 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 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 8731ca0fce Fix typechecking baseMethodCall: correctly idenify this type. 2020-07-03 16:23:00 +02: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 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 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
Fedor Isakov d4602c50d6 Ensure relevant input concepts are in query scope. 2020-06-28 17:14:35 +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 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 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 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 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 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 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 acd6234415 Force save all. 2020-05-09 10:54:18 +02: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 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 735276d2a2 Add import/export constructs for sequence type in collectionsExt to enable basic tests 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 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 35fd816cbc Update all usages of moved concepts. 2020-04-13 18:00:15 +02:00