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

Usings should be able to bind to declarations from previous submissions #4811

Closed
amcasey opened this issue Aug 26, 2015 · 10 comments
Closed
Labels
Area-Interactive Bug Interactive-ScriptingLogic Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented Verified
Milestone

Comments

@amcasey
Copy link
Member

amcasey commented Aug 26, 2015

> class Foo { }
> using F = Foo;

This case would be affected if it were legal (which it's not).

> namespace N { public class Foo { } }
> using N;
@amcasey
Copy link
Member Author

amcasey commented Aug 26, 2015

Was internal bug 528436.

@amcasey
Copy link
Member Author

amcasey commented Aug 26, 2015

See also internal bug 528258: the semantic model does consider previous submissions when binding usings, so it may disagree with the batch compiler.

@amcasey amcasey modified the milestones: 1.1(preview), 1.1 Aug 26, 2015
@amcasey
Copy link
Member Author

amcasey commented Sep 17, 2015

Since you can't declare namespaces in script/interactive code, only using aliases are affected.

@amcasey
Copy link
Member Author

amcasey commented Sep 21, 2015

@ManishJayaswal Since only using aliases are affected, I don't believe this meets the preview bar.

@amcasey amcasey modified the milestones: 1.1, 1.1(preview) Sep 21, 2015
@ManishJayaswal
Copy link
Contributor

@amcasey sounds good.

@amcasey
Copy link
Member Author

amcasey commented Sep 22, 2015

It is also impossible to alias a type declared in the same compilation.

@amcasey
Copy link
Member Author

amcasey commented Sep 22, 2015

The root of the problem seems to be that Binder.LookupMembersInSubmissions unconditionally considers the imports of all submissions (including the current one), ignoring the Imports passed into the binder.

@amcasey
Copy link
Member Author

amcasey commented Sep 25, 2015

amcasey added a commit to amcasey/roslyn that referenced this issue Sep 29, 2015
@amcasey
Copy link
Member Author

amcasey commented Oct 2, 2015

We had hoped we could fix this later, but it's not additive. Specifically, it changes the binding rules for using. using F = Foo; could go from referring to Foo in a referenced assembly to referring to Foo in a previous submission. Such rebindings break back-compat.

amcasey added a commit to amcasey/roslyn that referenced this issue Oct 8, 2015
 1. Look for declarations in the current submission (including aliases).
 2. Look for declarations in preceding submissions (including aliases), in
 order.
 3. Look for members in the host object (if any).
 4. Look for declarations in the global namespace.
 5. Look in usings (except aliases) in the current submission and all
 preceding submissions (all at once, not looping).
 6. Look in the global imports of the current submission and all preceding
 submissions (all at once, not looping).

Note that 5, 6, and aliases from 1 are skipped if we are binding the
target of a using in the current submission.

Fixes dotnet#5450
Fixes dotnet#4811
@amcasey
Copy link
Member Author

amcasey commented Mar 16, 2016

@genlu Can you please verify this?

@amcasey amcasey removed their assignment Mar 16, 2016
@genlu genlu added Verified Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented labels Mar 16, 2016
@genlu genlu removed their assignment Mar 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Interactive Bug Interactive-ScriptingLogic Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented Verified
Projects
None yet
Development

No branches or pull requests

3 participants