Issue 79: Mirah::InternalCompilerError: No constructor #128

Closed
consiliens opened this Issue Aug 26, 2011 · 5 comments

Projects

None yet

3 participants

@consiliens

"
Reported by rogerpack2005, Jun 3, 2011
this java:

import java.util.ArrayList; 
class yo extends ArrayList { 
   yo(java.util.List o) { 
    super(); 
   } 
} 

compiles, but this mirah:

import java.util.ArrayList 
class A < ArrayList 
   def initialize(o:java.util.List) 
    super 
   end 
end 

does not:
...
Mirah::InternalCompilerError: No constructor
java.util.ArrayList(Type(java.util.List))

ref: http://groups.google.com/group/mirah/browse_thread/thread/dfd77751fc0902c5
"

http://code.google.com/p/mirah/issues/detail?id=79

@baroquebobcat
Member

@rdp, what would you expect super to do in

import java.util.ArrayList 
class A < ArrayList 
   def initialize(o:java.util.List) 
    super 
   end 
end 

call ArrayList()?

Also, if it were

import java.util.ArrayList 
class A < ArrayList 
   def initialize(o:java.util.List) 
    super o 
   end 
end 

Would that call ArrayList(Collection c)?

@rdp
Collaborator
rdp commented Aug 31, 2011

I think so, isn't that what it does in java?

@baroquebobcat
Member

I get NameError: No constructor java.util.ArrayList(#<Type java.util.List>) with master. Also, it appears that fully qualified param typing is a syntax error right now.

The basic problem is that somewhere we are not widening the argument to super.

@baroquebobcat
Member

This is using Ruby semantics for initialization super delegation. In Ruby,

  def initialize x
    super
   end

means call super with my args. You have to change how you use super to make it more specific

You can have the behavior you expect by doing

  def initialize o: List
    super()
   end

You could also do

  def initialize o: List
    super o.size
   end

Also, it appears that fully qualified param typing is a syntax error right now.

Yeah, I'm not entirely sure why that is. Maybe something changed to require double colons instead of periods as a package separator.

@baroquebobcat
Member

I'm closing this. After reading more of the implementation this looks like intended behavior. I've added some more tests to better specify it.

@baroquebobcat baroquebobcat added a commit that referenced this issue Aug 4, 2013
@baroquebobcat baroquebobcat add tests to nail down super behavior
Mirah's super acts like Ruby's--which has some quirks. #128
accd0ea
@baroquebobcat baroquebobcat added a commit that referenced this issue Aug 28, 2013
@baroquebobcat baroquebobcat add tests to nail down super behavior
Mirah's super acts like Ruby's--which has some quirks. #128
97d46fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment