[java] Warning : No overload found for this constructor call #2679

Closed
singpolyma opened this Issue Feb 27, 2014 · 7 comments

Projects

None yet

7 participants

@singpolyma

What does this warning mean? It seems to be because I'm extending a Java class and adding a constructor with more arguments -- but it works fine? What's the "right thing" to do so this warning goes away? My code works fine, but I'd rather not have warnings for users of my library :)

@waneck
Haxe Foundation member
@singpolyma

Here's a simplified version of the example that still produces this warning:

package com.example.myfirstapp;

import android.view.MotionEvent;
import android.view.GestureDetector;

class SomeClass extends GestureDetector_SimpleOnGestureListener {
   var fun = null;

   function new(f) {
      super();
      fun = f;
   }

   @:overload function onSingleTapConfirmed(e:MotionEvent) {
      return true;
   }
}
@ncannasse ncannasse added this to the 3.2 milestone Mar 4, 2014
@waneck waneck was assigned by andyli Mar 14, 2014
@jdonaldson
Haxe Foundation member

I'm seeing this in java and the c# target.

@Justinfront
@jdonaldson
Haxe Foundation member

I wish this were easy to repro. Try to include this in a java/cs project, it's the shortest error example I could come up with:

class Runner {
    public var onPrecheck(default, null) : Dispatcher<TestHandler<TestFixture<Dynamic>>>;

    function runFixture(fixture : TestFixture<Dynamic>) {
        var handler = new TestHandler(fixture);
        handler.onPrecheck.add(function(x){
            this.onPrecheck.dispatch(x);
        });
    }

}

class Dispatcher<T> {

    private var handlers : Array<T -> Void>;

    public function add(h : T -> Void) : T -> Void {
        return h;
    }

    public function new(){}


    public function dispatch(e) {
        try {
            // prevents problems with self removing events
            var list = handlers.copy();
            for( l in list )
                l(e);
            return true;
        } catch( exc : Dynamic ) {
            return false;
        }
    }

}

class TestHandler<T> {
    public var onPrecheck(default, null) : Dispatcher<TestHandler<T>>;


    public function new(fixture : TestFixture<T>) {
    }

}

class TestFixture<T> {
}
@Atry

Even the Haxe standard library may cause this warning:

$ haxe haxe.ds.WeakMap -java out -dce no -D no-compilation
D:\HaxeToolkit\haxe\std/java/_std/haxe/ds/WeakMap.hx:525: lines 525-540 : Warning : No overload found for this constructor call
@waneck
Haxe Foundation member

2b9fb23 should handle these cases. Feel free to reopen if you still see it

@waneck waneck closed this Mar 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment