Commit Graph

32256 Commits

Author SHA1 Message Date
Asumu Takikawa
92e34ebab9 Fix class type subtyping
Although classes have no non-trivial subtyping relationships,
the representation I chose ends up introducing cases where two
"equal" types are not represented in the same way. This
commit fixes that by checking only the relevant parts of the
representation.
2014-02-20 16:50:24 -05:00
Asumu Takikawa
939c3bb4c8 Implement row polymorphism
- Refactor syntax classes and parsing for class types in
    order to accommodate constraints for row polymorphism
  - No contract generation, but other parts are implemented
2014-02-20 16:50:24 -05:00
Asumu Takikawa
884c898bfa Change #:extends to #:implements 2014-02-20 16:50:24 -05:00
Asumu Takikawa
c47531569a Add parsing for (Object ...) types into Instances 2014-02-20 16:50:24 -05:00
Asumu Takikawa
32f39ddff4 Improve object type printing
Use the `Object` constructor style instead of `Instance`
in cases where it makes sense.
2014-02-20 16:50:24 -05:00
Asumu Takikawa
081cc4777a Add syntactic sugar for recursive class types 2014-02-20 16:50:24 -05:00
Asumu Takikawa
a1efc2c276 Attempt to support recursive types in classes better 2014-02-20 16:50:24 -05:00
Asumu Takikawa
16ca57500b Remove debug displays 2014-02-20 16:50:24 -05:00
Asumu Takikawa
19b1ca17c6 Attempt to allow recursive types in objects/classes
Contract generation is not implemented correctly yet
since the static contract portion needs adjustment.
2014-02-20 16:50:24 -05:00
Asumu Takikawa
cc61f0639e Allow duplicate type names if they have the same type 2014-02-20 16:50:24 -05:00
Asumu Takikawa
f84cf996c3 Add "multiple inheritance" for class types 2014-02-20 16:50:24 -05:00
Asumu Takikawa
4543204e85 Don't add super-type inits into type with #:extends 2014-02-20 16:50:24 -05:00
Asumu Takikawa
bbd5d97a23 Support private fields 2014-02-20 16:50:23 -05:00
Asumu Takikawa
4559981212 Add super calls
(also removed bogus super-new init test)
2014-02-20 16:50:23 -05:00
Asumu Takikawa
ba70851ba0 Don't make mandatory super inits mandatory for super-new 2014-02-20 16:50:23 -05:00
Asumu Takikawa
f82a49be7d Fix type-checking for fields with this 2014-02-20 16:50:23 -05:00
Asumu Takikawa
6b5875a1f1 Fix subtyping for fields 2014-02-20 16:50:23 -05:00
Asumu Takikawa
5da60f7067 Make keyword methods type-check
Note: send does not work with keyword methods yet
2014-02-20 16:50:23 -05:00
Asumu Takikawa
4e5d0846ba Add support for inherited methods 2014-02-20 16:50:23 -05:00
Asumu Takikawa
30e3c49886 Attempt better error message for bad method type case 2014-02-20 16:50:23 -05:00
Asumu Takikawa
0d5a775a62 Better support for class top-level behavior 2014-02-20 16:50:23 -05:00
Asumu Takikawa
b9a175eed2 Allow top-level expressions to refer to inits 2014-02-20 16:50:23 -05:00
Asumu Takikawa
384e1392bd Cleanup FIXME comments 2014-02-20 16:50:23 -05:00
Asumu Takikawa
6f86c66199 Improve super-new handling.
Now `super-new` calls are type-checked with the right
context so that init arguments can be passed as arguments.

In addition, the `super-new` checking was factored out into
three functions.
2014-02-20 16:50:23 -05:00
Asumu Takikawa
44f9b87f02 Fix optional argument check that was broken 2014-02-20 16:50:23 -05:00
Asumu Takikawa
14eeab934c Make init defaults work correctly as well 2014-02-20 16:50:23 -05:00
Asumu Takikawa
aa830a3461 Get init-field working in most cases 2014-02-20 16:50:23 -05:00
Asumu Takikawa
267a37134e Type-check field initialization
Also fixed local accessors when internal names are used that
are different from external names.
2014-02-20 16:50:23 -05:00
Asumu Takikawa
6ce16e1538 Factor out class expansion parsing
This commit prepares the code for more interesting parsing
of the initializer body (for expansion-introduced top-level
expressions for example) and faster parsing of methods and
other things in a single pass.
2014-02-20 16:50:23 -05:00
Asumu Takikawa
599beeae52 Fix non-expected case with inits/fields missing annotations
Also fix bogus test cases and the bug that hid them
2014-02-20 16:50:23 -05:00
Asumu Takikawa
f188d7f103 Check more clause presence/absence appropriately 2014-02-20 16:50:22 -05:00
Asumu Takikawa
f010a9ce71 Rule out multiple super-new 2014-02-20 16:50:22 -05:00
Asumu Takikawa
0ef255916d Add support for private methods 2014-02-20 16:50:22 -05:00
Asumu Takikawa
ab8513f48d Fix bug that triggers due to missing super-new 2014-02-20 16:50:22 -05:00
Asumu Takikawa
c009948627 Make sure super inits that are provided don't count 2014-02-20 16:50:22 -05:00
Asumu Takikawa
b1627984e2 Make sure superclass mandatory inits are provided 2014-02-20 16:50:22 -05:00
Asumu Takikawa
c16a3b2350 Fix inheritance without expected type 2014-02-20 16:50:22 -05:00
Asumu Takikawa
d8a3039830 Set init arguments as optional correctly 2014-02-20 16:50:22 -05:00
Asumu Takikawa
f895e3156f Make internal/external names work 2014-02-20 16:50:22 -05:00
Asumu Takikawa
ae2866e8ca Better class types when no expected type given 2014-02-20 16:50:22 -05:00
Asumu Takikawa
2ae1f5a602 Fix top-level use of classes 2014-02-20 16:50:22 -05:00
Asumu Takikawa
dc35a8cd4d Type-check class top-level expressions 2014-02-20 16:50:22 -05:00
Asumu Takikawa
6a43fac5c2 Support tc-expr and not just tc-expr/check
Note: the type is too conservative in some cases with
      tc-expr (if you leave : annotations out). This should
      be fixed in the future.
2014-02-20 16:50:22 -05:00
Asumu Takikawa
709f3c6696 Add infrastructure for private methods
They don't actually work yet, because I don't yet know
how to assign them types for when they're called locally.
Probably requires the two pass approach for locals.
2014-02-20 16:50:22 -05:00
Asumu Takikawa
6c0e82f15b Add support for local field access 2014-02-20 16:50:22 -05:00
Asumu Takikawa
931556264e Add support for override 2014-02-20 16:50:22 -05:00
Asumu Takikawa
060aaa8b26 Check super-new calls
Still need to use this information to adjust the class
type init clauses
2014-02-20 16:50:21 -05:00
Asumu Takikawa
77847de944 Add unit tests for classes 2014-02-20 16:50:21 -05:00
Asumu Takikawa
244135a96e Initial work on type-checking class expressions
Add a `class:` macro that adds instrumentation for
the type-checker. Also add type-checking for the
expansion of that macro.
2014-02-20 16:50:21 -05:00
Asumu Takikawa
684fabde1b Clean up object init and add support for get-field 2014-02-20 16:50:21 -05:00