Skip to content

Commit 32be061

Browse files
Merge pull request #7026 from michaellilltokiwa/fix_soundness_issue
fix soundness issue in `constraintAssignableFrom`
2 parents a63e318 + a2d4482 commit 32be061

14 files changed

Lines changed: 84 additions & 18 deletions

File tree

modules/base/src/container/Typed_Sequence.fz

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public Typed_Sequence ref : Sequence container.Typed_Value is
9898
#
9999
# In case this `Typed_Sequence` is empty, the result is `e`.
100100
#
101-
public typed_zip_and_fold(E type, Z type : typed_zipper E, b Typed_Sequence.this, e E, z Z) E
101+
public typed_zip_and_fold(E type, Z type : container.typed_zipper E, b Typed_Sequence.this, e E, z Z) E
102102
=>
103103
abstract
104104

modules/base/src/eff/try.fz

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#
3737
# res := try ERROR_TYPE FALLIBLE_TYPE RESULT_TYPE code || (s->handle post condition failure `s`)
3838
#
39-
public try(ERROR type, F type : fallible ERROR, T type, code_try ()->T) is
39+
public try(ERROR type, F type : eff.fallible ERROR, T type, code_try ()->T) is
4040

4141
# a local mutate used for storing an error
4242
# when throwing an exception

modules/base/src/fuzion/java.fz

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public java is
5050
# A Java array
5151
#
5252
public Array(public T type,
53-
public redef java_ref Java_Ref) ref : Sequence T, Java_Object java_ref
53+
public redef java_ref Java_Ref) ref : Sequence T, fuzion.java.Java_Object java_ref
5454
is
5555
public length i32 ! fuzion.jvm =>
5656
fuzion.jvm.env.array_length T java_ref
@@ -108,7 +108,7 @@ public java is
108108

109109
# Java's 'java.lang.String' type
110110
#
111-
public Java_String(public redef java_ref Java_Ref) ref : String, Java_Object java_ref
111+
public Java_String(public redef java_ref Java_Ref) ref : String, fuzion.java.Java_Object java_ref
112112
is
113113
public redef utf8 Sequence u8 =>
114114
(jvm.java_string_to_string java_ref).utf8

modules/base/src/time/duration.fz

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module:public duration (
3838
#
3939
public nanos u64
4040
)
41-
: Period,
41+
: time.Period,
4242
property.orderable,
4343
property.hashable
4444

modules/base/src/time/nano.fz

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# not be the right source of time to, e.g., feed an alarm clock that should
3535
# wake you up at 6h30 every morning.
3636
#
37-
public nano (p Nano_Time_Handler) : Clock is
37+
public nano (p Nano_Time_Handler) : time.Clock is
3838

3939
# no guarantee can be given for precision nor resolution
4040
#

src/dev/flang/ast/AbstractType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,12 +717,12 @@ boolean constraintAssignableFrom(Context context, AbstractType actual)
717717
// NYI: BUG: Check: What about open generics?
718718
result = actual.feature() == feature() &&
719719
(actual.isThisType() || (genericsAssignable(actual, context) &&
720-
(outer() == null || actual.outer() != null && outer().constraintAssignableFrom(actual.outer()))));
720+
(outer() == null || actual.outer() != null && outer().isAssignableFromDirectly(actual.outer()).yes())));
721721
for (var p: actual.feature().inherits())
722722
{
723723
if (!result)
724724
{
725-
var pa = p.type().applyTypePars(actual);
725+
var pa = actualType(p.type().applyTypePars(actual));
726726
result = pa!=actual && constraintAssignableFrom(context, pa);
727727
}
728728
}

tests/covariance/test_covariance.fz

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ test_covariance is
7575

7676
# integer mod 2 implementation of num0
7777
#
78-
intM2(is_zero bool) : num0 is
78+
intM2(is_zero bool) : test_covariance.num0 is
7979
fixed z => intM2 true
8080
fixed o => intM2 false
8181
fixed redef type.zero => test_covariance.intM2 true
@@ -87,7 +87,7 @@ test_covariance is
8787

