/// Resolve overloaded definitions to exactly one unambiguous definition.
Resolve overloaded definitions to exactly one unambiguous definition.
Resolve overloaded definitions to exactly one unambiguous definition .
pub fn resolve_overloads(
    ctx: &ScoreContext,
    defs: &[Spanned<Def>],
    req: &OverloadReq,
    span: Span,
) -> Result<Spanned<Def>> {
    let reduced = reduce_overloads(ctx, defs, req, span)?;
    if reduced.is_empty() {
        ctx.emit(
            DiagBuilder2::error("no overload applies").span(span), // TODO: Show available implementations.
        );
        debugln!("available definitions: {:#?}", defs);
        Err(())
    } else if reduced.len() > 1 {
        ctx.emit(
            DiagBuilder2::error(format!("`{}` is ambiguous", span.extract())).span(span), // TODO: Show implementations that matched.
        );
        debugln!("matching definitions: {:#?}", reduced);
        Err(())
    } else {
        Ok(reduced.into_iter().next().unwrap())
    }
}
pub fn resolve_overloads ( ctx : & ScoreContext , defs : & [ Spanned < Def > ] , req : & OverloadReq , span : Span , ) -> Result < Spanned < Def > > { let reduced = reduce_overloads ( ctx , defs , req , span ) ? ; if reduced . is_empty ( ) { ctx . emit ( DiagBuilder2 :: error ( " " ) . span ( span ) , // TODO: Show available implementations. ) ; debugln ! ( " " defs ) ; Err ( ( ) ) } else if reduced . len ( ) > 1 { ctx . emit ( DiagBuilder2 :: error ( format ! ( " " span extract ( ) ) ) . span ( span ) , // TODO: Show implementations that matched. ) ; debugln ! ( " " reduced ) ; Err ( ( ) ) } else { Ok ( reduced . into_iter ( ) . next ( ) . unwrap ( ) ) } }
Resolve overloaded definitions to exactly one unambiguous definition.
Resolve overloaded definitions to exactly one unambiguous definition .
ctx
&ScoreContext
defs
&[Spanned<Def>]
req
&OverloadReq
span
Span