-
Notifications
You must be signed in to change notification settings - Fork 903
fix logic for obtaining TypeInfoFactory #1961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gbrail
merged 12 commits into
mozilla:master
from
ZZZank:type-factory-in-FunctionObject
Jul 25, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aed8b01
fix TypeInfoFactory used in FunctionObject
ZZZank b6b1f98
add test for FunctionObject+TypeInfoFactory
ZZZank c95d5aa
doc
ZZZank 9151ace
fix test method name
ZZZank c03015f
make `TypeInfoFactory#associate(...)` return a factory instead of a bool
ZZZank 92c954e
remove lazy init of TypeInfoFactory
ZZZank 1c5bd8f
add test case
ZZZank d00b035
fix test
ZZZank e54ad6f
make `ScriptableObject#defineProperty(...)` not depend on an initiali…
ZZZank 7ec22aa
Revert "fix test"
ZZZank fb14a4c
more fallback
ZZZank e755465
configure decycle
ZZZank File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import java.util.function.BiConsumer; | ||
| import java.util.function.Consumer; | ||
| import org.mozilla.javascript.ast.FunctionNode; | ||
| import org.mozilla.javascript.lc.type.impl.factory.ConcurrentFactory; | ||
| import org.mozilla.javascript.typedarrays.NativeArrayBuffer; | ||
| import org.mozilla.javascript.typedarrays.NativeBigInt64Array; | ||
| import org.mozilla.javascript.typedarrays.NativeBigUint64Array; | ||
|
|
@@ -167,6 +168,7 @@ public static ScriptableObject initSafeStandardObjects( | |
|
|
||
| scope.associateValue(LIBRARY_SCOPE_KEY, scope); | ||
| new ClassCache().associate(scope); | ||
| new ConcurrentFactory().associate(scope); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with that. We can move that later to |
||
|
|
||
| LambdaConstructor function = BaseFunction.init(cx, scope, sealed); | ||
| LambdaConstructor obj = NativeObject.init(cx, scope, sealed); | ||
|
|
||
This file contains hidden or 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 hidden or 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
53 changes: 53 additions & 0 deletions
53
tests/src/test/java/org/mozilla/javascript/tests/type_info/AlwaysFailFactory.java
This file contains hidden or 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,53 @@ | ||
| package org.mozilla.javascript.tests.type_info; | ||
|
|
||
| import java.lang.reflect.GenericArrayType; | ||
| import java.lang.reflect.ParameterizedType; | ||
| import java.lang.reflect.TypeVariable; | ||
| import java.lang.reflect.WildcardType; | ||
| import java.util.List; | ||
| import org.mozilla.javascript.lc.type.TypeInfo; | ||
| import org.mozilla.javascript.lc.type.TypeInfoFactory; | ||
|
|
||
| /** | ||
| * @author ZZZank | ||
| */ | ||
| enum AlwaysFailFactory implements TypeInfoFactory { | ||
| INSTANCE; | ||
|
|
||
| public static final String MESSAGE = "attempting to create TypeInfo on AlwaysFailFactory"; | ||
|
|
||
| @Override | ||
| public TypeInfo create(Class<?> clazz) { | ||
| throw new AssertionError(MESSAGE); | ||
| } | ||
|
|
||
| @Override | ||
| public TypeInfo create(GenericArrayType genericArrayType) { | ||
| throw new AssertionError(MESSAGE); | ||
| } | ||
|
|
||
| @Override | ||
| public TypeInfo create(TypeVariable<?> typeVariable) { | ||
| throw new AssertionError(MESSAGE); | ||
| } | ||
|
|
||
| @Override | ||
| public TypeInfo create(ParameterizedType parameterizedType) { | ||
| throw new AssertionError(MESSAGE); | ||
| } | ||
|
|
||
| @Override | ||
| public TypeInfo create(WildcardType wildcardType) { | ||
| throw new AssertionError(MESSAGE); | ||
| } | ||
|
|
||
| @Override | ||
| public TypeInfo toArray(TypeInfo component) { | ||
| throw new AssertionError(MESSAGE); | ||
| } | ||
|
|
||
| @Override | ||
| public TypeInfo attachParam(TypeInfo base, List<TypeInfo> params) { | ||
| throw new AssertionError(MESSAGE); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need both? (probably...
TypeInfoFactory implements TypeInfo)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we need. My guess is that the
.associate(...)method is fromTypeInfoFactory, and Decycle consider it as a reference toTypeInfoFactory