Created
October 30, 2013 20:36
-
-
Save default-kramer/7239781 to your computer and use it in GitHub Desktop.
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
class A<T> | |
{ | |
public string Foo { get { return "hello"; } } | |
} | |
class B<T> : A<T> { } | |
// this is OK (because A's generic parameter doesn't go to its base class?) | |
class Ok<T> : A<Ok<T>> { } | |
// this is broken (because B's generic parameter tries to go to a base class?) | |
class Broken<T> : B<Broken<T>> { } | |
[TestMethod] | |
public void MyTestMethod() | |
{ | |
dynamic d = new Ok<string>(); | |
var value = d.Foo; | |
Assert.AreEqual("hello", value); | |
d = new Broken<string>(); | |
value = d.Foo; // StackOverflowException | |
Assert.AreEqual("hello", value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment