Skip to content

Ignore all kinds of ProtoTypes instead of just AppliedProtos #6715

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

Merged
merged 6 commits into from
Jun 20, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jun 20, 2019

In blocks, conditionals and matches we mapped applied prototypes to
WildcardTypes in order to force eta expansions. With extension methods
the same problem arises for SelectionProtos as well. Furthermore,
it makes no sense to propagate a ViewProto into a local context. So the
consistent thing to do is to map all kinds of ProtoTypes to WildcardTypes
in these situations.

This fails one line in run/implicitsFuns.scala, which however is of dubious value.
(The line requires a manually inserted apply to propagate a given argument
into an if-then-else, circumventing the usual "no applies propagated" strategy.)

odersky added 4 commits June 19, 2019 22:34
liftToClasses used to drop an opaque types from the set of
types whose companion modules are included. Opaque types
do not have companion modules, but their prefixes might,
so it is incorrect to drop them.
The difference is that in an alias type `p.A = q.B`
we take `p` instead of `q` as the prefix to search.
In blocks, conditionals and matches we mapped applied prototypes to
WildcardTypes in order to force eta expansions. With extension methods
the same problem arises for SelectionProtos as well. Furthermore,
it makes to sense to propagate a ViewProto into a local context. So the
consistent thing to do is to map all kinds of ProtoTypes to WildcardTypes
in these situations.

This fails one line in run/implicitsFuns.scala, which, however is of dubious value.
(The line requires a manually inserted `apply` to propagate a `given` argument
into an if-then-else, circumvening the previous "no applies propagated" strategy.
@odersky
Copy link
Contributor Author

odersky commented Jun 20, 2019

Based on #6712

Used to print:

<none> does not take parameters.
@smarter
Copy link
Member

smarter commented Jun 20, 2019

Revise liftToClasses to make CB work

What does "CB" mean here ?

@@ -1428,6 +1430,9 @@ object Types {
/** If this is an ignored proto type, its underlying type, otherwise the type itself */
def revealIgnored: Type = this

/** If this is a proto type, the ignored version, otherwise the type itself */
Copy link
Member

Choose a reason for hiding this comment

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

I would expect "ignored version" to mean "IgnoredProto" but we always map to WildcardType instead, so maybe the documentation should read:

Suggested change
/** If this is a proto type, the ignored version, otherwise the type itself */
/** If this is a proto type, WildcardType, otherwise the type itself */

(lead /: tp.classSymbols)(joinClass)
case tp: TypeRef =>
val sym = tp.symbol
if (sym.isClass || sym.isOpaqueAlias) tp
Copy link
Member

Choose a reason for hiding this comment

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

The same condition is repeated in the definition of isLiftTarget just below, this could be refactored.

@@ -575,8 +582,10 @@ trait ImplicitRunInfo { self: Run =>
def computeIScope() = {
val liftedTp = if (isLifted) tp else liftToClasses(tp)
val refs =
if (liftedTp ne tp)
if (liftedTp ne tp) {
implicitsDetailed.println(i"lifted of $tp = $liftedTp")
Copy link
Member

Choose a reason for hiding this comment

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

Broken indentation.

@odersky
Copy link
Contributor Author

odersky commented Jun 20, 2019

CB = "Community Build". The shapeless 3 part failed.

@odersky odersky merged commit aef831a into scala:master Jun 20, 2019
@liufengyun liufengyun deleted the fix-protos branch June 20, 2019 20:05
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.

2 participants