Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Julien Lopez
qir
Commits
fec5eddc
Commit
fec5eddc
authored
6 years ago
by
Julien Lopez
Browse files
Options
Downloads
Patches
Plain Diff
Fix in interaction between QIRRecordType and QIRSomeType
parent
3f301f61
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/qir/types/QIRRecordType.java
+4
-5
4 additions, 5 deletions
src/qir/types/QIRRecordType.java
src/qir/types/QIRSomeType.java
+11
-8
11 additions, 8 deletions
src/qir/types/QIRSomeType.java
with
15 additions
and
13 deletions
src/qir/types/QIRRecordType.java
+
4
−
5
View file @
fec5eddc
...
...
@@ -6,8 +6,6 @@ import java.util.Map.Entry;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
qir.util.QIRException
;
public
class
QIRRecordType
extends
QIRType
{
private
final
Map
<
String
,
QIRType
>
fieldTypes
;
private
Optional
<
QIRType
>
globalRestriction
;
...
...
@@ -43,11 +41,11 @@ public class QIRRecordType extends QIRType {
return
fieldTypes
.
get
(
id
);
}
public
final
void
unionWith
(
final
QIRRecordType
other
)
{
public
final
boolean
unionWith
(
final
QIRRecordType
other
)
{
if
(!
globalRestriction
.
isPresent
()
||
other
.
globalRestriction
.
isPresent
()
&&
other
.
globalRestriction
.
get
().
isSubtypeOf
(
globalRestriction
.
get
()))
globalRestriction
=
other
.
globalRestriction
;
else
if
(
other
.
globalRestriction
.
isPresent
()
&&
!
globalRestriction
.
get
().
isSubtypeOf
(
other
.
globalRestriction
.
get
()))
throw
new
QIRException
(
"Failed union between "
+
this
+
" and "
+
other
)
;
return
false
;
for
(
Entry
<
String
,
QIRType
>
otherEntry
:
other
.
fieldTypes
.
entrySet
())
{
final
String
otherKey
=
otherEntry
.
getKey
();
final
QIRType
otherValue
=
otherEntry
.
getValue
();
...
...
@@ -56,10 +54,11 @@ public class QIRRecordType extends QIRType {
if
(
otherValue
.
isSubtypeOf
(
thisType
))
fieldTypes
.
put
(
otherKey
,
otherValue
);
else
if
(!
thisType
.
isSubtypeOf
(
otherValue
))
throw
new
QIRException
(
"Failed union between "
+
this
+
" and "
+
other
)
;
return
false
;
}
else
fieldTypes
.
put
(
otherEntry
.
getKey
(),
otherEntry
.
getValue
());
}
return
true
;
}
@Override
...
...
This diff is collapsed.
Click to expand it.
src/qir/types/QIRSomeType.java
+
11
−
8
View file @
fec5eddc
...
...
@@ -2,8 +2,6 @@ package qir.types;
import
java.util.Optional
;
import
qir.util.QIRException
;
public
class
QIRSomeType
extends
QIRType
{
private
static
int
idGen
=
0
;
...
...
@@ -25,18 +23,23 @@ public class QIRSomeType extends QIRType {
@Override
protected
boolean
isSubtypeOfSpecific
(
final
QIRType
other
)
{
if
(
other
instanceof
QIRRecordType
)
{
if
(
infered
.
isPresent
())
{
if
(
infered
.
get
()
instanceof
QIRRecordType
)
{
((
QIRRecordType
)
infered
.
get
()).
unionWith
((
QIRRecordType
)
other
);
return
true
;
}
else
return
false
;
}
infered
=
Optional
.
of
(
other
);
return
true
;
}
if
(!
infered
.
isPresent
()
||
other
.
isSubtypeOf
(
infered
.
get
()))
{
infered
=
Optional
.
of
(
other
);
return
true
;
}
if
(
infered
.
get
().
isSubtypeOf
(
other
))
return
true
;
if
(
infered
.
get
()
instanceof
QIRRecordType
&&
other
instanceof
QIRRecordType
)
try
{
((
QIRRecordType
)
infered
.
get
()).
unionWith
((
QIRRecordType
)
other
);
return
true
;
}
catch
(
final
QIRException
e
)
{
}
return
false
;
}
}
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