Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[runtime] Disallow casts between int[] and IList<int?> etc. #6486

Merged
merged 1 commit into from Jan 15, 2018

Conversation

vargaz
Copy link
Contributor

@vargaz vargaz commented Jan 11, 2018

Fixes #6401

@vargaz vargaz requested a review from kumpera as a code owner January 11, 2018 17:04
@luhenry luhenry changed the title [runtime] Disallow casts between int[] and IList<int?> etc. Fixes #6401. [runtime] Disallow casts between int[] and IList<int?> etc. Jan 11, 2018
@Therzok
Copy link
Contributor

Therzok commented Jan 11, 2018

Does:

public static void Main() {
        object arr = new int? [10];
        if (arr is IList<int?>) {
            Console.WriteLine("xyz");
        }
    }

Still work? .NET seems to suggest it should: https://sharplab.io/#v2:EYLgtghgzgLgpgJwDQxAgrgOwD4AEAMABLgIwDcAsAFAHEkAslV1uAzMQEyEDChA3tUJDi7UgDZi9OgA4AFAEp+g4SoD2wAFZwAxjEIQECQgF5CmOAHdCAS0wwA/IQDaJfAF0mKldYBmhWQZG1lCEAJIAMsEwADy2DgB8igJUXql0AJyyAEQAHgCeAF5Z8p5pAL7KQhVUZUA

@marek-safar
Copy link
Member

build

@@ -8411,13 +8411,15 @@ mono_class_is_assignable_from (MonoClass *klass, MonoClass *oklass)

// If the target we're trying to cast to is a valuetype, we must account of weird valuetype equivalences such as IntEnum <> int or uint <> int
// We can't apply it for ref types as this would go wrong with arrays - IList<byte[]> would have byte tested
if (iface_klass->valuetype)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that comment above should be moved into the if block imho

@marek-safar
Copy link
Member

Please backport to 2017-12

@luhenry luhenry self-assigned this Jan 12, 2018
@luhenry
Copy link
Contributor

luhenry commented Jan 12, 2018

@monojenkins build Linux AArch64

@luhenry
Copy link
Contributor

luhenry commented Jan 12, 2018

@monojenkins build Linux AArch64 Interpreter

@luhenry
Copy link
Contributor

luhenry commented Jan 12, 2018

@monojenkins build Linux i386

@luhenry
Copy link
Contributor

luhenry commented Jan 12, 2018

@monojenkins build Linux x64 FullAOT

@luhenry
Copy link
Contributor

luhenry commented Jan 12, 2018

@monojenkins build Linux ARMv7 hard float interpreter

@marek-safar marek-safar merged commit 902626b into mono:master Jan 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants