Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Test and optimise TypeEqual and TypeIs behaviour for pointer types. #16150

Merged
merged 1 commit into from
Feb 19, 2017

Conversation

JonHanna
Copy link
Contributor

Contributes to #8081, but since the current behaviour is to safely always return false, continue to allow pointer type operands.

There is already code that examines these expressions for always-false or always-true behaviour, so have pointer types also result in the always-false path being taken.

@@ -61,7 +61,7 @@ private static AnalyzeTypeIsResult AnalyzeTypeIs(Expression operand, Type testTy
return testType == typeof(void) ? AnalyzeTypeIsResult.KnownTrue : AnalyzeTypeIsResult.KnownFalse;
}

if (testType == typeof(void))
if (testType == typeof(void) || testType.GetTypeInfo().IsPointer)
Copy link
Member

Choose a reason for hiding this comment

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

Can it be just testType.IsPointer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it can be. I'll update soon.

@VSadov
Copy link
Member

VSadov commented Feb 18, 2017

LGTM, but wonder if we still need to do GetTypeInfo() to check IsPointer. I am not completely sure but that API might be directly available on the Type

Contributes to #8081, but since the current behaviour is to safely
always return false, continue to allow pointer type operands.

There is already code that examines these expressions for always-false
or always-true behaviour, so have pointer types also result in the
always-false path being taken.
@JonHanna
Copy link
Contributor Author

Updated.

Copy link
Member

@VSadov VSadov left a comment

Choose a reason for hiding this comment

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

LGTM

@VSadov VSadov merged commit 11c6841 into dotnet:master Feb 19, 2017
@JonHanna JonHanna deleted the pointer_types_type_equal_is branch February 19, 2017 19:54
@karelz karelz modified the milestone: 2.0.0 Feb 22, 2017
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…pe_equal_is

Test and optimise TypeEqual and TypeIs behaviour for pointer types.

Commit migrated from dotnet/corefx@11c6841
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants