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

Don't prefer concrete over deferred methods in lookup in Java classes #10579

Closed
wants to merge 1 commit into from

Conversation

lrytz
Copy link
Member

@lrytz lrytz commented Oct 19, 2023

@scala-jenkins scala-jenkins added this to the 2.13.13 milestone Oct 19, 2023
@lrytz
Copy link
Member Author

lrytz commented Oct 19, 2023

scala> def f(l: java.util.List[Object]) = l.sort(_.toString compareTo _.toString)
                                                 ^
       error: missing parameter type for expanded function ((<x$1: error>, x$2) => x$1.toString.compareTo(x$2.toString))
                                                                      ^
       error: missing parameter type for expanded function ((<x$1: error>, <x$2: error>) => x$1.toString.compareTo(x$2.toString))

not immediately obvious to me why this broke, will check later.

@som-snytt
Copy link
Contributor

Glad you are taking concrete action and not deferring.

@som-snytt
Copy link
Contributor

som-snytt commented Oct 19, 2023

I refreshed my poor memory about find members, and also JLS on inheritance. Interfaces are simple, but the rule for classes is first concrete, then if you didn't inherit a concrete m you can inherit an abstract-or-default member from super classes and interfaces.

So a default method in a Java interface does not count as concrete.

This alternative tweak maybe, in walkBaseClasses, to say always take interface methods as non-concrete:

          val flags =
            if (currentBaseClass.isJavaDefined && currentBaseClass.isTrait) flags0 | DEFERRED
            else flags0

The test with inference passes:

ok 1 - pos/t12892b.scala

(I opened a PR out of curiosity. Must go shower and return library books now.)

I'll try to understand what it indicates. #10580

@lrytz lrytz closed this Oct 23, 2023
@SethTisue SethTisue removed this from the 2.13.13 milestone Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants