Type safety analysis for Dart

Optional typing is traditionally viewed as a compromise between static and dynamic type checking, where code without type annotations is not checked until runtime. We demonstrate that optional type annotations in Dart programs can be integrated into a flow analysis to provide static type safety guarantees both for annotated and non-annotated parts of the code. We explore two approaches: one that uses type annotations for filtering, and one that uses them as specifications. What makes this particularly challenging for Dart is that its type system is unsound even for fully annotated code. Experimental results show that the technique is remarkably effective, even without context sensitivity: 99.3% of all property lookup operations are reported type safe in a collection of benchmark programs.

[1]  Jens Palsberg,et al.  Safety Analysis versus Type Inference , 1992, Inf. Comput..

[2]  Erik Ernst,et al.  Message safety in Dart , 2015, DLS.

[3]  Matthias Felleisen,et al.  Catching bugs in the web of program invariants , 1996, PLDI '96.

[4]  Peter Thiemann,et al.  Type Analysis for JavaScript , 2009, SAS.

[5]  Philip Wadler,et al.  Blame and coercion: together again for the first time , 2015, Journal of Functional Programming.

[6]  Jeremy G. Siek Gradual Typing for Functional Languages , 2006 .

[7]  Ole Agesen The Cartesian Product Algorithm: Simple and Precise Type Inference Of Parametric Polymorphism , 1995, ECOOP.

[8]  James Noble,et al.  Aliasing in Object-Oriented Programming. Types, Analysis and Verification , 2013, Lecture Notes in Computer Science.

[9]  David Grove,et al.  Optimization of Object-Oriented Programs Using Static Class Hierarchy Analysis , 1995, ECOOP.

[10]  Nevin Heintze,et al.  Set-based analysis of ML programs , 1994, LFP '94.

[11]  Hannes Mehnert Extending Dylan's type system for better type inference and error detection , 2010, ILC '10.

[12]  Eran Yahav,et al.  Alias Analysis for Object-Oriented Programs , 2013, Aliasing in Object-Oriented Programming.

[13]  Manish Vachharajani,et al.  Gradual typing with unification-based inference , 2008, DLS '08.

[14]  Susan Horwitz,et al.  Using static single assignment form to improve flow-insensitive pointer analysis , 1998, PLDI '98.

[15]  John Tang Boyland,et al.  Refined Criteria for Gradual Typing , 2015, SNAPL.

[16]  Mark N. Wegman,et al.  Analysis of pointers and structures , 1990, SIGP.

[17]  Walid Taha,et al.  Gradual Typing for Objects , 2007, ECOOP.

[18]  Gilad Bracha,et al.  Mirrors: design principles for meta-level facilities of object-oriented programming languages , 2004, OOPSLA.

[19]  Avik Chaudhuri,et al.  The ins and outs of gradual type inference , 2012, POPL '12.

[20]  Francisco Ortin Type Inference to Optimize a Hybrid Statically and Dynamically Typed Language , 2011, Comput. J..

[21]  Robert Cartwright,et al.  Soft typing , 2004, SIGP.

[22]  Jan Vitek,et al.  Is sound gradual typing dead? , 2016, POPL.