Skip to content

Commit

Permalink
Only mark builtin StyleMetrics as deprectated.
Browse files Browse the repository at this point in the history
User defined component or global named StyleMetrics shouldn't be deprecated
  • Loading branch information
ogoffart committed May 28, 2024
1 parent 1feb612 commit 61233d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/compiler/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,14 @@ impl LookupType {
Some(LookupResult::Expression {
expression: Expression::ElementReference(Rc::downgrade(&c.root_element)),
deprecated: (name == "StyleMetrics"
&& !ctx.type_register.expose_internal_types)
.then(|| "Palette".to_string()),
&& !ctx.type_register.expose_internal_types
&& c.root_element
.borrow()
.debug
.get(0)
.and_then(|x| x.0.source_file())
.map_or(false, |x| x.path().starts_with("builtin:")))
.then(|| "Palette".to_string()),
})
}
}
Expand Down
6 changes: 6 additions & 0 deletions internal/compiler/tests/syntax/lookup/global.slint
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ global my_lowercase := {
}


global StyleMetrics {
out property <length> padding: 3px;
}

export X := Rectangle {
x: MyGlobal.custom_prop;
background: MyGlobal.blue;
Expand All @@ -28,6 +32,8 @@ export X := Rectangle {
// ^error{Cannot access id 'NativeStyleMetrics'}
visible: SlintInternal.color-scheme;
// ^error{Cannot access id 'SlintInternal'}

height: StyleMetrics.padding;
}

property <int> my_lowercase: 45;
Expand Down

0 comments on commit 61233d8

Please sign in to comment.