Re: [gwt-contrib] GWT compiler optimization breaks some lambdas

2015-10-26 Thread Ignacio Baca Moreno-Torres
Bootstrap using lambda (fail)

// java
return service.get().getBootstrap().bootstrap().doOnNext(data -> {
Account account = data.getAccount();
if (account == null) auth.get().resetSessionData(false);
else auth.get().setSessionData(account, data.getKeychain());
theme.get().setCustomization(data.getCustomization());
analytics.get().init(data.getAnalyticsUserAccount() + ":" + data.
getAnalyticsDomainName());
OsmQueryResolver.configureServer(data.getReverseGeocodingUrl());
final String user = account == null ? "anonymous" : account.getEmail();
log.fine("Bootstrap data loaded successfully (user=" + user + ")");
});
// javascript + pretty
function $lambda$5(this$static) {
var lastArg;
null .$_nullMethod();
$resetSessionData(castTo(this$static.auth.get_1(), 400), false);
$setCustomization((lastArg = castTo(this$static.theme.get_1(), 1067),
null .$_nullMethod(),
lastArg));
castTo(this$static.analytics.get_1(), 6137).init_2(null .$_nullMethod() 
+ ':' + null .$_nullMethod());
configureServer(null .$_nullMethod());
$fine_0(log_3, 'Bootstrap data loaded successfully (user=anonymous)');
}


ProcessResponse using anonymous class (success).

