Type checking extracted methods

10/07/2020
by   Yuquan Fu, et al.
0

Many object-oriented dynamic languages allow programmers to extract methods from objects and treat them as functions. This allows for flexible programming patterns, but presents challenges for type systems. In particular, a simple treatment of method extraction would require methods to be contravariant in the reciever type, making overriding all-but-impossible. We present a detailed investigation of this problem, as well as an implemented and evaluated solution. We show how existing gradual type systems such as TypeScript and Flow are unsound in the presence of method extraction. Working in the context of Racket, whose structure system includes a low-level form of methods, we show how to combine two existing type system features—existential types and occurrence typing–to produce a sound approach to typing method extraction. Our design is proved sound, has been implemented and shipped in Typed Racket, and works for existing Racket programs using these features.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
02/19/2018

A Type-Based Complexity Analysis of Object Oriented Programs

A type system is introduced for a generic Object Oriented programming la...
research
10/17/2017

EffectiveSan: Type and Memory Error Detection using Dynamically Typed C/C++

Low-level programming languages such as C and C++ are vulnerable to erro...
research
04/16/2021

A Gradual Type System for Elixir

Elixir is a functional programming language with dynamic typing. We prop...
research
05/16/2017

A Co-contextual Type Checker for Featherweight Java (incl. Proofs)

This paper addresses compositional and incremental type checking for obj...
research
12/09/2018

Practical Optional Types for Clojure

Typed Clojure is an optional type system for Clojure, a dynamic language...
research
07/02/2018

Shallow Types for Insightful Programs: Grace is Optional, Performance is Not

Languages with explicit dynamic type checking are increasing in populari...
research
07/12/2019

Revisiting Occurrence Typing

We revisit occurrence typing, a technique to refine the type of variable...

Please sign up or login with your details

Forgot password? Click here to reset