Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 78e5206f4067
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4f810f2e3cdb
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Aug 29, 2016

  1. Fix #3197

    ozra committed Aug 29, 2016
    Copy the full SHA
    bc763f0 View commit details

Commits on Sep 1, 2016

  1. Merge pull request #3212 from ozra/fix/aliased_generic_matching_in_re…

    …striction
    
    Fix #3197
    Ary Borenszweig authored Sep 1, 2016
    Copy the full SHA
    4f810f2 View commit details
Showing with 16 additions and 0 deletions.
  1. +15 −0 spec/compiler/semantic/def_overload_spec.cr
  2. +1 −0 src/compiler/crystal/semantic/restrictions.cr
15 changes: 15 additions & 0 deletions spec/compiler/semantic/def_overload_spec.cr
Original file line number Diff line number Diff line change
@@ -301,6 +301,21 @@ describe "Semantic: def overload" do
") { int32 }
end

it "can call overload with aliased generic restriction" do
assert_type("
class Foo(T)
end
alias FooAlias = Foo
def foo(x : FooAlias(T))
1
end
foo(Foo(Int32).new)
") { int32 }
end

it "restrict matches to minimum necessary 1" do
assert_type("
def coco(x : Int, y); 1; end
1 change: 1 addition & 0 deletions src/compiler/crystal/semantic/restrictions.cr
Original file line number Diff line number Diff line change
@@ -506,6 +506,7 @@ module Crystal

def restrict(other : Generic, context)
generic_type = context.defining_type.lookup_path other.name
generic_type = generic_type.remove_alias if generic_type.is_a? AliasType
return super unless generic_type == self.generic_type

generic_type = generic_type.as(GenericType)