Skip to content

Commit

Permalink
Change short_reference for top-level methods to ::foo (crystal-lang…
Browse files Browse the repository at this point in the history
  • Loading branch information
keshavbiswa authored Dec 12, 2023
1 parent 4b7fa0c commit 8a1f136
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
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

0 comments on commit 8a1f136

Please sign in to comment.