sorbet-runtime 0.5.9058 → 0.5.9064

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e15f5bb2c23ab6f1a94d99fc85188a14a1fba652d4c8994bf84a5d568d7f808d
4
- data.tar.gz: 868e7ee916c1b38dd543d83277c06b8b1649b89e7007fe1a44869f31a129202d
3
+ metadata.gz: a36c0a956aee4ce8e78e9585799a20639754d948262415124cdde5785acfdeb5
4
+ data.tar.gz: f1df593f23974252f13762fa67bc2890de361b7f7db7f0dd906b1035e89433e6
5
5
  SHA512:
6
- metadata.gz: 4d44ba58916117adc0d516597779a7f66d92b9f3050416aa018cf313da0e1b09c1e1572a8f7f5cca6c68064a41fd0a61866e661ff25c6535e1363d45153b6704
7
- data.tar.gz: 64187d1b8daa52799600e370891594ae9f10b71fd9b163e84c6ddb4de6a7829d869e80780ca1b35dfc733f0719b3fc7590ff30dcd9e99a1465c3de72d626c50b
6
+ metadata.gz: 6489cc5e4bf147de9b7f57f178c54468fa656961f30ac252f02c02a5a5bef4569714c7227503b1ae68fefbaa28b947c64159dc9086d8b8cc1726e962b778c38d
7
+ data.tar.gz: 8cd9b6d6ed52390e73b7ce3a0a46b320a4acdea86661aae957e8e11bb85e092f280c15df39d214a546f654248f8f646723ca7ea596dda7cafa43771b66d81014
@@ -112,3 +112,6 @@ require_relative 'types/struct'
112
112
  require_relative 'types/non_forcing_constants'
113
113
 
114
114
  require_relative 'types/compatibility_patches'
115
+
116
+ # Sorbet Compiler support module
117
+ require_relative 'types/private/compiler'
@@ -112,7 +112,7 @@ module T::Configuration
112
112
  # statically, so that methods don't have to guard themselves from being
113
113
  # called incorrectly by untyped code.
114
114
  #
115
- # @param [:never, :tests, :always] default_checked_level
115
+ # @param [:never, :compiled, :tests, :always] default_checked_level
116
116
  def self.default_checked_level=(default_checked_level)
117
117
  T::Private::RuntimeLevels.default_checked_level = default_checked_level
118
118
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module T::Private
5
+ module Compiler
6
+ # If this code ever runs, the caller is running interpreted (or the
7
+ # compiler didn't see the call to `running_compiled?` statically.)
8
+ #
9
+ # The Sorbet Compiler replaces calls to this method unconditionally (no
10
+ # runtime guards) to return `true` when compiling a file.
11
+ def self.running_compiled?
12
+ false
13
+ end
14
+
15
+ # Returns `nil` because the compiler isn't running.
16
+ #
17
+ # The Sorbet Compiler replaces calls to this method unconditionally (no
18
+ # runtime guards) to return a String showing the Sorbet Compiler's version
19
+ # string.
20
+ def self.compiler_version
21
+ nil
22
+ end
23
+ end
24
+ end
@@ -88,8 +88,8 @@ module T::Private::Methods
88
88
  if !decl.checked.equal?(ARG_NOT_PROVIDED)
89
89
  raise BuilderError.new("You can't call .checked multiple times in a signature.")
90
90
  end
91
- if level == :never && !decl.on_failure.equal?(ARG_NOT_PROVIDED)
92
- raise BuilderError.new("You can't use .checked(:never) with .on_failure because .on_failure will have no effect.")
91
+ if (level == :never || level == :compiled) && !decl.on_failure.equal?(ARG_NOT_PROVIDED)
92
+ raise BuilderError.new("You can't use .checked(:#{level}) with .on_failure because .on_failure will have no effect.")
93
93
  end
94
94
  if !T::Private::RuntimeLevels::LEVELS.include?(level)
95
95
  raise BuilderError.new("Invalid `checked` level '#{level}'. Use one of: #{T::Private::RuntimeLevels::LEVELS}.")
@@ -106,8 +106,8 @@ module T::Private::Methods
106
106
  if !decl.on_failure.equal?(ARG_NOT_PROVIDED)
107
107
  raise BuilderError.new("You can't call .on_failure multiple times in a signature.")
108
108
  end
109
- if decl.checked == :never
110
- raise BuilderError.new("You can't use .on_failure with .checked(:never) because .on_failure will have no effect.")
109
+ if decl.checked == :never || decl.checked == :compiled
110
+ raise BuilderError.new("You can't use .on_failure with .checked(:#{decl.checked}) because .on_failure will have no effect.")
111
111
  end
112
112
 
113
113
  decl.on_failure = args
@@ -209,7 +209,7 @@ module T::Private::Methods
209
209
  end
210
210
  if decl.checked.equal?(ARG_NOT_PROVIDED)
211
211
  default_checked_level = T::Private::RuntimeLevels.default_checked_level
212
- if default_checked_level == :never && !decl.on_failure.equal?(ARG_NOT_PROVIDED)
212
+ if (default_checked_level == :never || default_checked_level == :compiled) && !decl.on_failure.equal?(ARG_NOT_PROVIDED)
213
213
  raise BuilderError.new("To use .on_failure you must additionally call .checked(:tests) or .checked(:always), otherwise, the .on_failure has no effect.")
214
214
  end
215
215
  decl.checked = default_checked_level
@@ -174,7 +174,7 @@ module T::Private::Methods::SignatureValidation
174
174
  return if signature.override_allow_incompatible
175
175
  return if super_signature.mode == Modes.untyped
176
176
  return unless [signature, super_signature].all? do |sig|
177
- sig.check_level == :always || (sig.check_level == :tests && T::Private::RuntimeLevels.check_tests?)
177
+ sig.check_level == :always || sig.check_level == :compiled || (sig.check_level == :tests && T::Private::RuntimeLevels.check_tests?)
178
178
  end
179
179
  mode_noun = super_signature.mode == Modes.abstract ? 'implementation' : 'override'
180
180
 
@@ -12,6 +12,9 @@ module T::Private::RuntimeLevels
12
12
  # Don't even validate in tests, b/c too expensive,
13
13
  # or b/c we fully trust the static typing
14
14
  :never,
15
+ # Validate the sig when the file is using the Sorbet Compiler.
16
+ # Behaves like :never when interpreted.
17
+ :compiled,
15
18
  ].freeze
16
19
 
17
20
  @check_tests = false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9058
4
+ version: 0.5.9064
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-22 00:00:00.000000000 Z
11
+ date: 2021-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -173,6 +173,7 @@ files:
173
173
  - lib/types/private/abstract/validate.rb
174
174
  - lib/types/private/casts.rb
175
175
  - lib/types/private/class_utils.rb
176
+ - lib/types/private/compiler.rb
176
177
  - lib/types/private/decl_state.rb
177
178
  - lib/types/private/final.rb
178
179
  - lib/types/private/methods/_methods.rb