Skip to content

Commit

Permalink
Semantic: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed Mar 12, 2024
1 parent 2a25bf4 commit 4e2ef47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/scope/trait.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('trait', () => {
expect(formatImplTypes(findSuperRelChains(vidFromString('std::list::List'), ctx))).toEqual([
['std::iter::Iterable<T>'],
['std::iter::Collector<T>'],
['std::io::Display'],
['std::io::Display']
])

Expand Down
7 changes: 4 additions & 3 deletions src/scope/trait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,14 @@ export const resolveTypeImpl = (
if (!traitRef || traitRef.def.kind !== 'trait-def') return undefined
const trait = ctx.impls.find(i => i.instanceDef === traitRef.def)!
const candidates = ctx.impls
.filter(
i =>
.filter(i => {
return (
(i.instanceDef.kind === 'impl-def' ||
i.instanceDef.block.statements.every(s => s.kind === 'fn-def' && s.block)) &&
isAssignable(type, i.forType, ctx) &&
typeEq(i.implType, traitType)
)
)
})
.toSorted((a, b) => relComparator(b, ctx, type, traitType) - relComparator(a, ctx, type, traitType))
const impl = candidates.at(0)
return impl ? { trait, impl } : undefined
Expand Down

0 comments on commit 4e2ef47

Please sign in to comment.