Skip to content

Commit ae5feb8

Browse files
authored
Merge pull request #1016 from Unity-Technologies/unity-master-bug-1069236
Properly inflate pointer types in inflate_generic_type (case 1069236)
2 parents 39082ef + 336490f commit ae5feb8

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

mono/metadata/class.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,14 @@ inflate_generic_type (MonoImage *image, MonoType *type, MonoGenericContext *cont
817817
nt->data.generic_class = gclass;
818818
return nt;
819819
}
820+
case MONO_TYPE_PTR: {
821+
MonoType *nt, *inflated = inflate_generic_type (image, type->data.type, context, error);
822+
if (!inflated || !mono_error_ok (error))
823+
return NULL;
824+
nt = mono_metadata_type_dup (image, type);
825+
nt->data.type = inflated;
826+
return nt;
827+
}
820828
default:
821829
return NULL;
822830
}

mono/tests/Makefile.am

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ MCS_NO_UNSAFE = $(TOOLS_RUNTIME) $(CSC) -debug:portable \
7676
-noconfig -nologo \
7777
-nowarn:0162 -nowarn:0168 -nowarn:0219 -nowarn:0414 -nowarn:0618 \
7878
-nowarn:0169 -nowarn:1690 -nowarn:0649 -nowarn:0612 -nowarn:3021 \
79-
-nowarn:0197 $(PROFILE_MCS_FLAGS)
79+
-nowarn:0197 -langversion:7.3 $(PROFILE_MCS_FLAGS)
8080
MCS_NO_LIB = $(MCS_NO_UNSAFE) -unsafe
8181

8282
MCS = $(MCS_NO_LIB)
@@ -530,7 +530,8 @@ TESTS_CS_SRC= \
530530
bug-59281.cs \
531531
init_array_with_lazy_type.cs \
532532
weak-fields.cs \
533-
threads-leak.cs
533+
threads-leak.cs \
534+
generic-unmanaged-constraint.cs
534535

535536
if AMD64
536537
TESTS_CS_SRC += async-exc-compilation.cs finally_guard.cs finally_block_ending_in_dead_bb.cs
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
3+
unsafe class Program
4+
{
5+
public static int Main(string[] args)
6+
{
7+
return (int)(IntPtr)Generic<int>.GetPtr();
8+
}
9+
}
10+
11+
unsafe class Generic<T> where T : unmanaged
12+
{
13+
public static T* GetPtr()
14+
{
15+
return (T*)null;
16+
}
17+
}

0 commit comments

Comments
 (0)