Skip to content

Commit 0f54f45

Browse files
stepanchegfacebook-github-bot
authored andcommitted
StarlarkValue::get_starlark_type_repr return TyStarlarkValue by default
Summary: Types defined with rust code are based on `StarlarkValue` with this diff by default. Reviewed By: ianlevesque Differential Revision: D48935231 fbshipit-source-id: 0949f850c8d3896b1cb9099c14fa35276e8cf9d1
1 parent 613471b commit 0f54f45

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

starlark/src/values/traits.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ pub trait StarlarkValue<'v>:
248248
/// This can be only implemented by the [`#[starlark_value]`](crate::values::starlark_value)
249249
/// proc macro.
250250
fn get_type_starlark_repr() -> Ty {
251-
// TODO(nga): replace with `Ty::starlark_value::<Self>()`.
252-
Ty::name_static(Self::TYPE)
251+
Ty::starlark_value::<Self>()
253252
}
254253

255254
/// Please do not implement this method or `get_type`,

starlark/src/values/types/dict/value.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,10 @@ where
497497
fn typechecker_ty(&self) -> Option<Ty> {
498498
Some(Ty::any_dict())
499499
}
500+
501+
fn get_type_starlark_repr() -> Ty {
502+
Ty::any_dict()
503+
}
500504
}
501505

502506
impl<'v, T: DictLike<'v>> Serialize for DictGen<T> {

starlark/src/values/types/list/value.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,10 @@ where
544544
fn typechecker_ty(&self) -> Option<Ty> {
545545
Some(Ty::any_list())
546546
}
547+
548+
fn get_type_starlark_repr() -> Ty {
549+
Ty::any_list()
550+
}
547551
}
548552

549553
impl<'v, T: ListLike<'v>> Serialize for ListGen<T> {

starlark/src/values/types/starlark_value_as_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def g(x: CompilerArgs): pass
198198
def h():
199199
g([])
200200
"#,
201-
r#"Expected type `"compiler_args"` but got"#,
201+
r#"Expected type `compiler_args` but got"#,
202202
);
203203
}
204204

starlark/src/values/types/tuple/value.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ where
259259
fn typechecker_ty(&self) -> Option<Ty> {
260260
Some(Ty::any_tuple())
261261
}
262+
263+
fn get_type_starlark_repr() -> Ty {
264+
Ty::any_tuple()
265+
}
262266
}
263267

264268
impl<'v, V: ValueLike<'v>> Serialize for TupleGen<V> {

0 commit comments

Comments
 (0)