Commit Graph

269 Commits

Author SHA1 Message Date
Grigorii Kirgizov b526afd357 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:26:03 +03:00
Fedor Isakov 991ae30ef7 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-10 14:31:23 +01:00
Fedor Isakov ecafb2da6d 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-10 14:31:20 +01: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