Skip to content
This repository

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

Closed
consiliens opened this Issue August 25, 2011 · 5 comments

3 participants

consiliens Nick Howard Roger Pack
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

Nick Howard
Collaborator

@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)?

Roger Pack
Collaborator
rdp commented August 31, 2011

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

Nick Howard
Collaborator

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.

Nick Howard
Collaborator

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.

Nick Howard baroquebobcat closed this August 04, 2013
Nick Howard
Collaborator

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.

Nick Howard baroquebobcat referenced this issue from a commit August 04, 2013
Nick Howard add tests to nail down super behavior
Mirah's super acts like Ruby's--which has some quirks. #128
accd0ea
Nick Howard baroquebobcat referenced this issue from a commit August 04, 2013
Nick Howard 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
Something went wrong with that request. Please try again.