Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing case for Array typeBounds, make private final, fix minor bug in RefinementLifting #1494

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ class RefinementLifting(override val s: Trees, override val t: Trees)
val (Seq(nvd), pred2) = parameterConds(Seq(vd.copy(tpe = vd2.tpe).copiedFrom(vd)))

(nvd, s.exprOps.replaceFromSymbols(Map(vd2 -> nvd.toVariable), s.and(pred, pred2)))
case _ =>
(vd, s.BooleanLiteral(true).copiedFrom(vd))
case t =>
// Note: t may have been dealiased, hence we need to update the type of the variable
// so it is consistent with each of its occurrence in the body of the function
(vd.copy(tpe = t), s.BooleanLiteral(true).copiedFrom(vd))
}).unzip

(newParams, s.andJoin(conds))
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/scala/stainless/extraction/oo/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ trait TypeOps extends innerfuns.TypeOps { self =>
case (MapType(f1, t1), MapType(f2, t2)) if leastUpperBound(f1, f2) == greatestLowerBound(f1, f2) =>
Some(MapType(f1, typeBound(t1, t2, upper)))

case (ArrayType(b1), ArrayType(b2)) if leastUpperBound(b1, b2) == greatestLowerBound(b1, b2) =>
Some(ArrayType(b1))

case _ => None
}).getOrElse(if (upper) AnyType() else NothingType()).getType

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object ArrayOfTypeAlias {
type AliasedLong = Long

case class SomeClass(arr: Array[AliasedLong])
}
9 changes: 9 additions & 0 deletions frontends/benchmarks/verification/valid/PrivateIsFinal.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
object PrivateIsFinal {
trait SomeTrait {
private def someSecret(x: BigInt): BigInt = x + 42

final def testSecret(x: BigInt): Unit = {
assert(someSecret(x) == 42 + x)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ class CodeExtraction(inoxCtx: inox.Context, symbolMapping: SymbolMapping)(using
(if ((sym is Implicit) && (sym is Synthetic)) Seq(xt.Inline, xt.Synthetic) else Seq()) ++
(if (sym is Inline) Seq(xt.Inline) else Seq()) ++
(if (sym is Private) Seq(xt.Private) else Seq()) ++
(if (sym is Final) Seq(xt.Final) else Seq()) ++
(if (sym.isEffectivelyFinal) Seq(xt.Final) else Seq()) ++
(if (isDefaultGetter(sym) || isCopyMethod(sym)) Seq(xt.Synthetic, xt.Inline) else Seq())

if (sym.name == nme.unapply) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ trait CodeExtraction extends ASTExtractors {
var flags = annotationsOf(sym).filterNot(annot => annot == xt.IsMutable || annot.name == "inlineInvariant") ++
(if (sym.isImplicit && sym.isSynthetic) Seq(xt.Inline, xt.Synthetic) else Seq()) ++
(if (sym.isPrivate) Seq(xt.Private) else Seq()) ++
(if (sym.isFinal) Seq(xt.Final) else Seq()) ++
(if (sym.isEffectivelyFinal) Seq(xt.Final) else Seq()) ++
(if (sym.isVal || sym.isLazy) Seq(xt.IsField(sym.isLazy)) else Seq()) ++
(if (isDefaultGetter(sym) || isCopyMethod(sym)) Seq(xt.Synthetic, xt.Inline) else Seq()) ++
(if (!sym.isLazy && sym.isAccessor)
Expand Down