Skip to content

Commit

Permalink
scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Dec 19, 2023
1 parent f2e461f commit a40cd56
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ case object TypeSignatures extends IRPass {
private def resolveAscription(sig: Type.Ascription): Expression = {
val newTyped = sig.typed.mapExpressions(resolveExpression)
val newSig = sig.signature.mapExpressions(resolveExpression)
newTyped.updateMetadata(new MetadataPair(this, Signature(newSig, sig.comment)))
newTyped.updateMetadata(
new MetadataPair(this, Signature(newSig, sig.comment))
)
}

/** Resolves type signatures in a block.
Expand Down Expand Up @@ -322,7 +324,8 @@ case object TypeSignatures extends IRPass {
*
* @param signature the expression for the type signature
*/
case class Signature(signature: Expression, comment: Option[String] = None) extends IRPass.IRMetadata {
case class Signature(signature: Expression, comment: Option[String] = None)
extends IRPass.IRMetadata {
override val metadataName: String = "TypeSignatures.Signature"

/** @inheritdoc */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,24 @@ object Type {
}

/** The ascription of a type to a value.
*
* @param typed the expression being ascribed a type
* @param signature the signature being ascribed to `typed`
* @param comment a comment that may be used to add context to the type error
* @param location the source location that the node corresponds to
* @param passData the pass metadata associated with this node
* @param diagnostics compiler diagnostics for this node
*/
*
* @param typed the expression being ascribed a type
* @param signature the signature being ascribed to `typed`
* @param comment a comment that may be used to add context to the type error
* @param location the source location that the node corresponds to
* @param passData the pass metadata associated with this node
* @param diagnostics compiler diagnostics for this node
*/
sealed case class Ascription(
typed: Expression,
signature: Expression,
comment: Option[String],
override val location: Option[IdentifiedLocation],
override val passData: MetadataStorage = new MetadataStorage(),
override val passData: MetadataStorage = new MetadataStorage(),
override val diagnostics: DiagnosticStorage = DiagnosticStorage()
) extends Type
with module.scope.Definition
with IRKind.Primitive {
with module.scope.Definition
with IRKind.Primitive {
var id: UUID @Identifier = randomId

/** Creates a copy of `this`.
Expand All @@ -153,13 +153,14 @@ object Type {
def copy(
typed: Expression = typed,
signature: Expression = signature,
comment: Option[String] = comment,
comment: Option[String] = comment,
location: Option[IdentifiedLocation] = location,
passData: MetadataStorage = passData,
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Ascription = {
val res = Ascription(typed, signature, comment, location, passData, diagnostics)
val res =
Ascription(typed, signature, comment, location, passData, diagnostics)
res.id = id
res
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,10 @@ class IrToTruffle(
// === Utility Functions ====================================================
// ==========================================================================

private def extractAscribedType(comment: String, t: Expression): ReadArgumentCheckNode = t match {
private def extractAscribedType(
comment: String,
t: Expression
): ReadArgumentCheckNode = t match {
case u: `type`.Set.Union =>
ReadArgumentCheckNode.oneOf(
comment,
Expand Down Expand Up @@ -1072,9 +1075,11 @@ class IrToTruffle(
ir match {
case _: Expression.Binding =>
case _ =>
val types: Option[TypeSignatures.Signature] = ir.getMetadata(TypeSignatures)
val types: Option[TypeSignatures.Signature] =
ir.getMetadata(TypeSignatures)
types.foreach { tpe =>
val checkNode = extractAscribedType(tpe.comment.orNull, tpe.signature);
val checkNode =
extractAscribedType(tpe.comment.orNull, tpe.signature);
if (checkNode != null) {
runtimeExpression =
ReadArgumentCheckNode.wrap(runtimeExpression, checkNode)
Expand Down

0 comments on commit a40cd56

Please sign in to comment.