-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-2230: Incorrect scoping in modules containing (non-static) polyfil…
…ls (#2231) * fix bug * add tests * adjust test expectation
- Loading branch information
mmews-n4
authored
Oct 18, 2021
1 parent
3dc450a
commit 2b9bdaa
Showing
7 changed files
with
144 additions
and
1 deletion.
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
41 changes: 41 additions & 0 deletions
41
tests/org.eclipse.n4js.xpect.tests/xt-tests/polyfill/ref_to_filled_type_scoping.n4js.xt
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,41 @@ | ||
/* | ||
* Copyright (c) 2021 NumberFour AG. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* NumberFour AG - Initial API and implementation | ||
*/ | ||
|
||
/* XPECT_SETUP org.eclipse.n4js.xpect.tests.N4jsXtTest | ||
Workspace { | ||
Project "ref-to-filled-type-scoping" { | ||
Folder "src" { | ||
ThisFile { } | ||
} | ||
File "package.json" { from="ref_to_filled_type_scoping.package.json" } | ||
} | ||
} | ||
END_SETUP | ||
*/ | ||
|
||
|
||
@@Global @@ProvidedByRuntime | ||
|
||
@Polyfill | ||
export external public class Array<T> extends Array<T> { | ||
// XPECT linkedFragment at 'Array' --> n4scheme:/builtin_js.n4jsd#/1/@topLevelTypes.2 | ||
member: Array<number>; // correctly scoped to Array in builtin_js.n4jsd | ||
} | ||
|
||
// XPECT linkedFragment at 'Array' --> n4scheme:/builtin_js.n4jsd#/1/@topLevelTypes.2 | ||
const K : Array<string> = null; | ||
|
||
class SomeClass { | ||
// XPECT linkedFragment at 'Array' --> n4scheme:/builtin_js.n4jsd#/1/@topLevelTypes.2 | ||
someMethod(): Array<string>; // make sure: not incorrectly scoped to Array in this module | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/org.eclipse.n4js.xpect.tests/xt-tests/polyfill/ref_to_filled_type_scoping.package.json
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,15 @@ | ||
{ | ||
"name": "ref-to-filled-type-scoping", | ||
"version": "0.0.1", | ||
"n4js": { | ||
"projectType": "runtimelibrary", | ||
"vendorId": "org.eclipse.n4js", | ||
"vendorName": "Eclipse N4JS Project", | ||
"output": "src-gen", | ||
"sources": { | ||
"source": [ | ||
"src" | ||
] | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...pse.n4js.xpect.tests/xt-tests/polyfill_static/ref_to_static_filled_type_scoping.n4js.src2
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,21 @@ | ||
/* | ||
* Copyright (c) 2021 NumberFour AG. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* NumberFour AG - Initial API and implementation | ||
*/ | ||
|
||
@@StaticPolyfillAware | ||
|
||
export public class A { | ||
public methodA() : void {} | ||
} | ||
|
||
|
||
export public class B { | ||
public methodB() : void {} | ||
} |
49 changes: 49 additions & 0 deletions
49
...lipse.n4js.xpect.tests/xt-tests/polyfill_static/ref_to_static_filled_type_scoping.n4js.xt
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,49 @@ | ||
/* | ||
* Copyright (c) 2021 NumberFour AG. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* NumberFour AG - Initial API and implementation | ||
*/ | ||
|
||
/* XPECT_SETUP org.eclipse.n4js.xpect.tests.N4jsXtTest | ||
Workspace { | ||
Project "ref-to-static-filled-type-scoping" { | ||
Folder "src1" { | ||
ThisFile { } | ||
} | ||
Folder "src2" { | ||
File "ref_to_static_filled_type_scoping.n4js" { from="ref_to_static_filled_type_scoping.n4js.src2" } | ||
} | ||
File "package.json" { from="ref_to_static_filled_type_scoping.package.json" } | ||
} | ||
} | ||
END_SETUP | ||
*/ | ||
|
||
|
||
|
||
|
||
@@StaticPolyfillModule | ||
|
||
@StaticPolyfill | ||
export public class A extends A { | ||
|
||
// XPECT linkedFragment at 'A' --> ../src2/ref_to_static_filled_type_scoping.n4js#/1/@topLevelTypes.0 | ||
public member : A = null; | ||
} | ||
|
||
|
||
@StaticPolyfill | ||
export public class B extends B { | ||
|
||
// XPECT linkedFragment at 'A' --> ../src2/ref_to_static_filled_type_scoping.n4js#/1/@topLevelTypes.0 | ||
public member : A = null; | ||
} | ||
|
||
|
16 changes: 16 additions & 0 deletions
16
....n4js.xpect.tests/xt-tests/polyfill_static/ref_to_static_filled_type_scoping.package.json
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,16 @@ | ||
{ | ||
"name": "ref-to-static-filled-type-scoping", | ||
"version": "0.0.1", | ||
"n4js": { | ||
"projectType": "library", | ||
"vendorId": "org.eclipse.n4js", | ||
"vendorName": "Eclipse N4JS Project", | ||
"output": "src-gen", | ||
"sources": { | ||
"source": [ | ||
"src1", | ||
"src2" | ||
] | ||
} | ||
} | ||
} |