Skip to content
Snippets Groups Projects
Commit 017b8c9f authored by Mikaël Mayer's avatar Mikaël Mayer
Browse files

Corrected invariance bug.

parent 89648d0a
No related branches found
No related tags found
No related merge requests found
...@@ -34,8 +34,8 @@ object QuestionBuilder { ...@@ -34,8 +34,8 @@ object QuestionBuilder {
// Add more if needed. // Add more if needed.
/** Sort methods for question's answers. You can (and should) build your own. */ /** Sort methods for question's answers. You can (and should) build your own. */
abstract class AlternativeSortingType[-T <: Expr] extends Ordering[T] { self => abstract class AlternativeSortingType[T <: Expr] extends Ordering[T] { self =>
/** Prioritizes this comparison operator agains the second one. */ /** Prioritizes this comparison operator against the second one. */
def &&(other: AlternativeSortingType[T]): AlternativeSortingType[T] = new AlternativeSortingType[T] { def &&(other: AlternativeSortingType[T]): AlternativeSortingType[T] = new AlternativeSortingType[T] {
def compare(e: T, f: T): Int = { def compare(e: T, f: T): Int = {
val ce = self.compare(e, f) val ce = self.compare(e, f)
...@@ -45,8 +45,8 @@ object QuestionBuilder { ...@@ -45,8 +45,8 @@ object QuestionBuilder {
} }
object AlternativeSortingType { object AlternativeSortingType {
/** Presents shortest alternatives first */ /** Presents shortest alternatives first */
case class ShorterIsBetter()(implicit c: LeonContext) extends AlternativeSortingType[Expr] { case class ShorterIsBetter[T <: Expr]()(implicit c: LeonContext) extends AlternativeSortingType[T] {
def compare(e: Expr, f: Expr) = e.asString.length - f.asString.length def compare(e: T, f: T) = e.asString.length - f.asString.length
} }
/** Presents balanced alternatives first */ /** Presents balanced alternatives first */
case class BalancedParenthesisIsBetter[T <: Expr]()(implicit c: LeonContext) extends AlternativeSortingType[T] { case class BalancedParenthesisIsBetter[T <: Expr]()(implicit c: LeonContext) extends AlternativeSortingType[T] {
...@@ -87,7 +87,7 @@ class QuestionBuilder[T <: Expr](input: List[Identifier], ruleApplication: RuleC ...@@ -87,7 +87,7 @@ class QuestionBuilder[T <: Expr](input: List[Identifier], ruleApplication: RuleC
import QuestionBuilder._ import QuestionBuilder._
private var _argTypes = input.map(_.getType) private var _argTypes = input.map(_.getType)
private var _questionSorMethod: QuestionSortingType = QuestionSortingType.IncreasingInputSize 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 solutionsToTake = 15
private var expressionsToTake = 15 private var expressionsToTake = 15
......
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