From cce425dda10dc824054cb887e4ec274c381eec10 Mon Sep 17 00:00:00 2001 From: Michael Cho Date: Thu, 26 Sep 2024 13:30:37 -0400 Subject: [PATCH] cxxstdlib: `typed: strong` --- Library/Homebrew/cxxstdlib.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cxxstdlib.rb b/Library/Homebrew/cxxstdlib.rb index e863b226bb..8b259144a8 100644 --- a/Library/Homebrew/cxxstdlib.rb +++ b/Library/Homebrew/cxxstdlib.rb @@ -1,23 +1,30 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strong # frozen_string_literal: true require "compilers" # Combination of C++ standard library and compiler. class CxxStdlib + sig { params(type: T.nilable(Symbol), compiler: T.any(Symbol, String)).returns(CxxStdlib) } def self.create(type, compiler) raise ArgumentError, "Invalid C++ stdlib type: #{type}" if type && [:libstdcxx, :libcxx].exclude?(type) CxxStdlib.new(type, compiler) end - attr_reader :type, :compiler + sig { returns(T.nilable(Symbol)) } + attr_reader :type + sig { returns(Symbol) } + attr_reader :compiler + + sig { params(type: T.nilable(Symbol), compiler: T.any(Symbol, String)).void } def initialize(type, compiler) @type = type - @compiler = compiler.to_sym + @compiler = T.let(compiler.to_sym, Symbol) end + sig { returns(String) } def type_string type.to_s.gsub(/cxx$/, "c++") end