-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove invalid reference to
this
as an enclosing instance for anony…
…mous classes in parameters to super/this construtor calls. Anonymous classes are considered to capture their enclosing instance except when declared in a static method. In constructors those classes capture the enclosing instance unless they appear as a parameter to a super/this constructor call. Since the type model object is constructed independent from the code, anonymous classes that are declared in a parameter to a super/this constructor call are considered as capturing the enclosing instance. This cl works around the problem by changing the way implicit qualifiers are computed, and in this cases the anonymous class will receive a null enclosing instance instead of a this reference. Such value will never be referenced since both Java and Kotlin forbid referencing `this` impliclitly or explicitly in these situation. PiperOrigin-RevId: 600956219
- Loading branch information
1 parent
6e38485
commit ff9f7b4
Showing
17 changed files
with
1,005 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ package( | |
|
||
readable_example( | ||
srcs = glob(["*.java"]), | ||
deps = ["//third_party:gwt-jsinterop-annotations-j2cl"], | ||
) |
45 changes: 45 additions & 0 deletions
45
...le/j2cl/readable/java/anonymousclass/output_closure/JsConstructorClass$1.impl.java.js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
goog.module('anonymousclass.JsConstructorClass.$1$impl'); | ||
|
||
const j_l_Object = goog.require('java.lang.Object$impl'); | ||
const $Util = goog.require('nativebootstrap.Util$impl'); | ||
|
||
let JsConstructorClass = goog.forwardDeclare('anonymousclass.JsConstructorClass$impl'); | ||
|
||
class $1 extends j_l_Object { | ||
/** @protected @nodts */ | ||
constructor() { | ||
super(); | ||
/**@type {JsConstructorClass} @nodts*/ | ||
this.$outer_this__anonymousclass_JsConstructorClass_1; | ||
} | ||
/** @nodts @return {!$1} */ | ||
static $create__anonymousclass_JsConstructorClass(/** JsConstructorClass */ $outer_this) { | ||
$1.$clinit(); | ||
let $instance = new $1(); | ||
$instance.$ctor__anonymousclass_JsConstructorClass_1__anonymousclass_JsConstructorClass__void($outer_this); | ||
return $instance; | ||
} | ||
/** @nodts */ | ||
$ctor__anonymousclass_JsConstructorClass_1__anonymousclass_JsConstructorClass__void(/** JsConstructorClass */ $outer_this) { | ||
this.$outer_this__anonymousclass_JsConstructorClass_1 = $outer_this; | ||
this.$ctor__java_lang_Object__void(); | ||
} | ||
/** @nodts */ | ||
static $clinit() { | ||
$1.$clinit = () =>{}; | ||
$1.$loadModules(); | ||
j_l_Object.$clinit(); | ||
} | ||
/** @nodts @return {boolean} */ | ||
static $isInstance(/** ? */ instance) { | ||
return instance instanceof $1; | ||
} | ||
|
||
/** @nodts */ | ||
static $loadModules() {} | ||
} | ||
$Util.$setClassMetadata($1, 'anonymousclass.JsConstructorClass$1'); | ||
|
||
exports = $1; | ||
|
||
//# sourceMappingURL=JsConstructorClass$1.js.map |
8 changes: 8 additions & 0 deletions
8
.../google/j2cl/readable/java/anonymousclass/output_closure/JsConstructorClass$1.java.js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
goog.module('anonymousclass.JsConstructorClass.$1'); | ||
|
||
goog.require('anonymousclass.JsConstructorClass'); | ||
goog.require('java.lang.Object'); | ||
goog.require('nativebootstrap.Util'); | ||
|
||
const $1 = goog.require('anonymousclass.JsConstructorClass.$1$impl'); | ||
exports = $1; |
17 changes: 17 additions & 0 deletions
17
...gle/j2cl/readable/java/anonymousclass/output_closure/JsConstructorClass$1.js.mappings.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[{}] => [$1] | ||
[{}] => [constructor] | ||
[{}] => [super();] "anonymousclass.JsConstructorClass$1.<synthetic: ctor_js>" | ||
[{}] => [/**@type {JsConstructorClass} @nodts*/ | ||
this.$outer_this__anonymousclass_JsConstructorClass_1;] "anonymousclass.JsConstructorClass$1.<synthetic: ctor_js>" | ||
[{}] => [$create__anonymousclass_JsConstructorClass] | ||
[{}] => [$1.$clinit();] "anonymousclass.JsConstructorClass$1.<synthetic: ctor_create>" | ||
[{}] => [let $instance = new $1();] "anonymousclass.JsConstructorClass$1.<synthetic: ctor_create>" | ||
[{}] => [$instance.$ctor__anonymousclass_JsConstructorClass_1__anonymousclass_JsConstructorClass__void($outer_this);] "anonymousclass.JsConstructorClass$1.<synthetic: ctor_create>" | ||
[{}] => [return $instance;] "anonymousclass.JsConstructorClass$1.<synthetic: ctor_create>" | ||
[{}] => [$ctor__anonymousclass_JsConstructorClass_1__anonymousclass_JsConstructorClass__void] | ||
[{}] => [this.$outer_this__anonymousclass_JsConstructorClass_1 = $outer_this;] "anonymousclass.JsConstructorClass$1.<init>" | ||
[{}] => [this.$ctor__java_lang_Object__void();] "anonymousclass.JsConstructorClass$1.<init>" | ||
[{}] => [$clinit] | ||
[{}] => [$1.$clinit = () =>{};] "anonymousclass.JsConstructorClass$1.<clinit>" | ||
[{}] => [$1.$loadModules();] "anonymousclass.JsConstructorClass$1.<clinit>" | ||
[{}] => [j_l_Object.$clinit();] "anonymousclass.JsConstructorClass$1.<clinit>" |
52 changes: 52 additions & 0 deletions
52
...ogle/j2cl/readable/java/anonymousclass/output_closure/JsConstructorClass.impl.java.js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
goog.module('anonymousclass.JsConstructorClass$impl'); | ||
|
||
const j_l_Object = goog.require('java.lang.Object$impl'); | ||
const $Util = goog.require('nativebootstrap.Util$impl'); | ||
|
||
let $1 = goog.forwardDeclare('anonymousclass.JsConstructorClass.$1$impl'); | ||
|
||
class JsConstructorClass extends j_l_Object { | ||
//JsConstructor 'JsConstructorClass(Object)'. | ||
|
||
constructor(/** * */ o) { | ||
JsConstructorClass.$clinit(); | ||
super(); | ||
this.$ctor__anonymousclass_JsConstructorClass__java_lang_Object__void(o); | ||
} | ||
//Initialization from constructor 'JsConstructorClass(Object)'. | ||
/** @nodts */ | ||
$ctor__anonymousclass_JsConstructorClass__java_lang_Object__void(/** * */ o) { | ||
this.$ctor__java_lang_Object__void(); | ||
} | ||
//Factory method corresponding to constructor 'JsConstructorClass()'. | ||
/** @nodts @return {!JsConstructorClass} */ | ||
static $create__() { | ||
JsConstructorClass.$clinit(); | ||
let $instance = new JsConstructorClass($1.$create__anonymousclass_JsConstructorClass(null)); | ||
$instance.$ctor__anonymousclass_JsConstructorClass__void(); | ||
return $instance; | ||
} | ||
//Initialization from constructor 'JsConstructorClass()'. | ||
/** @nodts */ | ||
$ctor__anonymousclass_JsConstructorClass__void() {} | ||
/** @nodts */ | ||
static $clinit() { | ||
JsConstructorClass.$clinit = () =>{}; | ||
JsConstructorClass.$loadModules(); | ||
j_l_Object.$clinit(); | ||
} | ||
/** @nodts @return {boolean} */ | ||
static $isInstance(/** ? */ instance) { | ||
return instance instanceof JsConstructorClass; | ||
} | ||
|
||
/** @nodts */ | ||
static $loadModules() { | ||
$1 = goog.module.get('anonymousclass.JsConstructorClass.$1$impl'); | ||
} | ||
} | ||
$Util.$setClassMetadata(JsConstructorClass, 'anonymousclass.JsConstructorClass'); | ||
|
||
exports = JsConstructorClass; | ||
|
||
//# sourceMappingURL=JsConstructorClass.js.map |
8 changes: 8 additions & 0 deletions
8
...om/google/j2cl/readable/java/anonymousclass/output_closure/JsConstructorClass.java.js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
goog.module('anonymousclass.JsConstructorClass'); | ||
|
||
goog.require('anonymousclass.JsConstructorClass.$1'); | ||
goog.require('java.lang.Object'); | ||
goog.require('nativebootstrap.Util'); | ||
|
||
const JsConstructorClass = goog.require('anonymousclass.JsConstructorClass$impl'); | ||
exports = JsConstructorClass; |
19 changes: 19 additions & 0 deletions
19
...oogle/j2cl/readable/java/anonymousclass/output_closure/JsConstructorClass.js.mappings.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[JsConstructorClass] => [JsConstructorClass] | ||
[JsConstructorClass] => [constructor] | ||
[o] => [o] "o" | ||
[JsConstructorClass] => [JsConstructorClass.$clinit();] "anonymousclass.JsConstructorClass.<init>" | ||
[JsConstructorClass] => [super();] "anonymousclass.JsConstructorClass.<init>" | ||
[JsConstructorClass] => [this.$ctor__anonymousclass_JsConstructorClass__java_lang_Object__void(o);] "anonymousclass.JsConstructorClass.<init>" | ||
[JsConstructorClass] => [$ctor__anonymousclass_JsConstructorClass__java_lang_Object__void] | ||
[o] => [o] "o" | ||
[{}] => [this.$ctor__java_lang_Object__void();] "anonymousclass.JsConstructorClass.<init>" | ||
[JsConstructorClass] => [$create__] | ||
[JsConstructorClass] => [JsConstructorClass.$clinit();] "anonymousclass.JsConstructorClass.<synthetic: ctor_create>" | ||
[JsConstructorClass] => [let $instance = new JsConstructorClass($1.$create__anonymousclass_JsConstructorClass(null));] "anonymousclass.JsConstructorClass.<synthetic: ctor_create>" | ||
[JsConstructorClass] => [$instance.$ctor__anonymousclass_JsConstructorClass__void();] "anonymousclass.JsConstructorClass.<synthetic: ctor_create>" | ||
[JsConstructorClass] => [return $instance;] "anonymousclass.JsConstructorClass.<synthetic: ctor_create>" | ||
[JsConstructorClass] => [$ctor__anonymousclass_JsConstructorClass__void] | ||
[JsConstructorClass] => [$clinit] | ||
[JsConstructorClass] => [JsConstructorClass.$clinit = () =>{};] "anonymousclass.JsConstructorClass.<clinit>" | ||
[JsConstructorClass] => [JsConstructorClass.$loadModules();] "anonymousclass.JsConstructorClass.<clinit>" | ||
[JsConstructorClass] => [j_l_Object.$clinit();] "anonymousclass.JsConstructorClass.<clinit>" |
45 changes: 45 additions & 0 deletions
45
...j2cl/readable/java/anonymousclass/output_closure/JsConstructorSubclass$1.impl.java.js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
goog.module('anonymousclass.JsConstructorSubclass.$1$impl'); | ||
|
||
const j_l_Object = goog.require('java.lang.Object$impl'); | ||
const $Util = goog.require('nativebootstrap.Util$impl'); | ||
|
||
let JsConstructorSubclass = goog.forwardDeclare('anonymousclass.JsConstructorSubclass$impl'); | ||
|
||
class $1 extends j_l_Object { | ||
/** @protected @nodts */ | ||
constructor() { | ||
super(); | ||
/**@type {JsConstructorSubclass} @nodts*/ | ||
this.$outer_this__anonymousclass_JsConstructorSubclass_1; | ||
} | ||
/** @nodts @return {!$1} */ | ||
static $create__anonymousclass_JsConstructorSubclass(/** JsConstructorSubclass */ $outer_this) { | ||
$1.$clinit(); | ||
let $instance = new $1(); | ||
$instance.$ctor__anonymousclass_JsConstructorSubclass_1__anonymousclass_JsConstructorSubclass__void($outer_this); | ||
return $instance; | ||
} | ||
/** @nodts */ | ||
$ctor__anonymousclass_JsConstructorSubclass_1__anonymousclass_JsConstructorSubclass__void(/** JsConstructorSubclass */ $outer_this) { | ||
this.$outer_this__anonymousclass_JsConstructorSubclass_1 = $outer_this; | ||
this.$ctor__java_lang_Object__void(); | ||
} | ||
/** @nodts */ | ||
static $clinit() { | ||
$1.$clinit = () =>{}; | ||
$1.$loadModules(); | ||
j_l_Object.$clinit(); | ||
} | ||
/** @nodts @return {boolean} */ | ||
static $isInstance(/** ? */ instance) { | ||
return instance instanceof $1; | ||
} | ||
|
||
/** @nodts */ | ||
static $loadModules() {} | ||
} | ||
$Util.$setClassMetadata($1, 'anonymousclass.JsConstructorSubclass$1'); | ||
|
||
exports = $1; | ||
|
||
//# sourceMappingURL=JsConstructorSubclass$1.js.map |
8 changes: 8 additions & 0 deletions
8
...ogle/j2cl/readable/java/anonymousclass/output_closure/JsConstructorSubclass$1.java.js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
goog.module('anonymousclass.JsConstructorSubclass.$1'); | ||
|
||
goog.require('anonymousclass.JsConstructorSubclass'); | ||
goog.require('java.lang.Object'); | ||
goog.require('nativebootstrap.Util'); | ||
|
||
const $1 = goog.require('anonymousclass.JsConstructorSubclass.$1$impl'); | ||
exports = $1; |
17 changes: 17 additions & 0 deletions
17
.../j2cl/readable/java/anonymousclass/output_closure/JsConstructorSubclass$1.js.mappings.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[{}] => [$1] | ||
[{}] => [constructor] | ||
[{}] => [super();] "anonymousclass.JsConstructorSubclass$1.<synthetic: ctor_js>" | ||
[{}] => [/**@type {JsConstructorSubclass} @nodts*/ | ||
this.$outer_this__anonymousclass_JsConstructorSubclass_1;] "anonymousclass.JsConstructorSubclass$1.<synthetic: ctor_js>" | ||
[{}] => [$create__anonymousclass_JsConstructorSubclass] | ||
[{}] => [$1.$clinit();] "anonymousclass.JsConstructorSubclass$1.<synthetic: ctor_create>" | ||
[{}] => [let $instance = new $1();] "anonymousclass.JsConstructorSubclass$1.<synthetic: ctor_create>" | ||
[{}] => [$instance.$ctor__anonymousclass_JsConstructorSubclass_1__anonymousclass_JsConstructorSubclass__void($outer_this);] "anonymousclass.JsConstructorSubclass$1.<synthetic: ctor_create>" | ||
[{}] => [return $instance;] "anonymousclass.JsConstructorSubclass$1.<synthetic: ctor_create>" | ||
[{}] => [$ctor__anonymousclass_JsConstructorSubclass_1__anonymousclass_JsConstructorSubclass__void] | ||
[{}] => [this.$outer_this__anonymousclass_JsConstructorSubclass_1 = $outer_this;] "anonymousclass.JsConstructorSubclass$1.<init>" | ||
[{}] => [this.$ctor__java_lang_Object__void();] "anonymousclass.JsConstructorSubclass$1.<init>" | ||
[{}] => [$clinit] | ||
[{}] => [$1.$clinit = () =>{};] "anonymousclass.JsConstructorSubclass$1.<clinit>" | ||
[{}] => [$1.$loadModules();] "anonymousclass.JsConstructorSubclass$1.<clinit>" | ||
[{}] => [j_l_Object.$clinit();] "anonymousclass.JsConstructorSubclass$1.<clinit>" |
37 changes: 37 additions & 0 deletions
37
...e/j2cl/readable/java/anonymousclass/output_closure/JsConstructorSubclass.impl.java.js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
goog.module('anonymousclass.JsConstructorSubclass$impl'); | ||
|
||
const JsConstructorClass = goog.require('anonymousclass.JsConstructorClass$impl'); | ||
const $Util = goog.require('nativebootstrap.Util$impl'); | ||
|
||
let $1 = goog.forwardDeclare('anonymousclass.JsConstructorSubclass.$1$impl'); | ||
|
||
class JsConstructorSubclass extends JsConstructorClass { | ||
|
||
constructor() { | ||
JsConstructorSubclass.$clinit(); | ||
super($1.$create__anonymousclass_JsConstructorSubclass(null)); | ||
this.$ctor__anonymousclass_JsConstructorSubclass__void(); | ||
} | ||
/** @nodts */ | ||
$ctor__anonymousclass_JsConstructorSubclass__void() {} | ||
/** @nodts */ | ||
static $clinit() { | ||
JsConstructorSubclass.$clinit = () =>{}; | ||
JsConstructorSubclass.$loadModules(); | ||
JsConstructorClass.$clinit(); | ||
} | ||
/** @nodts @return {boolean} */ | ||
static $isInstance(/** ? */ instance) { | ||
return instance instanceof JsConstructorSubclass; | ||
} | ||
|
||
/** @nodts */ | ||
static $loadModules() { | ||
$1 = goog.module.get('anonymousclass.JsConstructorSubclass.$1$impl'); | ||
} | ||
} | ||
$Util.$setClassMetadata(JsConstructorSubclass, 'anonymousclass.JsConstructorSubclass'); | ||
|
||
exports = JsConstructorSubclass; | ||
|
||
//# sourceMappingURL=JsConstructorSubclass.js.map |
8 changes: 8 additions & 0 deletions
8
...google/j2cl/readable/java/anonymousclass/output_closure/JsConstructorSubclass.java.js.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
goog.module('anonymousclass.JsConstructorSubclass'); | ||
|
||
goog.require('anonymousclass.JsConstructorClass'); | ||
goog.require('anonymousclass.JsConstructorSubclass.$1'); | ||
goog.require('nativebootstrap.Util'); | ||
|
||
const JsConstructorSubclass = goog.require('anonymousclass.JsConstructorSubclass$impl'); | ||
exports = JsConstructorSubclass; |
10 changes: 10 additions & 0 deletions
10
...le/j2cl/readable/java/anonymousclass/output_closure/JsConstructorSubclass.js.mappings.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[JsConstructorSubclass] => [JsConstructorSubclass] | ||
[JsConstructorSubclass] => [constructor] | ||
[JsConstructorSubclass] => [JsConstructorSubclass.$clinit();] "anonymousclass.JsConstructorSubclass.<init>" | ||
[JsConstructorSubclass] => [super($1.$create__anonymousclass_JsConstructorSubclass(null));] "anonymousclass.JsConstructorSubclass.<init>" | ||
[JsConstructorSubclass] => [this.$ctor__anonymousclass_JsConstructorSubclass__void();] "anonymousclass.JsConstructorSubclass.<init>" | ||
[JsConstructorSubclass] => [$ctor__anonymousclass_JsConstructorSubclass__void] | ||
[JsConstructorSubclass] => [$clinit] | ||
[JsConstructorSubclass] => [JsConstructorSubclass.$clinit = () =>{};] "anonymousclass.JsConstructorSubclass.<clinit>" | ||
[JsConstructorSubclass] => [JsConstructorSubclass.$loadModules();] "anonymousclass.JsConstructorSubclass.<clinit>" | ||
[JsConstructorSubclass] => [JsConstructorClass.$clinit();] "anonymousclass.JsConstructorSubclass.<clinit>" |
Oops, something went wrong.