Commit Graph

304 Commits

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