Boo

compiler error when attaching to an event on a locally defined generic or on a generic using a locally defined type parameter

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.7.8, 0.7.9, 0.8, 0.8.1
  • Fix Version/s: 0.8.2
  • Component/s: Compiler
  • Labels:
    None
  • Environment:
    Windows XP
    MS .Net 2.0
  • Number of attachments :
    1

Description

import System
import System.ComponentModel

class GenericFoo[of T]:
public event PropertyChanged as PropertyChangedEventHandler
def NotifyPropertyChanged(sender as object, e as
PropertyChangedEventArgs):
PropertyChanged(sender, e)

class AClass:
pass

class MyClass:
private _foo = GenericFoo[of AClass]()
def constructor():
_foo.PropertyChanged += PropertyChanged
def PropertyChanged(sender as object, e as PropertyChangedEventArgs):
pass

The compiler error...

Entering Boo.Lang.Compiler.Steps.InjectCallableConversions
MyClass.boo(19,9): Internal compiler error on node
'self._foo.add_PropertyChanged(self.PropertyChanged)':
System.NullReferenceException: Object reference not set to an instance
of an object.
at
Boo.Lang.Compiler.Steps.InjectCallableConversions.CreateDelegate(IType
type, Expression source)
at
Boo.Lang.Compiler.Steps.InjectCallableConversions.Convert(IType
expectedType, Expression argument)
at
Boo.Lang.Compiler.Steps.InjectCallableConversions.ConvertMethodInvocation(MethodInvocationExpression
node, IParameter[] parameters)
at
Boo.Lang.Compiler.Steps.InjectCallableConversions.LeaveMethodInvocationExpression(MethodInvocationExpression
node)
at
Boo.Lang.Compiler.Ast.DepthFirstVisitor.OnMethodInvocationExpression(MethodInvocationExpression
node)
at
Boo.Lang.Compiler.Ast.MethodInvocationExpression.Accept(IAstVisitor
visitor)
at Boo.Lang.Compiler.Ast.DepthFirstVisitor.Visit(Node
node)
Leaving Boo.Lang.Compiler.Steps.InjectCallableConversions

This error does not occur when GenericFoo[of T] and AClass are defined
in a separate assembly. Nor does it occur when GenericFoo[of T] is
defined in a separate assembly and a built in type is used for T.

Activity

Hide
Spruce Weber added a comment -

This patch fixes the issue by adding a method, GenericMapping.EntityNeedsMapping(), and calling that method before attempting to map an ICallableType. I will upload another patch to BOO-977 as an alternative to the previous one I added so that GenericConstructedType makes use of GenericMapping.EntityNeedsMapping() instead of implementing its own. A more complete test case follows...

callable MyEvent(sender as object, e as EventArgs)

class GenericFoo[of T]:
event AnExternalEvent as EventHandler
event AnInternalEvent as MyEvent

def TestEvents():
AnExternalEvent(self, EventArgs())
AnInternalEvent(self, EventArgs())

def OnExternalEvent(sender as object, e as EventArgs):
print "OnExternalEvent"

def OnInternalEvent(sender as object, e as EventArgs):
print "OnInternalEvent"

foo = GenericFoo[of string]()
foo.AnExternalEvent += OnExternalEvent
foo.AnInternalEvent += OnInternalEvent
foo.TestEvents()

Show
Spruce Weber added a comment - This patch fixes the issue by adding a method, GenericMapping.EntityNeedsMapping(), and calling that method before attempting to map an ICallableType. I will upload another patch to BOO-977 as an alternative to the previous one I added so that GenericConstructedType makes use of GenericMapping.EntityNeedsMapping() instead of implementing its own. A more complete test case follows... callable MyEvent(sender as object, e as EventArgs) class GenericFoo[of T]: event AnExternalEvent as EventHandler event AnInternalEvent as MyEvent def TestEvents(): AnExternalEvent(self, EventArgs()) AnInternalEvent(self, EventArgs()) def OnExternalEvent(sender as object, e as EventArgs): print "OnExternalEvent" def OnInternalEvent(sender as object, e as EventArgs): print "OnInternalEvent" foo = GenericFoo[of string]() foo.AnExternalEvent += OnExternalEvent foo.AnInternalEvent += OnInternalEvent foo.TestEvents()
Hide
Marcus Griep added a comment -

Committed revision

Show
Marcus Griep added a comment - Committed revision

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: