Skip to content

Comments

Cleanup hasOverloads#5198

Merged
ibuclaw merged 1 commit intodlang:masterfrom
9rnsr:cleanup_hasOverloads
Feb 15, 2016
Merged

Cleanup hasOverloads#5198
ibuclaw merged 1 commit intodlang:masterfrom
9rnsr:cleanup_hasOverloads

Conversation

@9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Oct 18, 2015

Remove Dsymbol.hasOverloads() because it's confusing method.

@9rnsr 9rnsr force-pushed the cleanup_hasOverloads branch from 934c08e to 9cf04ef Compare October 18, 2015 12:56
@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 18, 2015

src/expression.d Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

"Won't be generated" or "Isn't generated"

src/expression.d Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

What's with the commented out assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was a junk. Removed.

@9rnsr 9rnsr force-pushed the cleanup_hasOverloads branch from 46700a6 to a1e8b14 Compare November 16, 2015 06:34
@9rnsr 9rnsr force-pushed the cleanup_hasOverloads branch 2 times, most recently from 2ce3a57 to 20f963b Compare December 3, 2015 06:53
@9rnsr
Copy link
Contributor Author

9rnsr commented Dec 3, 2015

Ping to @yebblies and @klickverbot .

In TypeStruct (or TypeClass) dotExp(), it resolves a form e.ident to an actual expression. And if ident is a function, it's not yet known whether it has overloads or not. In other words, following semantic analysis should assume that the function would have some overloads. That's why we should set DotVarExp.hasOverloads to true if d is a FuncDeclaration.

The logic will also fit to TypeExp.semantic and ScopeExp.semantic.

@9rnsr 9rnsr force-pushed the cleanup_hasOverloads branch from 20f963b to 8b83389 Compare December 3, 2015 14:30
@9rnsr 9rnsr force-pushed the cleanup_hasOverloads branch 3 times, most recently from c8d03fb to 6c39247 Compare February 5, 2016 14:38
@9rnsr 9rnsr force-pushed the cleanup_hasOverloads branch 2 times, most recently from 6831881 to 064bb1a Compare February 14, 2016 12:26
@9rnsr
Copy link
Contributor Author

9rnsr commented Feb 14, 2016

Updated to fix all settings of (Dsymbol|Var|DotVar|SymOff|Delegate)Exp.hasOverloads fields.

Usually, when a function symbol appears in expression, e.g. func.d(), &func etc, the func has overload candidates. So, usually hasOverloads field should be set to true until it's resolved. Changing their default arguments to true, and supply false explicitly around internal code generations.

Now this PR is shared by #2130 and #5202.

bool hasOverloads;

extern (D) this(Loc loc, Dsymbol s, bool hasOverloads = false)
extern (D) this(Loc loc, Dsymbol s, bool hasOverloads = true)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it's better just to force hasOverloads to be explicitly passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. Half of hasOverloads would need to be set to false for VarDeclarations. For them, explicit argument passing is just verbose. The default argument true works for good default behavior.

@9rnsr 9rnsr force-pushed the cleanup_hasOverloads branch from 064bb1a to 2d5290e Compare February 15, 2016 15:10
…on names

Grep-ed `new (Dsymbol|Var|DotVar|SymOff|Delegate)Exp` and has checked them all.

Usually, when a function symbol appears in expression, e.g. `func.d()`, `&func` etc, the `func` has overload candidates. So, usually `hasOverloads` field should be set to `true` until it's resolved. Changing their default arguments to `true`, and supply `false` explicitly around internal code generations.
@9rnsr 9rnsr force-pushed the cleanup_hasOverloads branch from 2d5290e to 0364953 Compare February 15, 2016 15:15
@ibuclaw
Copy link
Member

ibuclaw commented Feb 15, 2016

Auto-merge toggled on

ibuclaw added a commit that referenced this pull request Feb 15, 2016
@ibuclaw ibuclaw merged commit 3d726b1 into dlang:master Feb 15, 2016
@ibuclaw
Copy link
Member

ibuclaw commented Feb 15, 2016

Ok, well on the whole I have nothing against this.

@9rnsr
Copy link
Contributor Author

9rnsr commented Feb 16, 2016

Thanks!

@9rnsr 9rnsr deleted the cleanup_hasOverloads branch February 16, 2016 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants