gpicron / google-gin

Automatically exported from code.google.com/p/google-gin
Apache License 2.0
1 stars 1 forks source link

Should have GIN error rather than gwt compiler error in package-private+generics corner case #188

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This is the specific example that bit us.  There may be a more general case to 
be found.

The visibility modifiers (or lack thereof) on A and B are important.

---

package x;

public class A<T> {
  A() {}
}

---

package y;

class B {}

---

package y;

class C {
  C(A<B> someParam) {}
}

---

The above code will yield a GWT compiler error on the ginjector fragment for 
package y saying that A's constructor isn't visible.  This is a bit confusing 
since generally you can inject another package's public object that only has a 
package private constructor.  If you look at the generated fragment for package 
y, you'll see that it tries to call A's constructor.

If you make B a public class things compile fine.  Presumably gin puts the 
construction of A<B> in package x's fragment.

In this case it would be helpful for gin to report that it's impossible for it 
to create a ginjector rather than generating uncompilable code.

Original issue reported on code.google.com by boppenh...@google.com on 2 May 2013 at 2:34

GoogleCodeExporter commented 9 years ago
I should add, we also saw this in a place where we were taking A.Factory<B>.  
Not sure if the generated factories are a completely different code path or not.

Original comment by boppenh...@google.com on 2 May 2013 at 3:05