Open saraswat opened 4 years ago
Does issue come up with types other than arrays (e.g. Lists of external types)?
Interesting. Works for Option[X]
.
But the code below produces an odd result. Yields the given traceback. My guess is that extraction succeeded but then something else failed. Evidence is that the same traceback happens whether you use the B[MyInt]
version of the code or the AA
version. (Previously, the AA
version would work.)
object CheckOpaqueParam {
case class Box[X](x:X)
type B[X] = Box[X]
@extern type MyInt = Int
@extern type AA = Box[MyInt]
case class A(x:B[MyInt] /*AA*/)
def m(x: B[MyInt] /*AA*/): MyInt = A(x).x.x
}
Traceback:
[info] Compiling 31 Scala sources to /Users/savija/IdeaProjects/cake/stainless_test/verified/target/scala-2.12/classes ...
[warn] The Z3 native interface is not available. Falling back onto smt-z3.
[info] Generating VCs for those functions:
[info] Checking Verification Conditions...
[error] Run has failed with error: java.lang.ClassCastException: class inox.ast.Types$ADTType cannot be cast to class stainless.extraction.oo.Trees$ClassType (inox.ast.Types$ADTType and stainless.extraction.oo.Trees$ClassType are in unnamed module of loader scala.reflect.internal.util.ScalaClassLoader$URLClassLoader @4b992201)
[error]
The code (extracted, after a few hours of loving labor, from a real program):
yields
I would hope that the same code is called to normalize the type in both places, and should yield
Array[Int]
in both places.The workaround for now is:
It would be helpful to understand exactly how
@extern type A = <typeexpr>
is supposed to operate. What exactly is an opaque type (as implemented in Stainless). How is equality of types expressions specified, if sub-expressions are opaque types.To be clear, the original problem I had (which will take some time to reproduce with a small example) resulted in a traceback because types did not match, the type
Array[OrderT]
did not match the typeArray[?]
. The first type comes from the definition (case class Foo(x: Array[OrderT]...
), the second came from an invocation within a methodm
, using an arg that was a parameter ofm
, whose type was also declared asArray[OrderT]
. This took a lot of head-scratching to figure out...