Commit Graph

243 Commits

Author SHA1 Message Date
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