Skip to content
Snippets Groups Projects
Commit 8f743372 authored by Etienne Kneuss's avatar Etienne Kneuss
Browse files

Substitute types in synthesis holes

parent 037665b0
No related branches found
No related tags found
No related merge requests found
...@@ -319,6 +319,9 @@ object TypeOps { ...@@ -319,6 +319,9 @@ object TypeOps {
case Error(tpe, desc) => case Error(tpe, desc) =>
Error(tpeSub(tpe), desc).copiedFrom(e) Error(tpeSub(tpe), desc).copiedFrom(e)
case Hole(tpe, alts) =>
Hole(tpeSub(tpe), alts.map(srec)).copiedFrom(e)
case g @ GenericValue(tpar, id) => case g @ GenericValue(tpar, id) =>
tpeSub(tpar) match { tpeSub(tpar) match {
case newTpar : TypeParameter => case newTpar : TypeParameter =>
......
...@@ -61,4 +61,19 @@ class TypeOpsSuite extends LeonTestSuite with helpers.WithLikelyEq with helpers. ...@@ -61,4 +61,19 @@ class TypeOpsSuite extends LeonTestSuite with helpers.WithLikelyEq with helpers.
assert(isSubtypeOf(listD.typed, listD.typed), "List[T] <: List[T]") assert(isSubtypeOf(listD.typed, listD.typed), "List[T] <: List[T]")
} }
test("instantiateType Hole") { ctx =>
val tp1 = TypeParameter.fresh("a")
val tp2 = TypeParameter.fresh("b")
val tpd = TypeParameterDef(tp1)
val e1 = Hole(tp1, Nil)
val e2 = instantiateType(e1, Map(tpd -> tp2), Map())
e2 match {
case Hole(tp, _) => assert(tp == tp2, "Type should have been substituted")
case _ => fail("Incorrect expr shape, should be a Hole")
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment