Skip to content
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

Intersection types & type checks #11600

Merged
merged 43 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c0c2fc5
Splitting types in EnsoMultiValue to methodDispatchTypes and the rest
JaroslavTulach Nov 20, 2024
c780c37
Merging with latest chances in develop
JaroslavTulach Nov 22, 2024
515e134
Don't expose EnsoMultiValue methods directly
JaroslavTulach Nov 25, 2024
d0460a4
TypeOf UnresolvedConstructor and UnresolvedSymbol test
JaroslavTulach Nov 25, 2024
a101fe6
Merge branch 'wip/jtulach/UseTypeOfNode11482' into wip/jtulach/Comple…
JaroslavTulach Nov 25, 2024
4e08d8f
UnsupportedMessageException.create accepts only AbstractTruffleException
JaroslavTulach Nov 25, 2024
acebbc1
Unwrap EnsoMultiValue before composing new EnsoMultiValue.create
JaroslavTulach Nov 25, 2024
af85b11
Avoid double wrapping test
JaroslavTulach Nov 25, 2024
ba5953f
Only consider booleans up to methodDispatchTypes
JaroslavTulach Nov 25, 2024
c2d1911
EqualsMultiValueTest
JaroslavTulach Nov 25, 2024
11f8ebc
Two unit tests showing a difference between success and failure
JaroslavTulach Nov 25, 2024
0278257
Special EqualsNode for EnsoMultiValue
JaroslavTulach Nov 25, 2024
720f644
Primitive interop types are mutually exclusive - we need to use one f…
JaroslavTulach Nov 25, 2024
ebaf492
Merge remote-tracking branch 'origin/develop' into wip/jtulach/Comple…
JaroslavTulach Nov 25, 2024
b5fc062
Interop value cannot be both isString and isNumber
JaroslavTulach Nov 25, 2024
02ec775
Handle EnsoMultiValue in a special way
JaroslavTulach Nov 25, 2024
57da6eb
Base EnsoMultiValue.equals on findAllTypesOrNull
JaroslavTulach Nov 26, 2024
3d048be
Documenting the example of Text and extra Integer equality check
JaroslavTulach Nov 26, 2024
be5dbe8
Don't consider extra multi value types in equals
JaroslavTulach Nov 26, 2024
0a81038
Note in the changelog
JaroslavTulach Nov 26, 2024
9fc4bb4
No need for StructsLibrary hack anymore
JaroslavTulach Nov 26, 2024
3a09a8d
No changes in GetFieldNode needed
JaroslavTulach Nov 26, 2024
20973d0
Intersection type and additional conversions tests
JaroslavTulach Nov 26, 2024
ce4c738
Verify dispatch of methods behaves as expected
JaroslavTulach Nov 27, 2024
a6ff51b
Only consider methodDispatchTypes for from conversions
JaroslavTulach Nov 27, 2024
957b3eb
Additional multi value tests
Akirathan Nov 29, 2024
dc490cf
Stream.of.anyMatch
JaroslavTulach Nov 29, 2024
d3102ad
Cleaning up allocated context
JaroslavTulach Nov 29, 2024
57eaf4a
Let converted by the variable name
JaroslavTulach Nov 29, 2024
9929fe8
Finishing documentation sentence
JaroslavTulach Nov 29, 2024
f5fbcf4
Otherwise extract value of type
JaroslavTulach Nov 29, 2024
ca0dd9a
Test also equality with Hi
JaroslavTulach Nov 29, 2024
2f72704
Send multi value as a method argument test
JaroslavTulach Dec 4, 2024
d1172a9
Merge remote-tracking branch 'origin/develop' into wip/jtulach/Comple…
JaroslavTulach Dec 10, 2024
f386c7b
All types state for type check nodes
JaroslavTulach Dec 10, 2024
7db299b
Documenting behavior of intersection types
JaroslavTulach Dec 11, 2024
1167b52
Documenting the converting type check
JaroslavTulach Dec 11, 2024
6b3b4d6
Example of failing conversions
JaroslavTulach Dec 11, 2024
52038f7
Verify case of on multi value
JaroslavTulach Dec 11, 2024
9eaa742
Note about #11600 in CHANGELOG.md belongs to Next Next Release
JaroslavTulach Dec 11, 2024
d1cbc8d
Radek's comments to Intersection Types documentation
radeusgd Dec 12, 2024
77619ab
Open to subclasses
JaroslavTulach Dec 12, 2024
91987ca
Multi value == is not transitive
JaroslavTulach Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ final Object doThatConversionUncached(
for (var thatType : multi.allTypes()) {
var fn = findSymbol(symbol, thatType);
if (fn != null) {
var thatCasted = EnsoMultiValue.CastToNode.getUncached().executeCast(thatType, multi);
var thatCasted =
EnsoMultiValue.CastToNode.getUncached().executeCast(thatType, multi, false);
var result =
doDispatch(
frame, self, thatCasted, selfType, thatType, fn, convertNode, invokeNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Object doMultiValue(
Object[] arguments,
@Cached EnsoMultiValue.CastToNode castTo) {
var type = extractType(self);
var result = castTo.executeCast(type, that);
var result = castTo.executeCast(type, that, true);
if (result == null) {
throw new PanicException(
EnsoContext.get(this).getBuiltins().error().makeNoSuchConversion(type, self, conversion),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ Object doMultiValue(
@Cached EnsoMultiValue.CastToNode castTo) {
var fnAndType = self.resolveSymbol(methodResolverNode, symbol);
if (fnAndType != null) {
var unwrapSelf = castTo.executeCast(fnAndType.getRight(), self);
var unwrapSelf = castTo.executeCast(fnAndType.getRight(), self, false);
if (unwrapSelf != null) {
assert arguments[0] == self;
arguments[0] = unwrapSelf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Root of hierarchy of nodes checking types. This class (and its subclasses) are an implementation
* detail. The API to perform the is in {@link TypeCheckNode}.
* detail. The API to perform the check or conversion is in {@link TypeCheckValueNode}.
*/
abstract sealed class AbstractTypeCheckNode extends Node
permits OneOfTypesCheckNode, AllOfTypesCheckNode, SingleTypeCheckNode, MetaTypeCheckNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Object executeCheckOrConversion(VirtualFrame frame, Object value, ExpressionNode
valueTypes[at] = types.getType(result);
at++;
}
return EnsoMultiValue.create(valueTypes, values);
return EnsoMultiValue.create(valueTypes, valueTypes.length, values);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Node for checking {@code polyglot java import} types. This class (and its subclasses)
* are an implementation detail. The API to perform the is in {@link TypeCheckNode}.
* are an implementation detail. The API to perform the is in {@link TypeCheckValueNode}.
*/
non-sealed abstract class MetaTypeCheckNode extends AbstractTypeCheckNode {
private final CachingSupplier<? extends Object> expectedSupplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ final Object findDirectMatch(VirtualFrame frame, Object v) {
CompilerDirectives.transferToInterpreter();
castTo = insert(EnsoMultiValue.CastToNode.create());
}
var result = castTo.executeCast(expectedType, mv);
var result = castTo.executeCast(expectedType, mv, true);
if (result != null) {
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ ExpressionNode getOriginal() {

@Override
public Object executeGeneric(VirtualFrame frame) {
java.lang.Object value = original.executeGeneric(frame);
java.lang.Object result = check.handleCheckOrConversion(frame, value, original);
var value = original.executeGeneric(frame);
var result = check.handleCheckOrConversion(frame, value, original);
return result;
}

Expand Down
Loading
Loading