Comments (8)
I only realised now that the firs testcase above only relies on wildcards, not full-blown existentials (ie. existential types which pass this condition).
While adding support for wildcards doesn't seem out of my reach, they won't actually prove very useful for my use-case, where I actually need something akin to:
trait Wrap {
type Inner
def foo: Inner
def bar(toto: Inner): Wrap
}
def other(a: Int): Wrap = new Wrap { /* ... */ }
val wrapped = new Wrap {
type Inner = Int
def foo = 42
def bar(toto: Int): Wrap = other(toto + bar)
}
I am thus wondering whether I should resuscitate my anonymous classes
branch, and then look into associated types/type aliases. What do you think?
from stainless.
Do we need wildcards or existentials to typecheck this testcase (variant of your first testcase)
object existential {
case class A()
case class B()
sealed abstract class AnyFoo
case class Foo[T](x: T) extends AnyFoo
val a: AnyFoo = Foo(A())
val b: AnyFoo = Foo(B())
val list0: List[AnyFoo] = List(a, b)
}
I wonder if the modifications made by @OlivierBlanvillain in the branch https://github.com/OlivierBlanvillain/stainless/tree/cats are enough
from stainless.
No, we don't them for such a variant. But it too fails with a type error as well on master
. It also fails to verify on Olivier's branch (I don't have the output on hand right now but I'll post it later). And as far as I can tell, none of the changes in that branch should affect whether such code can be extracted or not.
from stainless.
This fails as well:
object Existential {
case class A()
sealed abstract class AnyFoo
case class Foo[T](x: T) extends AnyFoo
val a: AnyFoo = Foo(A())
}
from stainless.
I looked at the encoding, and I see that Foo has type: (Type, Object) => Object
.
Then the issue happens when Foo is called: Foo(Adt(1072, Nil()), A()) is of type untyped
Apparently, the type of A() is not a subtype of Object (the inox function isSubtypeOf
from TypeOps returns false).
@samarion Should isSubtypeOf
return true in that case?
from stainless.
Hi, sorry for not helping much with the debugging, I haven't had time to actually run the examples and see what's going on.
@jad-hamza: in your example, isSubtypeOf
is doing the right thing. The class A
is specialized to an ADT because it fits into the fragment we know how to convert to ADTs. It therefore lives in a separate domain as the Object
hierarchy.
This is an issue with specialized type boxing. It seems that boxing is not being performed for ClassConstructor
arguments. To fix this, you can change the argument computation at
stainless/core/src/main/scala/stainless/extraction/oo/TypeEncoding.scala
Lines 819 to 821 in 31960ce
to something resembling
stainless/core/src/main/scala/stainless/extraction/oo/TypeEncoding.scala
Lines 848 to 850 in 31960ce
This should hopefully fix the issue in your example. I'm not sure about the initial issue, I'll need to take a closer look once I have some time.
from stainless.
from stainless.
Fixed by #78
from stainless.
Related Issues (20)
- Support for CVC5 HOT 1
- Slowness of `ValueClasses` HOT 1
- Refinement type not properly freshened
- Unsoundness of `no-inc:z3` involving class invariants
- Invalid conterexample in ScanLeft HOT 2
- CVC4/5 unsupported feature shows an error even though another solver is verifying the VC
- IArray support HOT 1
- Size of type parameters
- Incorrect ADT member type approximation HOT 2
- Collection types in Stainless should be inductive
- Reconcile full-imperative using a ShareCell abstraction HOT 3
- error: Lookup failed for adt with symbol `Conc$27` in phase FunctionSpecialization HOT 1
- Incorrect "refinements checks for subtyping" generated in some cases
- Deep structure updates in non-aliased imperative (was: `computes` to use condition as a more efficient implementation) HOT 4
- Failure of postcondition shown as failure of the assertion in the branch
- Crash in Inox type checker when using freshCopy HOT 1
- Inline functions that do mutation rejected as ghost HOT 3
- Inconsistent positions for postcondition HOT 1
- Equality between non-case classes not rejected HOT 2
- `AntiAliasing` not updating targets for `val` fields HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stainless.