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

Change short_reference for top-level methods to ::foo #14071

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/compiler/semantic/def_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ describe "Semantic: def" do

foo
),
"method top-level foo must return Int32 but it is returning Char"
"method ::foo must return Int32 but it is returning Char"
end

it "errors if return type doesn't match on instance method" do
Expand Down
14 changes: 7 additions & 7 deletions spec/compiler/semantic/warnings_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe "Semantic: warnings" do

foo
CRYSTAL
"warning in line 5\nWarning: Deprecated top-level foo. Do not use me"
"warning in line 5\nWarning: Deprecated ::foo. Do not use me"
end

it "deprecation reason is optional" do
Expand All @@ -51,7 +51,7 @@ describe "Semantic: warnings" do

foo
CRYSTAL
"warning in line 5\nWarning: Deprecated top-level foo."
"warning in line 5\nWarning: Deprecated ::foo."
end

it "detects deprecated instance methods" do
Expand Down Expand Up @@ -127,7 +127,7 @@ describe "Semantic: warnings" do

foo(a: 2)
CRYSTAL
"warning in line 5\nWarning: Deprecated top-level foo:a."
"warning in line 5\nWarning: Deprecated ::foo:a."
end

it "detects deprecated initialize" do
Expand Down Expand Up @@ -277,7 +277,7 @@ describe "Semantic: warnings" do

foo
CRYSTAL
"warning in line 7\nWarning: Deprecated top-level foo."
"warning in line 7\nWarning: Deprecated ::foo."
end

it "errors if invalid argument type" do
Expand Down Expand Up @@ -316,7 +316,7 @@ describe "Semantic: warnings" do
end

foo
), "warning in line 6\nWarning: Deprecated top-level foo. Do not use me"
), "warning in line 6\nWarning: Deprecated ::foo. Do not use me"
end

it "deprecation reason is optional" do
Expand All @@ -326,7 +326,7 @@ describe "Semantic: warnings" do
end

foo
), "warning in line 6\nWarning: Deprecated top-level foo."
), "warning in line 6\nWarning: Deprecated ::foo."
end

it "detects deprecated class macros" do
Expand Down Expand Up @@ -372,7 +372,7 @@ describe "Semantic: warnings" do
end

foo(a: 2)
), "warning in line 6\nWarning: Deprecated top-level foo."
), "warning in line 6\nWarning: Deprecated ::foo."
end

it "informs warnings once per call site location (a)" do
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/crystal/semantic/warnings.cr
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module Crystal
def short_reference
case owner
when Program
"top-level #{name}"
"::#{name}"
when MetaclassType
"#{owner.instance_type.to_s(generic_args: false)}.#{name}"
else
Expand Down Expand Up @@ -122,7 +122,7 @@ module Crystal
def short_reference
case owner
when Program
"top-level #{name}"
"::#{name}"
when .metaclass?
"#{owner.instance_type}.#{name}"
else
Expand Down