// java
tracker.add(heads.subscribe(new Action1() {
@Override public void call(SubscriptionResponse response) {
ClientTelemetryStore.this.processResponse(response);
}
}));
// Javascript
defineClass(2064, 1, {}, ClientTelemetryStore$1);
_.call_0 = function call_145(response) {
$call_3(this, castToAllowJso(response, 6180));
};
function $call_3(this$static, response) {
$processResponse(this$static.this$01, response);
}
function $processResponse(this$static, response) {
var newUnits, xs, xs$iterator, xs$iterator0;
requireNonNull_0(response, 'response required');
requireNonNull_0(response.uuid, 'response.uuid required’);


ProcessResponse using lambda (fail).

// Java
tracker.add(heads.subscribe(response -> { ClientTelemetryStore.this.
processResponse(response); }));
// Javascript
defineClass(2063, 1, {}, ClientTelemetryStore$lambda$3$Type);
_.call_0 = function call_153(arg0) {
$processResponse(this.$$outer_0, throwClassCastExceptionUnlessNull(arg0)
);
};
function $processResponse(this$static, response) {
var newUnits, xs, xs$iterator, xs$iterator0;
requireNonNull_0(response, 'response required');
requireNonNull_0(null .$_nullMethod(), 'response.uuid required');

I did not use pretty style because I thought that this flag produces 
different result, I tested now and looks like the output is the same, but, 
I'm pretty sure that some flags changes this issues, optimize is obvious 
that fixes the problem, but I think that namespace=package also changes the 
result.

I know that this was easier if we have a sample project, but I can't 
reproduce! :( You can try, the ResourceRegistry case is plain java + guava. 
But when you copy to a clean project, the bug disappear.
this.store = Suppliers.memoize(() -> from(resources.get()).uniqueIndex(
ResourceDescriptor::getType));
Resource descriptor is an interface with only one implementation where type 
is a Class type field, a getType return this field. Anyway, I'm still 
trying to reproduce in a small project.

On Monday, October 26, 2015 at 5:26:33 PM UTC+1, Roberto Lublinerman wrote:
>
> Also could you try the equivalent lamda that is not a method reference, i.e
>
>   (parameters) -> this.processResponse(params);
>
> I looked at the way we construct the innerclasses corresponding to lambdas 
> and it looks ok.
>
> It would really help if you could narrow it down to a small reprocase that 
> I can run.
>
> On Sun, Oct 25, 2015 at 5:23 AM, Ignacio Baca Moreno-Torres <
> ign...@bacamt.com > wrote:
>
> function ILe(a) { 
>   var b; 
>   b = Erb(PDl(a.a, 'REFXXX store'), 164); 
>   Erb(PDl(Erb(b.De(), 82), 'REFXXX store.get()'), 82); 
>   return Erb(PDl(undefined, 'REFXXX store.get().values()'), 6) 
> }
>
> This was the actual b.De() function.
> u9c(701, 1, { 164: 1, 701: 1, 3: 1 }, Uh);
> _.De = function Vh() {
> var a;
> if (!this.b) {
> if (!this.b) {
> a = this.a.De();
> this.c = a;
> this.b = true;
> return a
> }
> }
> return this.c
> };
> _.Bd = function Wh() { return 'Suppliers.memoize(' + this.a + ')' };
> _.b = false;
> var ltb = epl(tbm, 'Suppliers/MemoizingSupplier', 701);
>
> And the highlighted this.a.De() call the Supplier.get(). (this return 
> a,b,c; is pretty obscure!, equivalent to a;b;return c;)
> _.De = function RLe() {
> var a, b, c;
> return a = Erb(iEl(this.a, 'REF003 resources'), 38),
>   b = Erb(iEl(Erb(a.De(), 62), 'REF004 resources.get()'), 62),
>   c = Vu(new $u(b,b), new TLe),
>   Erb(iEl(c, 'REF001'), 82)
> }
>
>
> On Sunday, October 25, 2015 at 12:18:01 PM UTC+1, Ignacio Baca 
> Moreno-Torres wrote:
>
> Sorry, this is pretty confusing, just comment that the lamba cases 
> described previously still (in 

Re: [gwt-contrib] GWT compiler optimization breaks some lambdas

2015-10-26 Thread Ignacio Baca Moreno-Torres
I said that optimize=0 fix errors, but I just compiled the project a get 
the same bootstrap+lamba error. But with draftCompile the result looks ok.
// bootstrap case, lambda, pretty, draftCompile
_.lambda$5 = function lambda$5(data_0){ 
  $clinit_ApplicationBootstrapper(); 
  var account, user; 
  { 
account = getAccount__Lshared_user_Account___devirtual$(data_0); 
if (isNull_2(account)) 
  castTo(this.auth.get_1(), 242).resetSessionData(false); 
else  
  castTo(this.auth.get_1(), 242).setSessionData(account,
getKeychain__LKeychain___devirtual$(data_0)); 

castTo(this.theme.get_1(), 951).setCustomization(
getCustomization__LCustomization___devirtual$(data_0)); 
castTo(this.analytics.get_1(),7570).init_13(
getAnalyticsUserAccount__Ljava_lang_String___devirtual$(data_0) + 
':' + 
getAnalyticsDomainName__Ljava_lang_String___devirtual$(data_0)); 
configureServer(getReverseGeocodingUrl__Ljava_lang_String___devirtual$(
data_0)); 
user = isNull_2(account)?'anonymous':
getEmail__Ljava_lang_String___devirtual$(account); 
log_10.fine('Bootstrap data loaded successfully (user=' + user + ')'); 
  } 
}; 
defineClass(1672, 1, {1:1}, ApplicationBootstrapper$lambda$5$Type); 
_.call_0 = function call_3(arg0){ 
  this.$$outer_0.lambda$5(arg0);  
}; 
var Lclient_ApplicationBootstrapper$lambda$5$Type_2_classLit = 
createForClass('client', 'ApplicationBootstrapper/lambda$5$Type', 1672, 
Ljava_lang_Object_2_classLit);



On Monday, October 26, 2015 at 8:27:41 PM UTC+1, Ignacio Baca Moreno-Torres 
wrote:
>
> Bootstrap using lambda (fail)
>
> // java
> return service.get().getBootstrap().bootstrap().doOnNext(data -> {
> Account account = data.getAccount();
> if (account == null) auth.get().resetSessionData(false);
> else auth.get().setSessionData(account, data.getKeychain());
> theme.get().setCustomization(data.getCustomization());
> analytics.get().init(data.getAnalyticsUserAccount() + ":" + data.
> getAnalyticsDomainName());
> OsmQueryResolver.configureServer(data.getReverseGeocodingUrl());
> final String user = account == null ? "anonymous" : account.getEmail
> ();
> log.fine("Bootstrap data loaded successfully (user=" + user + ")");
> });
> // javascript + pretty
> function $lambda$5(this$static) {
> var lastArg;
> null .$_nullMethod();
> $resetSessionData(castTo(this$static.auth.get_1(), 400), false);
> $setCustomization((lastArg = castTo(this$static.theme.get_1(), 1067),
> null .$_nullMethod(),
> lastArg));
> castTo(this$static.analytics.get_1(), 6137).init_2(null .$_nullMethod
> () + ':' + null .$_nullMethod());
> configureServer(null .$_nullMethod());
> $fine_0(log_3, 'Bootstrap data loaded successfully (user=anonymous)');
> }
>
>
> ProcessResponse using anonymous class (success).
>
> // java
> tracker.add(heads.subscribe(new Action1() {
> @Override public void call(SubscriptionResponse response) {
> ClientTelemetryStore.this.processResponse(response);
> }
> }));
> // Javascript
> defineClass(2064, 1, {}, ClientTelemetryStore$1);
> _.call_0 = function call_145(response) {
> $call_3(this, castToAllowJso(response, 6180));
> };
> function $call_3(this$static, response) {
> $processResponse(this$static.this$01, response);
> }
> function $processResponse(this$static, response) {
> var newUnits, xs, xs$iterator, xs$iterator0;
> requireNonNull_0(response, 'response required');
> requireNonNull_0(response.uuid, 'response.uuid required’);
>
>
> ProcessResponse using lambda (fail).
>
> // Java
> tracker.add(heads.subscribe(response -> { ClientTelemetryStore.this.
> processResponse(response); }));
> // Javascript
> defineClass(2063, 1, {}, ClientTelemetryStore$lambda$3$Type);
> _.call_0 = function call_153(arg0) {
> $processResponse(this.$$outer_0, throwClassCastExceptionUnlessNull(
> arg0));
> };
> function $processResponse(this$static, response) {
> var newUnits, xs, xs$iterator, xs$iterator0;
> requireNonNull_0(response, 'response required');
> requireNonNull_0(null .$_nullMethod(), 'response.uuid required');
>
> I did not use pretty style because I thought that this flag produces 
> different result, I tested now and looks like the output is the same, but, 
> I'm pretty sure that some flags changes this issues, optimize is obvious 
> that fixes the problem, but I think that namespace=package also changes the 
> result.
>
> I know that this was easier if we have a sample project, but I can't 
> reproduce! :( You can try, the ResourceRegistry case is plain java + guava. 
> But when you copy to a clean project, the bug disappear.
> this.store = Suppliers.memoize(() -> from(resources.get()).uniqueIndex(
> ResourceDescriptor::getType));
> Resource descriptor is an interface with only one implementation where 
> type is a Class type field, a getType return this field. Anyway, I'm 
> still trying to reproduce in a small project.
>
> On Monday, October 26, 2015 

Re: [gwt-contrib] GWT compiler optimization breaks some lambdas

2015-10-26 Thread 'Ray Cromwell' via GWT Contributors
It looks to me like it might be a type inferencing issue Roberto. Remember,
the lambda is matched to a SAM interface method. When it synthesizes the
implementation, it takes info from JDT about the 'expected type' which is
inferred by JDT. I wonder if the type inferred messes up type tightener
somehow. Here's something to try, put your lambda into a local var;

e.g.

Function foo = {data -> data.getAccount() etc}
service.get().getBootstrap().bootstrap().doOnNext(foo)

That way you force the param types to what you know they are.

I suppose another thing to try is to declare a type

service.get().getBootstrap().bootstrap().doOnNext(Data data -> .)

What I'm suspecting is that the compiler is seeing a different type for the
parameter somehow and inferring it is never instantiated.



On Mon, Oct 26, 2015 at 12:57 PM, Ignacio Baca Moreno-Torres <
igna...@bacamt.com> wrote:

> I said that optimize=0 fix errors, but I just compiled the project a get
> the same bootstrap+lamba error. But with draftCompile the result looks ok.
> // bootstrap case, lambda, pretty, draftCompile
> _.lambda$5 = function lambda$5(data_0){
>   $clinit_ApplicationBootstrapper();
>   var account, user;
>   {
> account = getAccount__Lshared_user_Account___devirtual$(data_0);
> if (isNull_2(account))
>   castTo(this.auth.get_1(), 242).resetSessionData(false);
> else
>   castTo(this.auth.get_1(), 242).setSessionData(account,
> getKeychain__LKeychain___devirtual$(data_0));
>
> castTo(this.theme.get_1(), 951).setCustomization(
> getCustomization__LCustomization___devirtual$(data_0));
> castTo(this.analytics.get_1(),7570).init_13(
> getAnalyticsUserAccount__Ljava_lang_String___devirtual$(data_0) +
> ':' +
> getAnalyticsDomainName__Ljava_lang_String___devirtual$(data_0));
> configureServer(getReverseGeocodingUrl__Ljava_lang_String___devirtual$
> (data_0));
> user = isNull_2(account)?'anonymous':
> getEmail__Ljava_lang_String___devirtual$(account);
> log_10.fine('Bootstrap data loaded successfully (user=' + user + ')');
>   }
> };
> defineClass(1672, 1, {1:1}, ApplicationBootstrapper$lambda$5$Type);
> _.call_0 = function call_3(arg0){
>   this.$$outer_0.lambda$5(arg0);
> };
> var Lclient_ApplicationBootstrapper$lambda$5$Type_2_classLit =
> createForClass('client', 'ApplicationBootstrapper/lambda$5$Type', 1672,
> Ljava_lang_Object_2_classLit);
>
>
>
> On Monday, October 26, 2015 at 8:27:41 PM UTC+1, Ignacio Baca
> Moreno-Torres wrote:
>
>> Bootstrap using lambda (fail)
>>
>> // java
>> return service.get().getBootstrap().bootstrap().doOnNext(data -> {
>> Account account = data.getAccount();
>> if (account == null) auth.get().resetSessionData(false);
>> else auth.get().setSessionData(account, data.getKeychain());
>> theme.get().setCustomization(data.getCustomization());
>> analytics.get().init(data.getAnalyticsUserAccount() + ":" + data.
>> getAnalyticsDomainName());
>> OsmQueryResolver.configureServer(data.getReverseGeocodingUrl());
>> final String user = account == null ? "anonymous" : account.getEmail
>> ();
>> log.fine("Bootstrap data loaded successfully (user=" + user + ")");
>> });
>> // javascript + pretty
>> function $lambda$5(this$static) {
>> var lastArg;
>> null .$_nullMethod();
>> $resetSessionData(castTo(this$static.auth.get_1(), 400), false);
>> $setCustomization((lastArg = castTo(this$static.theme.get_1(), 1067),
>> null .$_nullMethod(),
>> lastArg));
>> castTo(this$static.analytics.get_1(), 6137).init_2(null .$_nullMethod
>> () + ':' + null .$_nullMethod());
>> configureServer(null .$_nullMethod());
>> $fine_0(log_3, 'Bootstrap data loaded successfully (user=anonymous)'
>> );
>> }
>>
>>
>> ProcessResponse using anonymous class (success).
>>
>> // java
>> tracker.add(heads.subscribe(new Action1() {
>> @Override public void call(SubscriptionResponse response) {
>> ClientTelemetryStore.this.processResponse(response);
>> }
>> }));
>> // Javascript
>> defineClass(2064, 1, {}, ClientTelemetryStore$1);
>> _.call_0 = function call_145(response) {
>> $call_3(this, castToAllowJso(response, 6180));
>> };
>> function $call_3(this$static, response) {
>> $processResponse(this$static.this$01, response);
>> }
>> function $processResponse(this$static, response) {
>> var newUnits, xs, xs$iterator, xs$iterator0;
>> requireNonNull_0(response, 'response required');
>> requireNonNull_0(response.uuid, 'response.uuid required’);
>>
>>
>> ProcessResponse using lambda (fail).
>>
>> // Java
>> tracker.add(heads.subscribe(response -> { ClientTelemetryStore.this.
>> processResponse(response); }));
>> // Javascript
>> defineClass(2063, 1, {}, ClientTelemetryStore$lambda$3$Type);
>> _.call_0 = function call_153(arg0) {
>> $processResponse(this.$$outer_0, throwClassCastExceptionUnlessNull(
>> arg0));
>> };
>> function $processResponse(this$static, response) {
>> var newUnits, xs, 

Re: [gwt-contrib] GWT compiler optimization breaks some lambdas

2015-10-26 Thread 'Roberto Lublinerman' via GWT Contributors
>
> I did not use pretty style because I thought that this flag produces
> different result, I tested now and looks like the output is the same, but,
> I'm pretty sure that some flags changes this issues, optimize is obvious
> that fixes the problem, but I think that namespace=package also changes the
> result.
>

In a nutshell there are optimizations on the Java AST and those are not
affected at all by -style or -Xnamespace. Optimizations that are related to
types, instantiability, devirtualization, etc, are done in the Java AST.

Some optimizations in that JavaScriptAST might be affected by -style (like
DuplicateFunctionRemoval) but those I think they are mostly off. I don't
think -Xnamespace has any impact on optimizations.

That said, if you are using JsInterop, and you have a type that is never
new'ed in Java, the compiler infers that is not instantiable and assumes it
is always null and optimizes accordingly. Types originating from JavaScript
need to be marked as JsType so that the compiler is aware and does not
assume they are null.

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAC7T7gmdNkvotuVz_2W6ht79ZRH-DB3ohE%3DMGvxLwRyWAxMDwg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gwt-contrib] GWT compiler optimization breaks some lambdas

2015-10-26 Thread 'Roberto Lublinerman' via GWT Contributors
It would be really helpful if you could isolate your problem to a small
example.

On Mon, Oct 26, 2015 at 2:39 PM, Roberto Lublinerman 
wrote:

> I did not use pretty style because I thought that this flag produces
>> different result, I tested now and looks like the output is the same, but,
>> I'm pretty sure that some flags changes this issues, optimize is obvious
>> that fixes the problem, but I think that namespace=package also changes the
>> result.
>>
>
> In a nutshell there are optimizations on the Java AST and those are not
> affected at all by -style or -Xnamespace. Optimizations that are related to
> types, instantiability, devirtualization, etc, are done in the Java AST.
>
> Some optimizations in that JavaScriptAST might be affected by -style (like
> DuplicateFunctionRemoval) but those I think they are mostly off. I don't
> think -Xnamespace has any impact on optimizations.
>
> That said, if you are using JsInterop, and you have a type that is never
> new'ed in Java, the compiler infers that is not instantiable and assumes it
> is always null and optimizes accordingly. Types originating from JavaScript
> need to be marked as JsType so that the compiler is aware and does not
> assume they are null.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAC7T7g%3DO7iy7S5Sha3ZsATY-aFeckFwFH9mOuJBGMOerPqMvsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gwt-contrib] Gerrit -> Github issue linking

2015-10-26 Thread 'Roberto Lublinerman' via GWT Contributors
Use Bug-link, see https://gwt-review.googlesource.com/#/c/13710/

On Sun, Oct 25, 2015 at 5:25 AM, Jens  wrote:

> Hi,
>
> In Gerrit "Bug: issue " points to Google Code. Do we already have an
> alternative wording for cross linking to Github? Something like "Bug:
> #" maybe?
>
> -- J.
>
> --
> You received this message because you are subscribed to the Google Groups
> "GWT Contributors" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-web-toolkit-contributors/2a50252d-fd29-44cd-9538-45a9e7d91532%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAC7T7gk%2BkBkH7_RDdDOdfwQSz9_E8or2foy-r9NrmrwzwqdwVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.