Sha256: ffcd555e944026e38865613c765cac43806fef8e3cc537f076dd8891f30fb61f
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
class Houndstooth::Environment # A type which will be replaced by a type argument later. class TypeParameterPlaceholder < Type def initialize(name) @name = name end attr_accessor :name def accepts?(other) if other.is_a?(TypeParameterPlaceholder) && name == other.name 1 else false end end def rbs name end def substitute_type_parameters(instance, call_type_args) # Call type arguments take priority, check those first return call_type_args[name] if call_type_args[name] # Get index of type parameter index = instance.type.type_parameters.index { |tp| tp == name } or return self # Replace with type argument, which should be an instance instance.type_arguments[index] or self end # Yikes! # It doesn't ever make sense to instantiate a type parameter, and trying to do so was # causing problems when passing type arguments around functions, so just don't allow it def instantiate(...) = self end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
houndstooth-0.1.0 | lib/houndstooth/environment/types/special/type_parameter_placeholder.rb |