aboutsummaryrefslogtreecommitdiff
path: root/src/jdk/nashorn/internal/codegen/types/Type.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jdk/nashorn/internal/codegen/types/Type.java')
-rw-r--r--src/jdk/nashorn/internal/codegen/types/Type.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/jdk/nashorn/internal/codegen/types/Type.java b/src/jdk/nashorn/internal/codegen/types/Type.java
index 2fa2c315..e7c78953 100644
--- a/src/jdk/nashorn/internal/codegen/types/Type.java
+++ b/src/jdk/nashorn/internal/codegen/types/Type.java
@@ -292,6 +292,16 @@ public abstract class Type implements Comparable<Type>, BytecodeOps {
}
/**
+ * Determines whether this type represents an primitive type according to the ECMAScript specification,
+ * which includes Boolean, Number, and String.
+ *
+ * @return true if a JavaScript primitive type, false otherwise.
+ */
+ public boolean isJSPrimitive() {
+ return !isObject() || isString();
+ }
+
+ /**
* Determines whether a type is the BOOLEAN type
* @return true if BOOLEAN, false otherwise
*/
@@ -443,7 +453,7 @@ public abstract class Type implements Comparable<Type>, BytecodeOps {
} else if (type0.isArray() != type1.isArray()) {
//array and non array is always object, widest(Object[], int) NEVER returns Object[], which has most weight. that does not make sense
return Type.OBJECT;
- } else if (type0.isObject() && type1.isObject() && ((ObjectType)type0).getTypeClass() != ((ObjectType)type1).getTypeClass()) {
+ } else if (type0.isObject() && type1.isObject() && type0.getTypeClass() != type1.getTypeClass()) {
// Object<type=String> and Object<type=ScriptFunction> will produce Object
// TODO: maybe find most specific common superclass?
return Type.OBJECT;