Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop deprecated definitions #10386

Merged
merged 14 commits into from
Mar 9, 2021
Merged
Prev Previous commit
Drop deprecated has_attribute? macro
  • Loading branch information
bcardiff committed Feb 12, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 80772045dbc2af007f22cf8ed1d45990c9da2aae
8 changes: 4 additions & 4 deletions spec/compiler/codegen/macro_spec.cr
Original file line number Diff line number Diff line change
@@ -770,7 +770,7 @@ describe "Code gen: macro" do
)).to_string.should eq("Green")
end

it "says that enum has Flags attribute" do
it "says that enum has Flags annotation" do
run(%(
@[Flags]
enum Color
@@ -779,19 +779,19 @@ describe "Code gen: macro" do
Blue
end

{{Color.has_attribute?("Flags")}}
{{Color.annotation(Flags) ? true : false}}
)).to_b.should be_true
end

it "says that enum doesn't have Flags attribute" do
it "says that enum doesn't have Flags annotation" do
run(%(
enum Color
Red
Green
Blue
end

{{Color.has_attribute?("Flags")}}
{{Color.annotation(Flags) ? true : false}}
)).to_b.should be_false
end

7 changes: 0 additions & 7 deletions src/compiler/crystal/macros.cr
Original file line number Diff line number Diff line change
@@ -1919,13 +1919,6 @@ module Crystal::Macros
def has_method?(name : StringLiteral | SymbolLiteral) : BoolLiteral
end

# Returns `true` if this type has an attribute. For example `@[Flags]`
# or `@[Packed]` (the name you pass to this method is `"Flags"` or `"Packed"`
# in these cases).
@[Deprecated("Use #annotation instead")]
def has_attribute?(name : StringLiteral | SymbolLiteral) : BoolLiteral
end

# Returns the last `Annotation` with the given `type`
# attached to this variable or `NilLiteral` if there are none.
def annotation(type : TypeNode) : Annotation | NilLiteral
13 changes: 0 additions & 13 deletions src/compiler/crystal/macros/methods.cr
Original file line number Diff line number Diff line change
@@ -1624,19 +1624,6 @@ module Crystal
value = arg.to_string("argument to 'TypeNode#has_method?'")
TypeNode.has_method?(type, value)
end
when "has_attribute?"
interpreter.report_warning_at(name_loc, "Deprecated TypeNode#has_attribute?. Use #annotation instead")
interpret_one_arg_method(method, args) do |arg|
value = arg.to_string("argument to 'TypeNode#has_attribute?'")
case value
when "Flags"
BoolLiteral.new(!!type.as?(EnumType).try &.flags?)
when "Packed"
BoolLiteral.new(!!type.as?(ClassType).try &.packed?)
else
BoolLiteral.new(false)
end
end
when "annotation"
fetch_annotation(self, method, args) do |type|
self.type.annotation(type)