|
13 | 13 | import org.aya.generic.term.DTKind;
|
14 | 14 | import org.aya.normalize.Normalizer;
|
15 | 15 | import org.aya.syntax.compile.JitCon;
|
| 16 | +import org.aya.syntax.compile.JitData; |
16 | 17 | import org.aya.syntax.concrete.Expr;
|
17 | 18 | import org.aya.syntax.concrete.Pattern;
|
| 19 | +import org.aya.syntax.concrete.stmt.decl.DataDecl; |
18 | 20 | import org.aya.syntax.core.Jdg;
|
19 |
| -import org.aya.syntax.core.def.ConDef; |
20 |
| -import org.aya.syntax.core.def.ConDefLike; |
| 21 | +import org.aya.syntax.core.def.*; |
21 | 22 | import org.aya.syntax.core.pat.Pat;
|
22 | 23 | import org.aya.syntax.core.pat.PatMatcher;
|
23 | 24 | import org.aya.syntax.core.pat.PatToTerm;
|
@@ -156,10 +157,10 @@ public record TyckResult(
|
156 | 157 |
|
157 | 158 | // report after tyRef.set, the error message requires it
|
158 | 159 | if (whnf(type) instanceof DataCall call) {
|
159 |
| - var unimportedCon = call.ref().body() |
160 |
| - .filter(con -> con.name().equals(bind.name())); |
| 160 | + var unimportedCon = collectConNames(call.ref()) |
| 161 | + .anyMatch(it -> it.equals(bind.name())); |
161 | 162 |
|
162 |
| - if (unimportedCon.isNotEmpty()) { |
| 163 | + if (unimportedCon) { |
163 | 164 | fail(new PatternProblem.UnimportedConName(pattern.replace(bindPat)));
|
164 | 165 | }
|
165 | 166 | }
|
@@ -479,6 +480,17 @@ private record Selection(
|
479 | 480 | };
|
480 | 481 | }
|
481 | 482 |
|
| 483 | + private static @NotNull SeqView<String> collectConNames(@NotNull DataDefLike call) { |
| 484 | + return switch (call) { |
| 485 | + case JitData jitData -> jitData.body().view().map(AnyDef::name); |
| 486 | + case DataDef.Delegate delegate -> { |
| 487 | + // the core may be unchecked! |
| 488 | + var concrete = (DataDecl) delegate.ref.concrete; |
| 489 | + yield concrete.body.view().map(it -> it.ref.name()); |
| 490 | + } |
| 491 | + }; |
| 492 | + } |
| 493 | + |
482 | 494 | /**
|
483 | 495 | * Check whether {@param con} is available under {@param type}
|
484 | 496 | */
|
|
0 commit comments