Wiki
Show
Ignore:
Timestamp:
03/10/10 06:47:00 (2 years ago)
Author:
Chuck.Esterbrook
Message:

Fixed: The compiler does not find valid extension methods in some circumstances.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/Boxes.cobra

    r2299 r2305  
    835835        Returns true if this type is a construction of the given generic type def, even going more than level deep through `genericDef`. 
    836836        """ 
     837        # TODO: can this implementation be replaced by: 
     838        # return .constructedTypeOf(box) is not nil 
    837839        if .genericDef is nil 
    838840            return false 
     
    17641766                    if box.isDescendantOf(cto) and .declForName(name) 
    17651767                        return .constructedTypeFor(cto.genericParams).declForName(name) 
     1768            else if .isGeneric 
     1769                # Example: 
     1770                # this == Extension of IEnumerable<of T> 
     1771                # box == X implements IEnumerable<of int> 
     1772                # name == 'toList' 
     1773                # The IEnumerable<of T> has .genericDef IEnumerable<> 
     1774                # The X's IEnumerable<of int> has .genericDef IEnumerable<> 
     1775                # Note that X and the Extension are not directly connected. 
     1776                # Only by tracing up to the generic def IEnumerable<> do they "connect". 
     1777                # see cobra/Tests/420-extensions/400-extend-generics/220-extend-ancestor-interface.cobra 
     1778                constructed = box.constructedTypeOf(_extendedBox.genericDef to !) 
     1779                if constructed, return .extensionMemberFor(constructed, name) 
    17661780        return nil 
    1767              
     1781 
    17681782    def memberForName(name as String) as IMember? 
    17691783        result = base.memberForName(name) 
    1770         if result is nil 
    1771             result = .extendedBox.memberForName(name) 
     1784        if result is nil, result = .extendedBox.memberForName(name) 
    17721785        return result 
    17731786