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

Also exclude when param is alias type #21191

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

Fixes #21190

Adjust test that params must not be opaque.

Other aliases are permitted, but could check if they are effectively final. String alias can't be overridden.

@som-snytt som-snytt marked this pull request as ready for review July 14, 2024 03:41
@@ -1148,6 +1148,9 @@ object RefChecks {
def strippedResultType = Applications.stripImplicit(tp.stripPoly, wildcardOnly = true).resultType
def firstExplicitParamTypes = Applications.stripImplicit(tp.stripPoly, wildcardOnly = true).firstParamTypes
def hasImplicitParams = tp.stripPoly match { case mt: MethodType => mt.isImplicitMethod case _ => false }
def isAnyAlias =
val denot = tp.typeSymbol.denot
denot.isAliasType || denot.isOpaqueAlias
Copy link

Choose a reason for hiding this comment

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

I'm not sure this is right. type Foo = Int is an alias type, isn't it?

But if you omit the opaque, the warning is correct: you can't ever call the extension method as an extension method.

I guess it's okay to not warn when there should be a warning, but the tricky part here is that opaque types look different depending on context.

Since I don't understand how much work is being done here and how much is being done by the later .isOpaqueAlias bit, I'm not sure this under-warns, but it seems like it might.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where the "receiver" is an alias, https://github.com/scala/scala3/blob/main/tests/warn/i16743.scala#L56

The current diff is at L1165 where the params are checked; the frozen_<:< is not sufficient.

For non-opaque aliases, I think the screws could be tightened where there can be no override (of the alias member).

The goal is indeed to prefer underwarn to overwarn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants