Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strange behaviour for abstract macro called on a class #289

Open
uujava opened this issue Mar 23, 2015 · 1 comment
Open

strange behaviour for abstract macro called on a class #289

uujava opened this issue Mar 23, 2015 · 1 comment

Comments

@uujava
Copy link
Contributor

uujava commented Mar 23, 2015

I have the following setup (abstract_class.mirah):

interface ICall
   def call():void;end
end   

abstract class ACall implements ICall    
end

Compiling it via mirahc gives proper abstract ACall class.

When I'm passing block closure when calling method accepting abstract class to implement AClass (call_abstract.mirah):

class TestACall
    def self.accept(v:ACall):void        
        v.call(1)
    end

    def self.main(args:String[]):void              
        accept do 
            puts "I'm in the closure"
        end
    end
end

Compiling it incrementally after ACall already compiled and in the classpath is working OK.

The issue raises when I'm compiling both files alltogether via mirahc - I'm getting
the following error:

ERROR: Can't find method TestACall.accept(org.mirah.jvm.mirrors.BlockType)
        accept do |v|
               ^^^^^^
1 errors

I've spend some time investigating it. For me it' looks like there are two instances of the ClassDefinition nodes in the type system (stored in the futures hash). One having 'abstract' macro applied to ast node and another does not have proper annotation. This for some reason prevents returning true in MethodLookup.isJvmSubType when checking isAbstract:

if subtype.isBlock
        return true if JVMTypeUtils.isInterface(supertype)
        return true if JVMTypeUtils.isAbstract(supertype)
      end

For now I have a workaround to split my abstract classes into different compilation unit.

But still the question is it possible to mend?

@baroquebobcat
Copy link
Member

I think we could fix it, but it might be a little tricky. That's definitely
a bug though.

On Mon, Mar 23, 2015 at 8:01 AM, uujava notifications@github.com wrote:

I have the following setup (abstract_class.mirah):

interface ICall
def call():void;endend

abstract class ACall implements ICall end

Compiling it via mirahc gives proper abstract ACall class.

When I'm passing block closure when calling method accepting abstract
class to implement AClass (call_abstract.mirah):

class TestACall
def self.accept(v:ACall):void
v.call(1)
end

def self.main(args:String[]):void
    accept do
        puts "I'm in the closure"
    end
endend

Compiling it incrementally after ACall already compiled and in the
classpath is working OK.

The issue raises when I'm compiling both files alltogether via mirahc -
I'm getting
the following error:

ERROR: Can't find method TestACall.accept(org.mirah.jvm.mirrors.BlockType)
accept do |v|
^^^^^^
1 errors

I've spend some time investigating it. For me it' looks like there are two
instances of the ClassDefinition nodes in the type system (stored in the
futures hash). One having 'abstract' macro applied to ast node and another
does not have proper annotation. This for some reason prevents returning
true in MethodLookup.isJvmSubType when checking isAbstract:

if subtype.isBlock
return true if JVMTypeUtils.isInterface(supertype)
return true if JVMTypeUtils.isAbstract(supertype)
end

For now I have a workaround to split my abstract classes into different
compilation unit.

But still the question is it possible to mend?


Reply to this email directly or view it on GitHub
#289.

-Nick Howard
http://blog.baroquebobcat.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants