<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<br>
<br>
<div class="moz-cite-prefix">On 3/7/2023 3:26 PM, <a class="moz-txt-link-abbreviated" href="mailto:forax@univ-mlv.fr">forax@univ-mlv.fr</a>
wrote:<br>
</div>
<blockquote type="cite" cite="mid:317692261.5717481.1678220813727.JavaMail.zimbra@u-pem.fr">
<div style="font-family: arial, helvetica, sans-serif; font-size:
12pt; color: #000000">
<div data-marker="__QUOTED_TEXT__">It's not exactly what i ask,
the question is how to call the deconstructor that takes a
CharSequence with a type pattern on a String.<br data-mce-bogus="1">
<div>The inverse of<br data-mce-bogus="1">
</div>
<div> String s = ...<br data-mce-bogus="1">
</div>
<div> new Foo((CharSequence) s)<br data-mce-bogus="1">
</div>
<div><br data-mce-bogus="1">
</div>
<div>should be <br data-mce-bogus="1">
</div>
<div> case [Call the destructor Foo(CharSequence)] + Type
Pattern (String)<br data-mce-bogus="1">
</div>
<br>
</div>
</div>
</blockquote>
<br>
Well, remember that you cannot really "name" a method either, you
can only eliminate the ambiguity that would cause a different method
to be selected. And its the same with patterns. <br>
<br>
If you really want to do this (and its not clear to me why this is
so important) you can do this:<br>
<br>
if (target instanceof Foo(CharSequence cs) && cs
instanceof String s) { ... }<br>
<br>
The first clause ensures that you select the CS pattern, and the
second refines the binding as if you had nested `String s`. <br>
<br>
</body>
</html>