Skip to content

Commit

Permalink
improve numeric enum name
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Aug 26, 2024
1 parent 9c9c05e commit 4e725c2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions sway-core/src/language/ty/declaration/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,15 +573,15 @@ impl TyFunctionSig {

pub fn is_concrete(&self, engines: &Engines) -> bool {
self.return_type
.is_concrete(engines, NumericIsNonConcrete::No)
.is_concrete(engines, TreatNumericAs::Concrete)
&& self
.parameters
.iter()
.all(|p| p.is_concrete(engines, NumericIsNonConcrete::No))
.all(|p| p.is_concrete(engines, TreatNumericAs::Concrete))
&& self
.type_parameters
.iter()
.all(|p| p.is_concrete(engines, NumericIsNonConcrete::No))
.all(|p| p.is_concrete(engines, TreatNumericAs::Concrete))
}

/// Returns a String representing the function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ fn type_check_encode_append(
};

// only supported types
if item_type.is_concrete(engines, NumericIsNonConcrete::Yes) {
if item_type.is_concrete(engines, TreatNumericAs::Abstract) {
match &*engines.te().get(item_type) {
TypeInfo::Boolean
| TypeInfo::UnsignedInteger(IntegerBits::Eight)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1866,13 +1866,13 @@ impl ty::TyExpression {
.fold_while(None, |last, current| match last {
None => Continue(Some(current.return_type)),
Some(last) => {
if last.is_concrete(engines, NumericIsNonConcrete::Yes) {
if last.is_concrete(engines, TreatNumericAs::Abstract) {
return Done(Some(last));
}

if current
.return_type
.is_concrete(engines, NumericIsNonConcrete::Yes)
.is_concrete(engines, TreatNumericAs::Abstract)
{
return Done(Some(current.return_type));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub(crate) fn type_check_method_application(
x.return_type
.extract_inner_types(engines, IncludeSelf::Yes)
.iter()
.any(|x| !x.is_concrete(engines, NumericIsNonConcrete::Yes))
.any(|x| !x.is_concrete(engines, TreatNumericAs::Abstract))
})
.unwrap_or_default();
let needs_second_pass = has_errors || is_not_concrete;
Expand Down
12 changes: 6 additions & 6 deletions sway-core/src/type_system/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pub enum IncludeSelf {
No,
}

pub enum NumericIsNonConcrete {
Yes,
No,
pub enum TreatNumericAs {
Abstract,
Concrete,
}

/// A identifier to uniquely refer to our type terms
Expand Down Expand Up @@ -464,13 +464,13 @@ impl TypeId {
pub(crate) fn is_concrete(
&self,
engines: &Engines,
numeric_non_concrete: NumericIsNonConcrete,
numeric_non_concrete: TreatNumericAs,
) -> bool {
let nested_types = (*self).extract_nested_types(engines);
!nested_types
.into_iter()
.any(|x| match numeric_non_concrete {
NumericIsNonConcrete::Yes => matches!(
TreatNumericAs::Abstract => matches!(
x,
TypeInfo::UnknownGeneric { .. }
| TypeInfo::Custom { .. }
Expand All @@ -479,7 +479,7 @@ impl TypeId {
| TypeInfo::TypeParam(..)
| TypeInfo::Numeric
),
NumericIsNonConcrete::No => matches!(
TreatNumericAs::Concrete => matches!(
x,
TypeInfo::UnknownGeneric { .. }
| TypeInfo::Custom { .. }
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/type_system/priv_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ pub use super::{
type_parameter::TypeParameter,
},
engine::TypeEngine,
id::{IncludeSelf, NumericIsNonConcrete, TypeId},
id::{IncludeSelf, TreatNumericAs, TypeId},
info::{AbiEncodeSizeHint, AbiName, TypeInfo, TypeSourceInfo},
};

0 comments on commit 4e725c2

Please sign in to comment.