Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
7a570c8d
Commit
7a570c8d
authored
9 years ago
by
Manos Koukoutos
Browse files
Options
Downloads
Patches
Plain Diff
Properly type findOption
parent
900e027d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/leon/LeonContext.scala
+5
-3
5 additions, 3 deletions
src/main/scala/leon/LeonContext.scala
with
5 additions
and
3 deletions
src/main/scala/leon/LeonContext.scala
+
5
−
3
View file @
7a570c8d
...
@@ -6,6 +6,8 @@ import leon.utils._
...
@@ -6,6 +6,8 @@ import leon.utils._
import
java.io.File
import
java.io.File
import
scala.reflect.ClassTag
/** Everything that is part of a compilation unit, except the actual program tree.
/** Everything that is part of a compilation unit, except the actual program tree.
* Contexts are immutable, and so should all there fields (with the possible
* Contexts are immutable, and so should all there fields (with the possible
* exception of the reporter). */
* exception of the reporter). */
...
@@ -20,11 +22,11 @@ case class LeonContext(
...
@@ -20,11 +22,11 @@ case class LeonContext(
// @mk: This is not typesafe, because equality for options is implemented as name equality.
// @mk: This is not typesafe, because equality for options is implemented as name equality.
// It will fail if an LeonOptionDef is passed that has the same name
// It will fail if an LeonOptionDef is passed that has the same name
// with one in Main,allOptions, but is different
// with one in Main,allOptions, but is different
def
findOption
[
A
](
optDef
:
LeonOptionDef
[
A
])
:
Option
[
A
]
=
options
.
collectFirst
{
def
findOption
[
A
:
ClassTag
](
optDef
:
LeonOptionDef
[
A
])
:
Option
[
A
]
=
options
.
collectFirst
{
case
LeonOption
(
`optDef`
,
value
)
=>
value
.
asInstanceOf
[
A
]
case
LeonOption
(
`optDef`
,
value
:
A
)
=>
value
}
}
def
findOptionOrDefault
[
A
](
optDef
:
LeonOptionDef
[
A
])
:
A
=
def
findOptionOrDefault
[
A
:
ClassTag
](
optDef
:
LeonOptionDef
[
A
])
:
A
=
findOption
(
optDef
).
getOrElse
(
optDef
.
default
)
findOption
(
optDef
).
getOrElse
(
optDef
.
default
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment