From eaadc7f495047bce11d4dd1f5b61945db05694af Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Tue, 11 Jun 2024 16:06:59 +0200 Subject: [PATCH] Also check intersection type --- .../test/AutoscopedConstructorTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AutoscopedConstructorTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AutoscopedConstructorTest.java index 73d6e841fbf1..41515e2c0e82 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AutoscopedConstructorTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AutoscopedConstructorTest.java @@ -1,5 +1,7 @@ package org.enso.interpreter.test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -307,4 +309,28 @@ public void simpleAnyOrACheck() { assertEquals("A", create.getMetaObject().getMetaSimpleName()); } + + @Test + public void intersectionAnyOrACheck() { + var code = + """ + import Standard.Base.Any.Any + + type A + Typed (x:Any&A) + + t = ..Typed ..My_Other + materialize v:A = v + + create = materialize t + """; + + try { + var create = + ctx.eval("enso", code).invokeMember(MethodNames.Module.EVAL_EXPRESSION, "create"); + fail("Got value, but expecting an exception: " + create); + } catch (PolyglotException ex) { + assertThat(ex.getMessage(), containsString("Cannot find constructor ..My_Other among A.")); + } + } }