Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–121 unchanged (121 lines)
122 return false;
123 }
124 }
125
126 boolean thisIsVarArgs = thisParam.isVarArgs();
127 boolean thatIsVarArgs = thatParam.isVarArgs();
128
129 // "that" can't be a supertype, because it's missing a required argument.
130 // NOTE(nicksantos): In our type system, we use {function(...?)} and
131 // {function(...NoType)} to to indicate that arity should not be
132 // checked. Strictly speaking, this is not a correct formulation,
133 // because now a sub-function can required arguments that are var_args
134 // in the super-function. So we special-case this.
135
136 // don't advance if we have variable arguments
137 if (!thisIsVarArgs) {
138 thisParam = thisParam.getNext();
139 }
140 if (!thatIsVarArgs) {
141 thatParam = thatParam.getNext();
…lines 142–145 unchanged (4 lines)
146 thisParam = null;
147 thatParam = null;
148 }
149 }
150
151 // "that" can't be a supertype, because it's missing a required arguement.
152
153 return true;
154 }
155
156 /**
157 * @return True if our parameter spec is equal to {@code that}'s parameter
158 * spec.
…lines 159–275 unchanged (117 lines)

After

…lines 1–121 unchanged (121 lines)
122 return false;
123 }
124 }
125
126 boolean thisIsVarArgs = thisParam.isVarArgs();
127 boolean thatIsVarArgs = thatParam.isVarArgs();
128 boolean thisIsOptional = thisIsVarArgs || thisParam.isOptionalArg();
129 boolean thatIsOptional = thatIsVarArgs || thatParam.isOptionalArg();
130
131 // "that" can't be a supertype, because it's missing a required argument.
132 if (!thisIsOptional && thatIsOptional) {
133 // NOTE(nicksantos): In our type system, we use {function(...?)} and
134 // {function(...NoType)} to to indicate that arity should not be
135 // checked. Strictly speaking, this is not a correct formulation,
136 // because now a sub-function can required arguments that are var_args
137 // in the super-function. So we special-case this.
138 boolean isTopFunction =
139 thatIsVarArgs &&
140 (thatParamType == null ||
141 thatParamType.isUnknownType() ||
142 thatParamType.isNoType());
143 if (!isTopFunction) {
144 return false;
145 }
146 }
147
148 // don't advance if we have variable arguments
149 if (!thisIsVarArgs) {
150 thisParam = thisParam.getNext();
151 }
152 if (!thatIsVarArgs) {
…lines 153–157 unchanged (5 lines)
158 thisParam = null;
159 thatParam = null;
160 }
161 }
162
163 // "that" can't be a supertype, because it's missing a required arguement.
164 if (thisParam != null
165 && !thisParam.isOptionalArg() && !thisParam.isVarArgs()
166 && thatParam == null) {
167 return false;
168 }
169
170 return true;
171 }
172
173 /**
174 * @return True if our parameter spec is equal to {@code that}'s parameter
…lines 175–292 unchanged (118 lines)

Before

program
block_comment "/*\n *\n * ***** BEGIN LICENSE BLOCK *****\n * Version: MPL 1.1"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "jstype"
; ";"
import_declaration (+23 nodes collapsed)
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "ErrorReporter"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Node"
; ";"
block_comment "/**\n * The arrow type is an internal type that models the fu"...
class_declaration
modifiers
final "final"
class "class"
identifier "ArrowType"
superclass
extends "extends"
type_identifier "JSType"
class_body
{ "{"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
long "long"
variable_declarator
identifier "serialVersionUID"
= "="
decimal_integer_literal "1L"
; ";"
field_declaration
modifiers
final "final"
type_identifier "Node"
variable_declarator
identifier "parameters"
; ";"
field_declaration
type_identifier "JSType"
variable_declarator
identifier "returnType"
; ";"
line_comment "// Whether the return type is inferred."
field_declaration
modifiers
final "final"
boolean_type "boolean"
variable_declarator
identifier "returnTypeInferred"
; ";"
constructor_declaration (+32 nodes collapsed)
constructor_declaration (+90 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
boolean_type "boolean"
identifier "isSubtype"
formal_parameters
( "("
formal_parameter
type_identifier "JSType"
identifier "other"
) ")"
block
{ "{"
if_statement (+21 nodes collapsed)
local_variable_declaration
type_identifier "ArrowType"
variable_declarator
identifier "that"
= "="
cast_expression
( "("
type_identifier "ArrowType"
) ")"
identifier "other"
; ";"
line_comment "// This is described in Draft 2 of the ES4 spec,"
line_comment "// Section 3.4.7: Subtyping Function Types."
line_comment "// this.returnType <: that.returnType (covariant)"
if_statement (+28 nodes collapsed)
line_comment "// that.paramType[i] <: this.paramType[i] (contravariant)"
line_comment "//"
line_comment "// If this.paramType[i] is required,"
line_comment "// then that.paramType[i] is required."
line_comment "//"
line_comment "// In theory, the \"required-ness\" should work in the other d"...
line_comment "// well. In other words, if we have"
line_comment "//"
line_comment "// function f(number, number) {}"
line_comment "// function g(number) {}"
line_comment "//"
line_comment "// Then f *should* not be a subtype of g, and g *should* not"...
line_comment "// a subtype of f. But in practice, we do not implement it t"...
line_comment "// We want to support the use case where you can pass g wher"...
line_comment "// expected, and pretend that g ignores the second argument."
line_comment "// That way, you can have a single \"no-op\" function, and you"...
line_comment "// to create a new no-op function for every possible type si"...
line_comment "//"
line_comment "// So, in this case, g < f, but f !< g"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "thisParam"
= "="
method_invocation
identifier "parameters"
. "."
identifier "getFirstChild"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "thatParam"
= "="
method_invocation
field_access
identifier "that"
. "."
identifier "parameters"
. "."
identifier "getFirstChild"
argument_list
( "("
) ")"
; ";"
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "thisParam"
!= "!="
null_literal "null"
&& "&&"
binary_expression
identifier "thatParam"
!= "!="
null_literal "null"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "JSType"
variable_declarator
identifier "thisParamType"
= "="
method_invocation
identifier "thisParam"
. "."
identifier "getJSType"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
type_identifier "JSType"
variable_declarator
identifier "thatParamType"
= "="
method_invocation
identifier "thatParam"
. "."
identifier "getJSType"
argument_list
( "("
) ")"
; ";"
if_statement (+40 nodes collapsed)
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "thisIsVarArgs"
= "="
method_invocation
identifier "thisParam"
. "."
identifier "isVarArgs"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "thatIsVarArgs"
= "="
method_invocation
identifier "thatParam"
. "."
identifier "isVarArgs"
argument_list
( "("
) ")"
; ";"
line_comment "// \"that\" can't be a supertype, because it's missing a requi"...
line_comment "// NOTE(nicksantos): In our type system, we use {function(.."...
line_comment "// {function(...NoType)} to to indicate that arity should no"...
line_comment "// checked. Strictly speaking, this is not a correct formula"...
line_comment "// because now a sub-function can required arguments that ar"...
line_comment "// in the super-function. So we special-case this."
line_comment "// don't advance if we have variable arguments"
if_statement (+23 nodes collapsed)
if_statement (+23 nodes collapsed)
line_comment "// both var_args indicates the end"
if_statement (+24 nodes collapsed)
} "}"
line_comment "// \"that\" can't be a supertype, because it's missing a requi"...
return_statement
return "return"
true "true"
; ";"
} "}"
block_comment "/**\n * @return True if our parameter spec is equal to {@co"...
method_declaration (+179 nodes collapsed)
method_declaration (+84 nodes collapsed)
method_declaration (+152 nodes collapsed)
method_declaration (+26 nodes collapsed)
method_declaration (+26 nodes collapsed)
method_declaration (+26 nodes collapsed)
method_declaration (+36 nodes collapsed)
method_declaration (+21 nodes collapsed)
method_declaration (+116 nodes collapsed)
method_declaration (+110 nodes collapsed)
method_declaration (+26 nodes collapsed)
} "}"

After

program
block_comment "/*\n *\n * ***** BEGIN LICENSE BLOCK *****\n * Version: MPL 1.1"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "jstype"
; ";"
import_declaration (+23 nodes collapsed)
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "ErrorReporter"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Node"
; ";"
block_comment "/**\n * The arrow type is an internal type that models the fu"...
class_declaration
modifiers
final "final"
class "class"
identifier "ArrowType"
superclass
extends "extends"
type_identifier "JSType"
class_body
{ "{"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
long "long"
variable_declarator
identifier "serialVersionUID"
= "="
decimal_integer_literal "1L"
; ";"
field_declaration
modifiers
final "final"
type_identifier "Node"
variable_declarator
identifier "parameters"
; ";"
field_declaration
type_identifier "JSType"
variable_declarator
identifier "returnType"
; ";"
line_comment "// Whether the return type is inferred."
field_declaration
modifiers
final "final"
boolean_type "boolean"
variable_declarator
identifier "returnTypeInferred"
; ";"
constructor_declaration (+32 nodes collapsed)
constructor_declaration (+90 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
boolean_type "boolean"
identifier "isSubtype"
formal_parameters
( "("
formal_parameter
type_identifier "JSType"
identifier "other"
) ")"
block
{ "{"
if_statement (+21 nodes collapsed)
local_variable_declaration
type_identifier "ArrowType"
variable_declarator
identifier "that"
= "="
cast_expression
( "("
type_identifier "ArrowType"
) ")"
identifier "other"
; ";"
line_comment "// This is described in Draft 2 of the ES4 spec,"
line_comment "// Section 3.4.7: Subtyping Function Types."
line_comment "// this.returnType <: that.returnType (covariant)"
if_statement (+28 nodes collapsed)
line_comment "// that.paramType[i] <: this.paramType[i] (contravariant)"
line_comment "//"
line_comment "// If this.paramType[i] is required,"
line_comment "// then that.paramType[i] is required."
line_comment "//"
line_comment "// In theory, the \"required-ness\" should work in the other d"...
line_comment "// well. In other words, if we have"
line_comment "//"
line_comment "// function f(number, number) {}"
line_comment "// function g(number) {}"
line_comment "//"
line_comment "// Then f *should* not be a subtype of g, and g *should* not"...
line_comment "// a subtype of f. But in practice, we do not implement it t"...
line_comment "// We want to support the use case where you can pass g wher"...
line_comment "// expected, and pretend that g ignores the second argument."
line_comment "// That way, you can have a single \"no-op\" function, and you"...
line_comment "// to create a new no-op function for every possible type si"...
line_comment "//"
line_comment "// So, in this case, g < f, but f !< g"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "thisParam"
= "="
method_invocation
identifier "parameters"
. "."
identifier "getFirstChild"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
type_identifier "Node"
variable_declarator
identifier "thatParam"
= "="
method_invocation
field_access
identifier "that"
. "."
identifier "parameters"
. "."
identifier "getFirstChild"
argument_list
( "("
) ")"
; ";"
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "thisParam"
!= "!="
null_literal "null"
&& "&&"
binary_expression
identifier "thatParam"
!= "!="
null_literal "null"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "JSType"
variable_declarator
identifier "thisParamType"
= "="
method_invocation
identifier "thisParam"
. "."
identifier "getJSType"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
type_identifier "JSType"
variable_declarator
identifier "thatParamType"
= "="
method_invocation
identifier "thatParam"
. "."
identifier "getJSType"
argument_list
( "("
) ")"
; ";"
if_statement (+40 nodes collapsed)
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "thisIsVarArgs"
= "="
method_invocation
identifier "thisParam"
. "."
identifier "isVarArgs"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "thatIsVarArgs"
= "="
method_invocation
identifier "thatParam"
. "."
identifier "isVarArgs"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "thisIsOptional"
= "="
binary_expression
identifier "thisIsVarArgs"
|| "||"
method_invocation
identifier "thisParam"
. "."
identifier "isOptionalArg"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "thatIsOptional"
= "="
binary_expression
identifier "thatIsVarArgs"
|| "||"
method_invocation
identifier "thatParam"
. "."
identifier "isOptionalArg"
argument_list
( "("
) ")"
; ";"
line_comment "// \"that\" can't be a supertype, because it's missing a requi"...
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
unary_expression
! "!"
identifier "thisIsOptional"
&& "&&"
identifier "thatIsOptional"
) ")"
block
{ "{"
line_comment "// NOTE(nicksantos): In our type system, we use {function(.."...
line_comment "// {function(...NoType)} to to indicate that arity should no"...
line_comment "// checked. Strictly speaking, this is not a correct formula"...
line_comment "// because now a sub-function can required arguments that ar"...
line_comment "// in the super-function. So we special-case this."
local_variable_declaration
boolean_type "boolean"
variable_declarator
identifier "isTopFunction"
= "="
binary_expression
identifier "thatIsVarArgs"
&& "&&"
parenthesized_expression
( "("
binary_expression
binary_expression
binary_expression
identifier "thatParamType"
== "=="
null_literal "null"
|| "||"
method_invocation
identifier "thatParamType"
. "."
identifier "isUnknownType"
argument_list
( "("
) ")"
|| "||"
method_invocation
identifier "thatParamType"
. "."
identifier "isNoType"
argument_list
( "("
) ")"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
identifier "isTopFunction"
) ")"
block
{ "{"
return_statement
return "return"
false "false"
; ";"
} "}"
} "}"
line_comment "// don't advance if we have variable arguments"
if_statement (+23 nodes collapsed)
if_statement (+23 nodes collapsed)
line_comment "// both var_args indicates the end"
if_statement (+24 nodes collapsed)
} "}"
line_comment "// \"that\" can't be a supertype, because it's missing a requi"...
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
binary_expression
binary_expression
identifier "thisParam"
!= "!="
null_literal "null"
&& "&&"
unary_expression
! "!"
method_invocation
identifier "thisParam"
. "."
identifier "isOptionalArg"
argument_list
( "("
) ")"
&& "&&"
unary_expression
! "!"
method_invocation
identifier "thisParam"
. "."
identifier "isVarArgs"
argument_list
( "("
) ")"
&& "&&"
binary_expression
identifier "thatParam"
== "=="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
false "false"
; ";"
} "}"
return_statement
return "return"
true "true"
; ";"
} "}"
block_comment "/**\n * @return True if our parameter spec is equal to {@co"...
method_declaration (+179 nodes collapsed)
method_declaration (+84 nodes collapsed)
method_declaration (+152 nodes collapsed)
method_declaration (+26 nodes collapsed)
method_declaration (+26 nodes collapsed)
method_declaration (+26 nodes collapsed)
method_declaration (+36 nodes collapsed)
method_declaration (+21 nodes collapsed)
method_declaration (+116 nodes collapsed)
method_declaration (+110 nodes collapsed)
method_declaration (+26 nodes collapsed)
} "}"