[nem-en] Compare two MType
Michal Moskal
michal.moskal at gmail.com
Thu Nov 23 10:08:16 CET 2006
On 11/23/06, Michal Moskal <michal.moskal at gmail.com> wrote:
> On 11/22/06, vc <vc at rsdn.ru> wrote:
> > > In completion I need compare two MType.
> > >
> > > I try to use MType.TryProvide(), but in some case it is get wrong result.
> > >
> > > For example, if type1 is 'array[string]' and type2 is 'array[T.123]' the
> > > TryProvide() return false. But me need interpret it as same type.
> > >
> > > What me need to do?
> >
> > Me need filter extension methods for completion list. See ncc\typing\Typer.n
> > lile 1464.
>
> You need to call GetFreshType() on the method, ignore TyVars and match
> MType returned against MType.Fun. It will have T.123 replaced with a
> fresh type variable that will be substitued with string.
Or, better yet do a (untested):
match (ty.TypeOfMethod (meth).Fix ()) {
| Fun (from, _) =>
match (from.Fix ().GetFunctionArguments ()) {
| t1 :: _ => ty.TryProvide (t1)
| _ => false
}
| _ => Util.ice ()
}
which should also work when the defing class of an extension method is
generic (as oposed to just the method being generic).
--
Michał
More information about the devel-en
mailing list