forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't mark override of abstract base if the override's declaring type…
… is not marked (dotnet/linker#3098) * Don't mark an override every time the base is abstract, only if the declaring type is also marked Adds a condition to ShouldMarkOverrideForBase to exit early if the declaring type of the method is not marked. Commit migrated from dotnet/linker@391ac60
- Loading branch information
1 parent
7b603fa
commit 8c5cfa6
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
...nker.Tests.Cases/Inheritance.VirtualMethods/OverrideOfAbstractInUnmarkedClassIsRemoved.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
using Mono.Linker.Tests.Cases.Expectations.Metadata; | ||
|
||
namespace Mono.Linker.Tests.Cases.Inheritance.VirtualMethods | ||
{ | ||
public class OverrideOfAbstractInUnmarkedClassIsRemoved | ||
{ | ||
[Kept] | ||
public static void Main () | ||
{ | ||
MarkedBase x = new MarkedDerived (); | ||
x.Method (); | ||
|
||
UsedSecondLevelTypeWithAbstractBase y = new (); | ||
y.Method (); | ||
|
||
UsedSecondLevelType z = new (); | ||
z.Method (); | ||
} | ||
|
||
[Kept] | ||
[KeptMember (".ctor()")] | ||
abstract class MarkedBase | ||
{ | ||
[Kept] | ||
public abstract int Method (); | ||
} | ||
|
||
[Kept] | ||
[KeptMember (".ctor()")] | ||
[KeptBaseType (typeof (MarkedBase))] | ||
class MarkedDerived : MarkedBase | ||
{ | ||
[Kept] | ||
public override int Method () => 1; | ||
} | ||
|
||
class UnmarkedDerived : MarkedBase | ||
{ | ||
public override int Method () => 1; | ||
} | ||
|
||
[Kept] | ||
[KeptMember (".ctor()")] | ||
[KeptBaseType (typeof (MarkedBase))] | ||
class UnusedIntermediateType : MarkedBase | ||
{ | ||
[Kept] | ||
public override int Method () => 1; | ||
} | ||
|
||
[Kept] | ||
[KeptMember (".ctor()")] | ||
[KeptBaseType (typeof (UnusedIntermediateType))] | ||
class UsedSecondLevelType : UnusedIntermediateType | ||
{ | ||
[Kept] | ||
public override int Method () => 1; | ||
} | ||
|
||
[Kept] | ||
[KeptMember (".ctor()")] | ||
[KeptBaseType (typeof (MarkedBase))] | ||
abstract class UnusedIntermediateTypeWithAbstractOverride : MarkedBase | ||
{ | ||
[Kept] | ||
public abstract override int Method (); | ||
} | ||
|
||
[Kept] | ||
[KeptMember (".ctor()")] | ||
[KeptBaseType (typeof (UnusedIntermediateTypeWithAbstractOverride))] | ||
class UsedSecondLevelTypeWithAbstractBase : UnusedIntermediateTypeWithAbstractOverride | ||
{ | ||
[Kept] | ||
public override int Method () => 1; | ||
} | ||
|
||
class UnusedSecondLevelTypeWithAbstractBase : UnusedIntermediateTypeWithAbstractOverride | ||
{ | ||
public override int Method () => 1; | ||
} | ||
|
||
class UnusedSecondLevelType : UnusedIntermediateType | ||
{ | ||
public override int Method () => 1; | ||
} | ||
} | ||
} |