# I think I must not be understanding how overloads are resolved in class methods

**URL:** <https://forum.crystal-lang.org/t/i-think-i-must-not-be-understanding-how-overloads-are-resolved-in-class-methods/6316>\
**Category:** Help & Support\
**Created:** [January 13, 2024, 11:44pm UTC](https://forum.crystal-lang.org/t/i-think-i-must-not-be-understanding-how-overloads-are-resolved-in-class-methods/6316 "2024-01-13T23:44:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MyrddinE](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/myrddine/32/2195_2.png) [@MyrddinE](https://forum.crystal-lang.org/u/MyrddinE)\
**Post date:** [January 13, 2024, 11:44pm UTC](https://forum.crystal-lang.org/t/i-think-i-must-not-be-understanding-how-overloads-are-resolved-in-class-methods/6316/1 "2024-01-13T23:44:39Z")

</div>

The compile error seems to be clearly saying that there is no overload that matches, despite the second overload clearly does. I must not be understanding something here.

I believe it’s relevant that I’m calling Item.new from _inside_ the class (from a `self.import` class method). Before I refactored the code to move the import inside the class, it was able to resolve the overload.

```auto
 211 | hash[name] = Item.new(name, itype, slot, id)
                                          ^---
Error: expected argument 3 to 'Item.new' to be (Slot | Nil), not (String | Nil)

Overloads are:
 - Item.new(name : String, itype : ItemType, slot : Slot | Nil, id : String | Nil)
 - Item.new(name : String, itype : ItemType, slot : String | Nil, id : String | Nil)

```

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [January 14, 2024, 12:01am UTC](https://forum.crystal-lang.org/t/i-think-i-must-not-be-understanding-how-overloads-are-resolved-in-class-methods/6316/2 "2024-01-14T00:01:25Z")

</div>

Can you share some example code that reproduces this?

---

<div class="post-metadata">

**Author:** ![MyrddinE](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/myrddine/32/2195_2.png) [@MyrddinE](https://forum.crystal-lang.org/u/MyrddinE)\
**Post date:** [January 14, 2024, 12:19am UTC](https://forum.crystal-lang.org/t/i-think-i-must-not-be-understanding-how-overloads-are-resolved-in-class-methods/6316/3 "2024-01-14T00:19:55Z")

</div>

I tried to create a minimal example… but it successfully resolved the overload without error. Let me see what else I can do. It’s not large, or private, but it is multiple files.
