@@ -244,52 +244,23 @@ end
244
244
issub (x, y, env) = (x === y)
245
245
issub (x:: Ty , y:: Ty , env) = (x === y) || x === BottomT
246
246
247
- function discover_Lunion (a:: UnionT , env)
247
+ function union_issub (a:: UnionT , b :: Ty , env)
248
248
if env. Ldepth > length (env. Lunions)
249
249
# at a new nesting depth, begin by just counting unions
250
250
env. Lnew += 1
251
251
return true
252
252
end
253
- return false
254
- end
255
-
256
- function discover_Runion (b:: UnionT , env)
257
- if env. Rdepth > length (env. Runions)
258
- env. Rnew += 1
259
- return true
260
- end
261
- return false
262
- end
263
-
264
- function issub (a:: UnionT , b:: UnionT , env)
265
- a === b && return true
266
- if discover_Lunion (a, env) | discover_Runion (b, env)
267
- return true
268
- end
269
- L = env. Lunions[env. Ldepth]; L. i += 1
270
- R = env. Runions[env. Rdepth]; R. i += 1
271
- env. Ldepth += 1
272
- env. Rdepth += 1
273
- ans = issub (a .((L. idxs& (1 << L. i)!= 0 ) + 1 ), b .((R. idxs& (1 << R. i)!= 0 ) + 1 ), env)
274
- env. Rdepth -= 1
275
- env. Ldepth -= 1
276
- return ans
277
- end
278
-
279
- function issub (a:: UnionT , t:: Ty , env)
280
- if discover_Lunion (a, env)
281
- return true
282
- end
283
253
L = env. Lunions[env. Ldepth]; L. i += 1
284
254
env. Ldepth += 1
285
- ans = issub (a .((L. idxs& (1 << L. i)!= 0 ) + 1 ), t , env)
255
+ ans = issub (a .((L. idxs& (1 << L. i)!= 0 ) + 1 ), b , env)
286
256
env. Ldepth -= 1
287
257
return ans
288
258
end
289
259
290
- function issub (a:: Ty , b:: UnionT , env)
260
+ function issub_union (a:: Ty , b:: UnionT , env)
291
261
a === BottomT && return true
292
- if discover_Runion (b, env)
262
+ if env. Rdepth > length (env. Runions)
263
+ env. Rnew += 1
293
264
return true
294
265
end
295
266
R = env. Runions[env. Rdepth]; R. i += 1
@@ -299,6 +270,10 @@ function issub(a::Ty, b::UnionT, env)
299
270
return ans
300
271
end
301
272
273
+ issub (a:: UnionT , b:: UnionT , env) = a === b || union_issub (a, b, env)
274
+ issub (a:: UnionT , b:: Ty , env) = union_issub (a, b, env)
275
+ issub (a:: Ty , b:: UnionT , env) = issub_union (a, b, env)
276
+
302
277
function issub (a:: TagT , b:: TagT , env)
303
278
a === b && return true
304
279
b === AnyT && return true
@@ -308,10 +283,8 @@ function issub(a::TagT, b::TagT, env)
308
283
return issub (super (a), b, env)
309
284
end
310
285
if a. name === TupleName
311
- va = a. vararg
312
- vb = b. vararg
313
- la = length (a. params)
314
- lb = length (b. params)
286
+ va, vb = a. vararg, b. vararg
287
+ la, lb = length (a. params), length (b. params)
315
288
if va && (! vb || la < lb)
316
289
return false
317
290
end
@@ -350,8 +323,7 @@ function issub(a::Var, b::Ty, env)
350
323
# invariant position. So just return true when checking the "flipped"
351
324
# direction B<:A.
352
325
aa. right && return true
353
- d = env. depth
354
- if d != aa. depth # && d > 1 ???
326
+ if env. depth != aa. depth # && env.depth > 1 ???
355
327
# Var <: non-Var can only be true when there are no invariant
356
328
# constructors between the UnionAll and this occurrence of Var.
357
329
return false
@@ -364,12 +336,11 @@ function issub(a::Var, b::Var, env)
364
336
aa = env. vars[a]
365
337
aa. right && return true
366
338
bb = env. vars[b]
367
- d = env. depth
368
- if aa. depth != bb. depth # && d > 1 ???
339
+ if aa. depth != bb. depth # && env.depth > 1 ???
369
340
# Vars must occur at same depth
370
341
return false
371
342
end
372
- if d > bb. depth
343
+ if env . depth > bb. depth
373
344
# if there are invariant constructors between a UnionAll and
374
345
# this occurrence of Var, then we have an equality constraint on Var.
375
346
if isa (bb. ub,Var)
0 commit comments