Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: imkiva <imkiva@islovely.icu>
- Loading branch information
Showing
18 changed files
with
264 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) 2020-2021 Yinsen (Tesla) Zhang. | ||
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file. | ||
package org.aya.api.error; | ||
|
||
import kala.collection.mutable.Buffer; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public interface StoringReporter extends Reporter { | ||
@NotNull Buffer<Problem> problems(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
base/src/main/java/org/aya/tyck/error/CircularSignatureError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2020-2021 Yinsen (Tesla) Zhang. | ||
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file. | ||
package org.aya.tyck.error; | ||
|
||
import kala.collection.immutable.ImmutableSeq; | ||
import org.aya.api.distill.DistillerOptions; | ||
import org.aya.api.error.Problem; | ||
import org.aya.api.error.SourcePos; | ||
import org.aya.concrete.remark.Remark; | ||
import org.aya.concrete.stmt.Decl; | ||
import org.aya.concrete.stmt.Sample; | ||
import org.aya.concrete.stmt.Stmt; | ||
import org.aya.pretty.doc.Doc; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Comparator; | ||
|
||
public record CircularSignatureError( | ||
@NotNull ImmutableSeq<Stmt> cycles | ||
) implements Problem { | ||
@Override public @NotNull SourcePos sourcePos() { | ||
return cycles.view().map(Stmt::sourcePos) | ||
.max(Comparator.comparingInt(SourcePos::endLine)); | ||
} | ||
|
||
@Override public @NotNull Doc describe(@NotNull DistillerOptions options) { | ||
return Doc.sep( | ||
Doc.english("Circular signature dependency found between"), | ||
Doc.commaList(cycles.view().map(this::nameOf).toImmutableSeq() | ||
.sorted().view().map(Doc::plain)) | ||
); | ||
} | ||
|
||
private @NotNull String nameOf(@NotNull Stmt stmt) { | ||
return switch (stmt) { | ||
case Decl decl -> decl.ref().name(); | ||
case Sample sample -> nameOf(sample.delegate()); | ||
case Remark remark -> remark.raw; | ||
default -> throw new IllegalStateException("Unexpected stmt seen in SCCTycker: " + stmt); | ||
}; | ||
} | ||
|
||
@Override public @NotNull Severity level() { | ||
return Severity.ERROR; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.