Changeset 1733

Show
Ignore:
Timestamp:
11/05/08 12:12:45 (2 months ago)
Author:
Chuck.Esterbrook
Message:

Fixed: Nilable delegates cannot be called (foo(arg1, arg2)).

Location:
cobra/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Developer/IntermediateReleaseNotes.text

    r1732 r1733  
    203203 
    204204* Fixed: Cannot add a doc string for a `sig` declaration. 
     205 
     206* Fixed: Nilable delegates cannot be called (`foo(arg1, arg2)`). 
  • cobra/trunk/Source/Expr.cobra

    r1731 r1733  
    14971497                if _type is nil 
    14981498                        assert expr.type is not nil 
    1499                         if expr.type inherits MethodSig  # TODO: probably still need to handle case of a method sig coming from a DLL 
    1500                                 _type = (expr.type to MethodSig).returnType 
     1499                        exprType = expr.type 
     1500                        if exprType inherits NilableType 
     1501                                exprType = exprType.theWrappedType 
     1502                        if exprType inherits MethodSig  # TODO: probably still need to handle case of a method sig coming from a DLL 
     1503                                _type = exprType.returnType 
    15011504                        else if expr.receiverType and expr.receiverType.isSystemTypeClass 
    15021505                                _type = .compiler.dynamicType 
    1503                         else if expr.type inherits Box 
     1506                        else if exprType inherits Box 
    15041507                                _type = expr.receiverType  # for example, an IdentifierExpr of 'SomeClass' has a .receiverType of that class 
    1505                         else if expr.type.isDynamic 
     1508                        else if exprType.isDynamic 
    15061509                                _type = .compiler.nilableDynamicType 
    15071510                        else 
  • cobra/trunk/Source/SharpGenerator.cobra

    r1730 r1733  
    33483348                                        .writeSharpArgs(sw) 
    33493349                                        sw.write(')') 
    3350                                 else if expr.type inherits MethodSig 
     3350                                else if expr.type inherits MethodSig or (expr.type inherits NilableType and (expr.type to NilableType).theWrappedType inherits MethodSig) 
    33513351                                        isMethodSig = true 
    33523352                                else if expr.type.isSystemTypeClass or _type.isDynamic 
  • cobra/trunk/Tests/220-delegates-etc/100-delegates/110-declare-sig.cobra

    r1732 r1733  
    3131 
    3232        def eval1 as int 
     33                # use the var with .invoke 
    3334                if _op 
    3435                        return _op.invoke(_a, _b) 
     
    3738 
    3839        def eval2 as int 
     40                # use the var with direct call 
    3941                if _op 
    4042                        return _op(_a, _b) 
     43                else 
     44                        return 0 
     45 
     46        def eval3 as int 
     47                # use a property with invoke 
     48                # also testing nilable delegate 
     49                if .op 
     50                        op = .op 
     51                        return op.invoke(_a, _b) 
     52                else 
     53                        return 0 
     54 
     55        def eval4 as int 
     56                # use a property with direct call 
     57                # also testing nilable delegate 
     58                if .op 
     59                        op = .op 
     60                        return op(_a, _b) 
    4161                else 
    4262                        return 0