typeprof 0.20.1 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3938be1edd2b64861739d4ea2f801972c32fc67b4b791837e2b238d9be3a5bb
4
- data.tar.gz: 8ba23caae4ab25ea713a1b4fca1850cbc44954aaecabcfd9a3e7a3db18c6ea4b
3
+ metadata.gz: 18bdb9e24afde0cb827e78bc77825f9d316fa4959f0276b961f8fd897787810a
4
+ data.tar.gz: '095fdf956b09a88940adfe99f68bc6d6afe6d01f2e521b0ca8801691b3df7ab3'
5
5
  SHA512:
6
- metadata.gz: e946bed7229effa1d0d95fd665875b39344d8aa959e6fa126631b914e8f9ead55a2a5cababd2ea390f1275b04d1e73bec2b4969c3ccc549acfdeb09512ed8626
7
- data.tar.gz: e31d656a00087bb096c91e2c3da129e7d81ee480e99d67685b1c458a5cbf1a2e97c3ea0feef1657b1a895fc44bd2011ba3fd6ef8b387833967e99c1c728b6e4b
6
+ metadata.gz: df332ec8c3b08f13d6bf35dd3ae60604ddb31ea4e27d959b0c027b0fb616ab74df582b292ff27169daf6a962f34b21550a21214826ac8a2815829a57b94dd5ed
7
+ data.tar.gz: cf47173a218dca213e96cc3ebeb84b86c1376cca6f5f06703fb95c1d3de6c0d289d719324ac9d887eefbb36662458bd636250239389fe16bd0f34a66f402abb7
data/Gemfile.lock CHANGED
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- typeprof (0.20.1)
5
- rbs (>= 1.6.2)
4
+ typeprof (0.21.0)
5
+ rbs (>= 1.8.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  coverage-helpers (1.0.0)
11
11
  docile (1.4.0)
12
- power_assert (2.0.0)
12
+ power_assert (2.0.1)
13
13
  rake (13.0.1)
14
- rbs (1.6.2)
14
+ rbs (1.8.1)
15
15
  simplecov (0.21.2)
16
16
  docile (~> 1.1)
17
17
  simplecov-html (~> 0.11)
@@ -19,7 +19,7 @@ GEM
19
19
  simplecov-html (0.12.3)
20
20
  simplecov_json_formatter (0.1.3)
21
21
  stackprof (0.2.17)
22
- test-unit (3.4.4)
22
+ test-unit (3.5.3)
23
23
  power_assert
24
24
 
25
25
  PLATFORMS
@@ -36,4 +36,4 @@ DEPENDENCIES
36
36
  typeprof!
37
37
 
38
38
  BUNDLED WITH
39
- 2.2.15
39
+ 2.3.0.dev
@@ -345,7 +345,7 @@ module TypeProf
345
345
  attr_reader :class_defs
346
346
 
347
347
  class ClassDef # or ModuleDef
348
- def initialize(kind, name, absolute_path)
348
+ def initialize(kind, name, absolute_path, superclass)
349
349
  raise unless name.is_a?(Array)
350
350
  @kind = kind
351
351
  @modules = {
@@ -359,10 +359,11 @@ module TypeProf
359
359
  @cvars = VarTable.new
360
360
  @absolute_path = absolute_path
361
361
  @namespace = nil
362
+ @superclass = superclass
362
363
  @subclasses = []
363
364
  end
364
365
 
365
- attr_reader :kind, :modules, :methods, :ivars, :cvars, :absolute_path, :subclasses
366
+ attr_reader :kind, :modules, :methods, :ivars, :cvars, :absolute_path, :superclass, :subclasses
366
367
  attr_accessor :name, :klass_obj
367
368
 
368
369
  def mix_module(kind, mod, type_args, singleton, absolute_path)
@@ -446,14 +447,22 @@ module TypeProf
446
447
  end
447
448
  end
448
449
 
449
- def check_typed_method(mid, singleton)
450
+ def check_typed(mid, singleton, klass)
450
451
  set = @methods[[singleton, mid]]
451
452
  return nil unless set
452
- set = set.select {|mdef| mdef.is_a?(TypedMethodDef) }
453
+ set = set.select {|mdef| mdef.is_a?(klass) }
453
454
  return nil if set.empty?
454
455
  return set
455
456
  end
456
457
 
458
+ def check_typed_method(mid, singleton)
459
+ check_typed(mid, singleton, TypedMethodDef)
460
+ end
461
+
462
+ def check_typed_attr(mid, singleton)
463
+ check_typed(mid, singleton, TypedAttrMethodDef)
464
+ end
465
+
457
466
  def add_method(mid, singleton, mdef)
458
467
  @methods[[singleton, mid]] ||= Utils::MutableSet.new
459
468
  @methods[[singleton, mid]] << mdef
@@ -494,8 +503,9 @@ module TypeProf
494
503
  show_name = cbase_path(cbase) + [name]
495
504
  idx = @class_defs.size
496
505
  if superclass
497
- @class_defs[idx] = ClassDef.new(:class, show_name, def_ep&.absolute_path)
498
- @class_defs[superclass.idx].subclasses << idx unless superclass == :__root__
506
+ superclass_def = @class_defs[superclass.idx] unless superclass == :__root__
507
+ @class_defs[idx] = ClassDef.new(:class, show_name, def_ep&.absolute_path, superclass_def)
508
+ superclass_def.subclasses << idx if superclass_def
499
509
  klass = Type::Class.new(:class, idx, type_params, superclass, show_name)
500
510
  @class_defs[idx].klass_obj = klass
501
511
  cbase ||= klass # for bootstrap
@@ -503,7 +513,7 @@ module TypeProf
503
513
  return klass
504
514
  else
505
515
  # module
506
- @class_defs[idx] = ClassDef.new(:module, show_name, def_ep&.absolute_path)
516
+ @class_defs[idx] = ClassDef.new(:module, show_name, def_ep&.absolute_path, nil)
507
517
  mod = Type::Class.new(:module, idx, type_params, nil, show_name)
508
518
  @class_defs[idx].klass_obj = mod
509
519
  add_constant(cbase, name, mod, def_ep)
@@ -521,7 +531,8 @@ module TypeProf
521
531
  idx = @class_defs.size
522
532
  superclass = Type::Builtin[:struct]
523
533
  name = "AnonymousStruct_generated_#{ @anonymous_struct_gen_id += 1 }"
524
- @class_defs[idx] = ClassDef.new(:class, [name], ep.ctx.iseq.absolute_path)
534
+ # Should we pass a superclass here?
535
+ @class_defs[idx] = ClassDef.new(:class, [name], ep.ctx.iseq.absolute_path, nil)
525
536
  #@class_defs[superclass.idx].subclasses << idx # needed?
526
537
  klass = Type::Class.new(:class, idx, [], superclass, name)
527
538
  add_superclass_type_args!(klass, [Type.any])
@@ -701,6 +712,10 @@ module TypeProf
701
712
  @class_defs[klass.idx].check_typed_method(mid, singleton)
702
713
  end
703
714
 
715
+ def check_typed_attr(klass, mid, singleton)
716
+ @class_defs[klass.idx].check_typed_attr(mid, singleton)
717
+ end
718
+
704
719
  def add_method(klass, mid, singleton, mdef)
705
720
  @class_defs[klass.idx].add_method(mid, singleton, mdef)
706
721
  mdef
@@ -713,13 +728,26 @@ module TypeProf
713
728
 
714
729
  def add_attr_method(klass, mid, ivar, kind, pub_meth, ep)
715
730
  if kind == :reader || kind == :accessor
716
- add_method(klass, mid, false, AttrMethodDef.new(ivar, :reader, pub_meth, ep))
731
+ typed_mdef = check_typed_attr(klass, mid, ep.ctx.cref.singleton)
732
+ unless typed_mdef
733
+ add_method(klass, mid, false, ExecutedAttrMethodDef.new(ivar, :reader, pub_meth, ep))
734
+ end
717
735
  end
718
736
  if kind == :writer || kind == :accessor
719
- add_method(klass, :"#{ mid }=", false, AttrMethodDef.new(ivar, :writer, pub_meth, ep))
737
+ mid = :"#{ mid }="
738
+ typed_mdef = check_typed_attr(klass, mid, ep.ctx.cref.singleton)
739
+ unless typed_mdef
740
+ add_method(klass, mid, false, ExecutedAttrMethodDef.new(ivar, :writer, pub_meth, ep))
741
+ end
720
742
  end
721
743
  end
722
744
 
745
+ def add_typed_attr_method(klass, mdef)
746
+ name = mdef.ivar[1..-1]
747
+ name = mdef.kind == :writer ? :"#{ name }=" : name.to_sym
748
+ add_method(klass, name, false, mdef)
749
+ end
750
+
723
751
  def add_iseq_method(klass, mid, iseq, cref, outer_ep, pub_meth)
724
752
  add_method(klass, mid, false, ISeqMethodDef.new(iseq, cref, outer_ep, pub_meth))
725
753
  end
@@ -848,7 +876,7 @@ module TypeProf
848
876
  end
849
877
  entry.type = entry.type.union(ty)
850
878
  entry.read_continuations.each do |read_ep, ctn|
851
- ctn[ty, read_ep, [ep]]
879
+ ctn[ty, read_ep, ep ? [ep] : []]
852
880
  end
853
881
  end
854
882
 
@@ -1393,9 +1421,12 @@ module TypeProf
1393
1421
  num, = operands
1394
1422
  env, = env.pop(num)
1395
1423
  env = env.push(Type::Instance.new(Type::Builtin[:str]))
1396
- when :tostring
1424
+ when :tostring, :anytostring
1397
1425
  env, (_ty1, _ty2,) = env.pop(2)
1398
1426
  env = env.push(Type::Instance.new(Type::Builtin[:str]))
1427
+ when :objtostring
1428
+ env, (_ty1,) = env.pop(1)
1429
+ env = env.push(Type::Instance.new(Type::Builtin[:str]))
1399
1430
  when :freezestring
1400
1431
  # do nothing
1401
1432
  when :toregexp
@@ -1418,7 +1449,16 @@ module TypeProf
1418
1449
  cref = ep.ctx.cref
1419
1450
  recv.each_child do |recv|
1420
1451
  if recv.is_a?(Type::Class)
1421
- meth = add_singleton_iseq_method(recv, mid, iseq, cref, nil, env.static_env.pub_meth)
1452
+ typed_mdef = check_typed_method(recv, mid, true)
1453
+ if typed_mdef
1454
+ mdef = ISeqMethodDef.new(iseq, cref, nil, env.static_env.pub_meth)
1455
+ typed_mdef.each do |typed_mdef|
1456
+ typed_mdef.do_match_iseq_mdef(mdef, recv, mid, env, ep, self)
1457
+ end
1458
+ else
1459
+ meth = add_singleton_iseq_method(recv, mid, iseq, cref, nil, env.static_env.pub_meth)
1460
+ end
1461
+
1422
1462
  pend_method_execution(iseq, meth, recv, mid, ep.ctx.cref, nil)
1423
1463
  else
1424
1464
  recv = Type.any # XXX: what to do?
@@ -97,7 +97,8 @@ module TypeProf
97
97
  # check?
98
98
  #subst = { Type::Var.new(:self) => caller_env.static_env.recv_ty }
99
99
  # XXX: Update type vars
100
- ctn[@ret_ty, caller_ep, caller_env]
100
+ ret_ty = @ret_ty.remove_type_vars
101
+ ctn[ret_ty, caller_ep, caller_env]
101
102
  end
102
103
  end
103
104
 
@@ -227,8 +227,9 @@ module TypeProf
227
227
 
228
228
  def screen_name(scratch)
229
229
  str = @elems.screen_name(scratch)
230
- if str.start_with?("*")
231
- str = @base_type.screen_name(scratch) + str[1..]
230
+ if str =~ /\A\*\[(.*)\]\z/
231
+ str = @base_type.klass.type_params.map {|var_name,| var_name == :Elem ? $1 : "untyped" }.join(", ")
232
+ str = "#{ @base_type.screen_name(scratch) }[#{ str }]"
232
233
  end
233
234
  str
234
235
  end
@@ -163,8 +163,7 @@ module TypeProf
163
163
  visibilities[key] ||= mdef.pub_meth
164
164
  source_locations[key] ||= mdef.def_ep&.source_location
165
165
  methods[key] = orig_name
166
- when AttrMethodDef
167
- next if !mdef.def_ep
166
+ when ExecutedAttrMethodDef
168
167
  absolute_path = mdef.def_ep.ctx.iseq.absolute_path
169
168
  next if !absolute_path || Config.current.check_dir_filter(absolute_path) == :exclude
170
169
  mid = mid.to_s[0..-2].to_sym if mid.to_s.end_with?("=")
@@ -191,14 +190,46 @@ module TypeProf
191
190
  visibilities[key] ||= mdef.pub_meth
192
191
  source_locations[key] ||= mdef.iseq&.source_location(0)
193
192
  end
193
+ when TypedAttrMethodDef
194
+ if mdef.rbs_source
195
+ mid = mid.to_s[0..-2].to_sym if mid.to_s.end_with?("=")
196
+ method_name = mid
197
+ method_name = [method_name, :"@#{ mid }" != mdef.ivar]
198
+ key = [:rbs_attr, method_name]
199
+ visibilities[key] ||= mdef.pub_meth
200
+ if methods[key]
201
+ if methods[key][0] != mdef.kind
202
+ methods[key][0] = :accessor
203
+ end
204
+ else
205
+ entry = ivars[[singleton, mdef.ivar]]
206
+ ty = entry ? entry.type : Type.any
207
+ methods[key] = [mdef.kind, ty.screen_name(@scratch), ty.include_untyped?(@scratch)]
208
+ end
209
+ end
194
210
  end
195
211
  end
196
212
  end
197
213
 
214
+ superclass_ivars = {}
215
+ while (superclass_def = (superclass_def || class_def).superclass)
216
+ superclass_ivars.merge!(superclass_def.ivars.dump)
217
+ end
218
+
198
219
  ivars = ivars.map do |(singleton, var), entry|
199
220
  next if entry.absolute_paths.all? {|path| Config.current.check_dir_filter(path) == :exclude }
200
221
  ty = entry.type
201
222
  next unless var.to_s.start_with?("@")
223
+
224
+ if (_, existing = superclass_ivars.find {|((s, v), _)| s == singleton && v == var })
225
+ existing_types = existing.type.is_a?(Type::Union) ? existing.type.types : [existing.type]
226
+ entry_types = entry.type.is_a?(Type::Union) ? entry.type.types : [entry.type]
227
+ if entry_types.all? { |t| existing_types.include?(t) }
228
+ # This type is a subset of the parent type
229
+ next
230
+ end
231
+ end
232
+
202
233
  var = "self.#{ var }" if singleton
203
234
  next if methods[[:attr, [singleton ? "self.#{ var.to_s[1..] }" : var.to_s[1..].to_sym, false]]]
204
235
  next if entry.rbs_declared
@@ -302,7 +333,7 @@ module TypeProf
302
333
  visibilities[key] ||= mdef.pub_meth
303
334
  source_locations[key] ||= [mdef.def_ep&.source_location]
304
335
  methods[key] = orig_name
305
- when AttrMethodDef
336
+ when ExecutedAttrMethodDef
306
337
  next if !mdef.def_ep
307
338
  absolute_path = mdef.def_ep.ctx.iseq.absolute_path
308
339
  next if !absolute_path || Config.current.check_dir_filter(absolute_path) == :exclude
@@ -383,7 +414,7 @@ module TypeProf
383
414
  source_location, rbs_code_range = class_data.source_locations[key]
384
415
  type, (method_name, hidden) = key
385
416
  case type
386
- when :attr
417
+ when :attr, :rbs_attr
387
418
  kind, ty, untyped = *arg
388
419
  line = "attr_#{ kind } #{ method_name }#{ hidden ? "()" : "" }: #{ ty }"
389
420
  when :rbs
@@ -522,11 +553,15 @@ module TypeProf
522
553
  end
523
554
  type, (method_name, hidden) = key
524
555
  case type
556
+ when :rbs_attr
557
+ kind, ty, untyped = *arg
558
+ lines << (indent + "# attr_#{ kind } #{ method_name }#{ hidden ? "()" : "" }: #{ ty }")
525
559
  when :attr
526
560
  kind, ty, untyped = *arg
527
561
  exclude = Config.current.options[:exclude_untyped] && untyped ? "#" : " " # XXX
528
562
  lines << (indent + "#{ exclude } attr_#{ kind } #{ method_name }#{ hidden ? "()" : "" }: #{ ty }")
529
563
  when :rbs
564
+ arg = arg.map { |a| a.split("\n").join("\n" + indent + "#" + " " * (method_name.size + 5)) }
530
565
  sigs = arg.sort.join("\n" + indent + "#" + " " * (method_name.size + 5) + "| ")
531
566
  lines << (indent + "# def #{ method_name }: #{ sigs }")
532
567
  when :iseq
@@ -191,12 +191,15 @@ module TypeProf
191
191
  when RBS::AST::Members::AttrReader
192
192
  ty = conv_type(member.type)
193
193
  attr_methods[[false, member.name]] = attr_method_def(:reader, member.name, ty, visibility)
194
+ rbs_sources[[false, member.name]] = attr_rbs_source(member)
194
195
  when RBS::AST::Members::AttrWriter
195
196
  ty = conv_type(member.type)
196
197
  attr_methods[[false, member.name]] = attr_method_def(:writer, member.name, ty, visibility)
198
+ rbs_sources[[false, member.name]] = attr_rbs_source(member)
197
199
  when RBS::AST::Members::AttrAccessor
198
200
  ty = conv_type(member.type)
199
201
  attr_methods[[false, member.name]] = attr_method_def(:accessor, member.name, ty, visibility)
202
+ rbs_sources[[false, member.name]] = attr_rbs_source(member)
200
203
  when RBS::AST::Members::Alias
201
204
  # XXX: an alias to attr methods?
202
205
  if member.instance?
@@ -394,6 +397,14 @@ module TypeProf
394
397
  }
395
398
  end
396
399
 
400
+ def attr_rbs_source(member)
401
+ [
402
+ member.name.to_s,
403
+ member.type.location.source,
404
+ [member.location.name, CodeRange.from_rbs(member.location)],
405
+ ]
406
+ end
407
+
397
408
  def conv_block(rbs_block)
398
409
  blk = rbs_block.type
399
410
 
@@ -604,11 +615,13 @@ module TypeProf
604
615
  end
605
616
 
606
617
  attr_methods.each do |(singleton, method_name), mdef|
607
- kind = mdef[:kind]
608
- ivar = mdef[:ivar]
618
+ rbs_source = explicit ? rbs_sources[[singleton, method_name]] : nil
609
619
  ty = conv_type(mdef[:ty]).remove_type_vars
610
- @scratch.add_attr_method(klass, ivar, :"@#{ ivar }", kind, mdef[:visibility], nil)
611
- @scratch.add_ivar_write!(Type::Instance.new(klass), :"@#{ ivar }", ty, nil)
620
+ mdefs = conv_attr_defs(mdef, rbs_source)
621
+ mdefs.each do |mdef|
622
+ @scratch.add_typed_attr_method(klass, mdef)
623
+ end
624
+ @scratch.add_ivar_write!(Type::Instance.new(klass), :"@#{ mdef[:ivar] }", ty, nil)
612
625
  end
613
626
 
614
627
  ivars.each do |ivar_name, ty|
@@ -644,6 +657,22 @@ module TypeProf
644
657
  TypedMethodDef.new(sig_rets, rbs_source, mdef[:visibility])
645
658
  end
646
659
 
660
+ def conv_attr_defs(mdef, rbs_source)
661
+ ivar = :"@#{ mdef[:ivar] }"
662
+ kind = mdef[:kind]
663
+ pub_meth = mdef[:visibility]
664
+
665
+ defs = []
666
+ if kind == :reader || kind == :accessor
667
+ defs << TypedAttrMethodDef.new(ivar, :reader, pub_meth, rbs_source)
668
+ end
669
+ if kind == :writer || kind == :accessor
670
+ defs << TypedAttrMethodDef.new(ivar, :writer, pub_meth, rbs_source)
671
+ end
672
+ raise if defs.empty?
673
+ defs
674
+ end
675
+
647
676
  def conv_func(sig_ret)
648
677
  #type_params = sig_ret[:type_params] # XXX
649
678
  lead_tys = sig_ret[:lead_tys]
@@ -21,6 +21,8 @@ TypeProf::INSN_TABLE = {:nop=>[],
21
21
  :putstring=>["VALUE"],
22
22
  :concatstrings=>["rb_num_t"],
23
23
  :tostring=>[],
24
+ :objtostring=>[],
25
+ :anytostring=>[],
24
26
  :freezestring=>["VALUE"],
25
27
  :toregexp=>["rb_num_t", "rb_num_t"],
26
28
  :intern=>[],
data/lib/typeprof/iseq.rb CHANGED
@@ -704,7 +704,7 @@ module TypeProf
704
704
  sp += 1
705
705
  when :newhashfromarray
706
706
  raise NotImplementedError, "newhashfromarray"
707
- when :newrange, :tostring
707
+ when :newrange, :tostring, :objtostring, :anytostring
708
708
  sp -= 2
709
709
  return nil if sp <= 0
710
710
  sp += 1
@@ -753,7 +753,7 @@ module TypeProf
753
753
  when :setlocal, :setblockparam
754
754
  return # conservative
755
755
  when :getinstancevariable, :getclassvariable, :getglobal,
756
- :getlocal, :getblockparam, :getblockparamproxy
756
+ :getlocal, :getblockparam, :getblockparamproxy, :getlocal_checkmatch_branch
757
757
  sp += 1
758
758
  when :getconstant
759
759
  sp -= 2
@@ -67,6 +67,10 @@ module TypeProf
67
67
  if rest_start
68
68
  # almost ok
69
69
  else
70
+ if msig.rest_ty
71
+ scratch.error(ep, "RBS says that a rest argument is accepted, but the method definition does not accept one")
72
+ return
73
+ end
70
74
  if msig.lead_tys.size + msig.post_tys.size < lead_num + post_num
71
75
  scratch.error(ep, "RBS says that the arity may be %d, but the method definition requires at least %d arguments" % [msig.lead_tys.size + msig.post_tys.size, lead_num + post_num])
72
76
  return
@@ -79,7 +83,6 @@ module TypeProf
79
83
 
80
84
  lead_num = @iseq.fargs_format[:lead_num] || 0
81
85
  post_start = @iseq.fargs_format[:post_start]
82
- rest_start = @iseq.fargs_format[:rest_start]
83
86
  kw_start = @iseq.fargs_format[:kwbits]
84
87
  keyword = @iseq.fargs_format[:keyword]
85
88
  kw_start -= keyword.size if kw_start
@@ -175,14 +178,13 @@ module TypeProf
175
178
  end
176
179
 
177
180
  class AttrMethodDef < MethodDef
178
- def initialize(ivar, kind, pub_meth, def_ep)
181
+ def initialize(ivar, kind, pub_meth)
179
182
  @ivar = ivar
180
183
  @kind = kind # :reader | :writer
181
184
  @pub_meth = pub_meth
182
- @def_ep = def_ep
183
185
  end
184
186
 
185
- attr_reader :ivar, :kind, :def_ep
187
+ attr_reader :ivar, :kind
186
188
 
187
189
  def do_send(recv, mid, aargs, caller_ep, caller_env, scratch, &ctn)
188
190
  case @kind
@@ -206,6 +208,25 @@ module TypeProf
206
208
  end
207
209
  end
208
210
 
211
+ class ExecutedAttrMethodDef < AttrMethodDef
212
+ def initialize(ivar, kind, pub_meth, def_ep)
213
+ super(ivar, kind, pub_meth)
214
+ @def_ep = def_ep
215
+ end
216
+
217
+ attr_reader :def_ep
218
+ end
219
+
220
+ class TypedAttrMethodDef < AttrMethodDef
221
+ def initialize(ivar, kind, pub_meth, rbs_source)
222
+ @rbs_source = rbs_source
223
+
224
+ super(ivar, kind, pub_meth)
225
+ end
226
+
227
+ attr_reader :rbs_source
228
+ end
229
+
209
230
  class TypedMethodDef < MethodDef
210
231
  def initialize(sig_rets, rbs_source, pub_meth) # sig_rets: Array<[MethodSignature, (return)Type]>
211
232
  @sig_rets = sig_rets
data/lib/typeprof/type.rb CHANGED
@@ -422,22 +422,22 @@ module TypeProf
422
422
  end
423
423
 
424
424
  def self.any
425
- @any ||= Any.new
425
+ Thread.current[:any] ||= Any.new
426
426
  end
427
427
 
428
428
  def self.bot
429
- @bot ||= Union.new(Utils::Set[], nil)
429
+ Thread.current[:bot] ||= Union.new(Utils::Set[], nil)
430
430
  end
431
431
 
432
432
  def self.bool
433
- @bool ||= Union.new(Utils::Set[
433
+ Thread.current[:bool] ||= Union.new(Utils::Set[
434
434
  Instance.new(Type::Builtin[:true]),
435
435
  Instance.new(Type::Builtin[:false])
436
436
  ], nil)
437
437
  end
438
438
 
439
439
  def self.nil
440
- @nil ||= Instance.new(Type::Builtin[:nil])
440
+ Thread.current[:nil] ||= Instance.new(Type::Builtin[:nil])
441
441
  end
442
442
 
443
443
  def self.optional(ty)
@@ -1,3 +1,3 @@
1
1
  module TypeProf
2
- VERSION = "0.20.1"
2
+ VERSION = "0.21.0"
3
3
  end
data/typeprof.gemspec CHANGED
@@ -24,11 +24,11 @@ Gem::Specification.new do |spec|
24
24
  # Specify which files should be added to the gem when it is released.
25
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
26
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|smoke|testbed)/}) }
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(doc|test|spec|features|smoke|testbed)/}) }
28
28
  end
29
29
  spec.bindir = "exe"
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_runtime_dependency "rbs", ">= 1.6.2"
33
+ spec.add_runtime_dependency "rbs", ">= 1.8.1"
34
34
  end