Skip to content

Commit

Permalink
cast: generate dummy terms
Browse files Browse the repository at this point in the history
Co-authored-by: Hoshino Tented <[email protected]>
  • Loading branch information
ice1000 and HoshinoTented committed Nov 15, 2024
1 parent 71f1e15 commit 4b35a0d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public sealed interface ClassDefLike extends AnyDef permits JitClass, ClassDef.D

default @NotNull Term telescope(int i, @NotNull Seq<Term> restriction) {
var member = members().get(i);
// Our code should not refer the subterm of [self], the only meaningful part is [self.forget()]
// Our code should not refer any out-of-scope field, the only meaningful part is [self.forget().take(i)]
// Also, we don't use NewTerm, cause the type of the self-parameter is a class call without any restriction.
var self = new ClassCastTerm(this, ErrorTerm.DUMMY, ImmutableSeq.empty(),
restriction.view().take(i).map(Closure::mkConst).toImmutableSeq()
);
var implList = ImmutableSeq.fill(members().size(), idx ->
Closure.mkConst(idx < i ? restriction.get(idx) : ErrorTerm.DUMMY));

var self = new ClassCastTerm(this, ErrorTerm.DUMMY, ImmutableSeq.empty(), implList);
return member.signature().inst(ImmutableSeq.of(self)).makePi(Seq.empty());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public record ClassCastTerm(
@NotNull ImmutableSeq<Closure> forget
) implements StableWHNF, Term {
public ClassCastTerm {
// TODO: uncomment
// assert forget.isNotEmpty();
assert forget.isNotEmpty();
}

public @NotNull ClassCastTerm update(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ private MemberCall update(Term clazz, ImmutableSeq<Term> newArgs) {
}

public static @NotNull Term make(
@NotNull ClassCall typeOfOf,
@NotNull Term of,
@NotNull MemberDefLike ref,
int ulift,
@NotNull ClassCall typeOfOf, @NotNull Term of,
@NotNull MemberDefLike ref, int ulift,
@NotNull ImmutableSeq<@NotNull Term> args
) {
var impl = typeOfOf.get(ref);
Expand Down

0 comments on commit 4b35a0d

Please sign in to comment.