8888
# integer mod 5 implementation of num0
8989
#
90-
intM5(v u8) : num0 is
90+
intM5(v u8) : test_covariance.num0 is
9191
fixed z => intM5 0
9292
fixed o => intM5 1
9393
fixed redef type.zero => test_covariance.intM5 0

tests/reg_issue1294/issue1294.fz

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ scenario2 is
6565
_ : scenario2.M T is
6666
fixed redef e => zero
6767

68-
b : a scenario2.b is
68+
b : scenario2.a scenario2.b is
6969

7070
fixed redef type.zero scenario2.b => scenario2.b
7171

@@ -328,7 +328,7 @@ scenario8 is
328328

329329
# integer mod 2 implementation of num0
330330
#
331-
intM2(is_zero bool) : num0 is
331+
intM2(is_zero bool) : scenario8.num0 is
332332
fixed z => intM2 true
333333
fixed o => intM2 false
334334
fixed redef type.zero => scenario8.intM2 true

tests/reg_issue5569/reg_issue5569.fz

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ reg_issue5569 =>
4848

4949
# using a different outer type `t2`
5050
t2 : t is
51-
yak "expecting t2.i: "; t2.e ! v t2.e
51+
# gives error: Incompatible type parameter:
52+
# yak "expecting t2.i: "; t2.e ! v t2.e
5253

5354
# using a different inner type `e2`
5455
t.e2 : t.e is
@@ -66,7 +67,8 @@ reg_issue5569 =>
6667
say "{type_of x} {type_of y}"
6768

6869
yak "expecting t.i /t.e.j : "; t.e ! w t.e
69-
yak "expecting t2.i/t2.e.j : "; t2.e ! w t2.e
70+
# gives error: Incompatible type parameter:
71+
# yak "expecting t2.i/t2.e.j : "; t2.e ! w t2.e
7072
yak "expecting t.i /t.e2.j : "; t.e2 ! w t.e2
7173
yak "expecting t2.i/t2.e2.j: "; t2.e2 ! w t2.e2
7274

@@ -80,7 +82,8 @@ reg_issue5569 =>
8082
say "{type_of x} {type_of y}"
8183

8284
yak "expecting option (array t.i /t.e.j ): "; t.e ! w2 t.e
83-
yak "expecting option (array t2.i/t2.e.j ): "; t2.e ! w2 t2.e
85+
# gives error: Incompatible type parameter:
86+
# yak "expecting option (array t2.i/t2.e.j ): "; t2.e ! w2 t2.e
8487
yak "expecting option (array t.i /t.e2.j ): "; t.e2 ! w2 t.e2
8588
yak "expecting option (array t2.i/t2.e2.j): "; t2.e2 ! w2 t2.e2
8689

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
expecting t.i : Type of 'reg_issue5569.t.i'
2-
expecting t2.i: Type of 'reg_issue5569.t2.i'
32
expecting t.i : Type of 'reg_issue5569.t.i'
43
expecting t2.i: Type of 'reg_issue5569.t2.i'
54
expecting t.i /t.e.j : Type of 'reg_issue5569.t.i' Type of 'reg_issue5569.t.e.j'
6-
expecting t2.i/t2.e.j : Type of 'reg_issue5569.t2.i' Type of 'reg_issue5569.t2.e.j'
75
expecting t.i /t.e2.j : Type of 'reg_issue5569.t.i' Type of 'reg_issue5569.t.e2.j'
86
expecting t2.i/t2.e2.j: Type of 'reg_issue5569.t2.i' Type of 'reg_issue5569.t2.e2.j'
97
expecting option (array t.i /t.e.j ): Type of 'option (array reg_issue5569.t.i)' Type of 'option (array reg_issue5569.t.e.j)'
10-
expecting option (array t2.i/t2.e.j ): Type of 'option (array reg_issue5569.t2.i)' Type of 'option (array reg_issue5569.t2.e.j)'
118
expecting option (array t.i /t.e2.j ): Type of 'option (array reg_issue5569.t.i)' Type of 'option (array reg_issue5569.t.e2.j)'
129
expecting option (array t2.i/t2.e2.j): Type of 'option (array reg_issue5569.t2.i)' Type of 'option (array reg_issue5569.t2.e2.j)'

0 commit comments

Comments
 (0)