Skip to content

Commit

Permalink
Unify processing of array types in TypeDetector
Browse files Browse the repository at this point in the history
Both ArrayTypeInStream and CalcArrayType the only existing successors
of the sealed class TypeDetector so we can do that simplification
  • Loading branch information
Mingun committed Jul 13, 2023
1 parent 88aa2ec commit 1ddc2c5
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,10 @@ class TypeDetector(provider: TypeProvider) {
}
case Ast.expr.Subscript(container: Ast.expr, idx: Ast.expr) =>
detectType(container) match {
case ArrayTypeInStream(elType: DataType) =>
case arr: ArrayType =>
detectType(idx) match {
case _: IntType => elType.asNonOwning(
elType match {
case ct: ComplexDataType => ct.isOwning
case _ => false
}
)
case idxType => throw new TypeMismatchError(s"unable to index an array using $idxType")
}
case CalcArrayType(elType: DataType, _) =>
detectType(idx) match {
case _: IntType => elType.asNonOwning(
elType match {
case _: IntType => arr.elType.asNonOwning(
arr.elType match {
case ct: ComplexDataType => ct.isOwning
case _ => false
}
Expand Down

0 comments on commit 1ddc2c5

Please sign in to comment.