Skip to content

Commit

Permalink
Semantic: better generic inference
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed Mar 30, 2024
1 parent 4204e67 commit 1455434
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/semantic/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Context, addError } from '../scope'
import { getInstanceForType, resolveMethodImpl, resolveTypeImpl } from '../scope/trait'
import { vidFromString, vidToString } from '../scope/util'
import { MethodDef, VirtualIdentifier, resolveVid, typeKinds } from '../scope/vid'
import { VirtualFnType, VirtualType, combine, genericToVirtual, typeToVirtual, virtualTypeToString } from '../typecheck'
import { VirtualFnType, VirtualType, combine, genericToVirtual, typeToVirtual } from '../typecheck'
import {
makeFnGenericMap,
makeFnTypeArgGenericMap,
Expand Down Expand Up @@ -174,6 +174,7 @@ export const checkMethodCall = (expr: UnaryExpr, mCall: MethodCallOp, ctx: Conte
return resolveType(fnType.returnType, genericMaps, ctx)
}

// TODO: disambiguate clashing generic names
const makeMethodGenericMaps = (
lOperand: Operand,
methodDef: MethodDef,
Expand Down Expand Up @@ -205,5 +206,9 @@ const makeMethodGenericMaps = (
const fnGenericMap = makeFnGenericMap(fnType, [lOperand.type!, ...call.call.args.map(a => a.expr.type!)])
maps.push(fnGenericMap)

// needed to resolve generics in closure return type
// TODO: might also be required in other generic map builders
maps.push(implForGenericMap)

return maps
}

0 comments on commit 1455434

Please sign in to comment.