Last active
September 20, 2015 22:51
-
-
Save controlflow/cb6d3fb4e21adb743bb7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Foo { | |
[ProvidesContext] IPredefinedType _predefinedTypes = ...; | |
void DoSomething(ITreeNode node) { | |
if (Check(node)) { | |
var expressionType = node.GetExpressionType(); | |
if (expressionType.Equals(node.GetPredefinedType().Bool) { | |
// ^^^^^^^^^^^^^^^^^^^^^^^^ | |
// Use aleady provided 'IPredefinedType' value from '_predefinedTypes' field | |
} | |
} | |
} | |
} | |
/* | |
Allow on fields/properties | |
Allow in parameters? | |
Check staticness of provided field/property | |
Allow on methods? var foo = Foo() can provide context for inner scope | |
Should it work recursively? We can check for [ProvidesContext] members of [ProvidesContext] type | |
What about subtyping? What about multiple equal types? Introduce context types traversing subtypes until common subtype? | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment