Skip to content

case of recognizes Enso values as any Java interface even though is_a does not #12266

@radeusgd

Description

@radeusgd

I've discovered this issue when debugging test failures on #12247 PR.

A simple repro can be following:

from Standard.Base import all

polyglot java import org.enso.base.text.TextFoldingStrategy

f x = case x of
    j : TextFoldingStrategy ->
        suffix = ", but is it really? "+(j.is_a TextFoldingStrategy).to_text
        j.to_text+" is a Java value"+suffix
    other -> other.to_text+" is not a Java value"

type My_Type
    Value x

main =
    IO.println (f 42)
    IO.println (f "abc")
    IO.println (f (My_Type.Value 1))

That code prints:

42 is not a Java value
abc is not a Java value
(My_Type.Value 1) is a Java value, but is it really? False

We can see that case of treats My_Type as if it was matching the TextFoldingStrategy interface. However is_a correctly responds that it has nothing to do with it.

I think that case of matching any Enso type with any Java interface is wrong.

Metadata

Metadata

Type

No type

Projects

Status

🟢 Accepted

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions