From 017b8c9f11ec754bae0041ee57cf260802377e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Mayer?= <a-mikmay@microsoft.com> Date: Mon, 7 Dec 2015 16:56:24 +0100 Subject: [PATCH] Corrected invariance bug. --- .../synthesis/disambiguation/QuestionBuilder.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/leon/synthesis/disambiguation/QuestionBuilder.scala b/src/main/scala/leon/synthesis/disambiguation/QuestionBuilder.scala index b3f13d4fc..cb29b9b19 100644 --- a/src/main/scala/leon/synthesis/disambiguation/QuestionBuilder.scala +++ b/src/main/scala/leon/synthesis/disambiguation/QuestionBuilder.scala @@ -34,8 +34,8 @@ object QuestionBuilder { // Add more if needed. /** Sort methods for question's answers. You can (and should) build your own. */ - abstract class AlternativeSortingType[-T <: Expr] extends Ordering[T] { self => - /** Prioritizes this comparison operator agains the second one. */ + abstract class AlternativeSortingType[T <: Expr] extends Ordering[T] { self => + /** Prioritizes this comparison operator against the second one. */ def &&(other: AlternativeSortingType[T]): AlternativeSortingType[T] = new AlternativeSortingType[T] { def compare(e: T, f: T): Int = { val ce = self.compare(e, f) @@ -45,8 +45,8 @@ object QuestionBuilder { } object AlternativeSortingType { /** Presents shortest alternatives first */ - case class ShorterIsBetter()(implicit c: LeonContext) extends AlternativeSortingType[Expr] { - def compare(e: Expr, f: Expr) = e.asString.length - f.asString.length + case class ShorterIsBetter[T <: Expr]()(implicit c: LeonContext) extends AlternativeSortingType[T] { + def compare(e: T, f: T) = e.asString.length - f.asString.length } /** Presents balanced alternatives first */ case class BalancedParenthesisIsBetter[T <: Expr]()(implicit c: LeonContext) extends AlternativeSortingType[T] { @@ -87,7 +87,7 @@ class QuestionBuilder[T <: Expr](input: List[Identifier], ruleApplication: RuleC import QuestionBuilder._ private var _argTypes = input.map(_.getType) private var _questionSorMethod: QuestionSortingType = QuestionSortingType.IncreasingInputSize - private var _alternativeSortMethod: AlternativeSortingType[T] = AlternativeSortingType.BalancedParenthesisIsBetter() && AlternativeSortingType.ShorterIsBetter() + private var _alternativeSortMethod: AlternativeSortingType[T] = AlternativeSortingType.BalancedParenthesisIsBetter[T]() && AlternativeSortingType.ShorterIsBetter[T]() private var solutionsToTake = 15 private var expressionsToTake = 15 -- GitLab