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

SAM type change causes undercompilation #830

Closed
eed3si9n opened this issue Jul 12, 2020 · 2 comments · Fixed by scala/scala3#16996, #1288 or scala/scala#10617
Closed

SAM type change causes undercompilation #830

eed3si9n opened this issue Jul 12, 2020 · 2 comments · Fixed by scala/scala3#16996, #1288 or scala/scala#10617
Labels
area/under_compilation Zinc does not pick up compilation when needed

Comments

@eed3si9n
Copy link
Member

This is yet another example of Zinc lagging Scala language spec change.
https://www.scala-lang.org/news/2.12.0/#lambda-syntax-for-sam-types

steps

Haven't minimized it but I noticed while coding. First you have a Java interface in one subproject.

import java.nio.file.Path;
import java.util.Optional;

public interface SingleOutput {
    public Path getOutputDirectory();

    public default Optional<Path> getSingleOutput() {
        return Optional.of(getOutputDirectory());
    }
}

In another subproject, use it as SAM-type lambda:

val output: SingleOutput = () => RootFilePath.resolve("out")

Then change the Java interface..

import java.io.File;
import java.util.Optional;

public interface SingleOutput {
    public File getOutputDirectory();

    public default Optional< File > getSingleOutput() {
        return Optional.of(getOutputDirectory());
    }
}

problem

The Scala code is not invalidated. So locally compile keeps succeeding. On CI the build fails if it's compiled from scratch.

expectation

Invalidate correctly.

@eed3si9n eed3si9n added the area/under_compilation Zinc does not pick up compilation when needed label Jul 12, 2020
smarter added a commit to dotty-staging/dotty that referenced this issue Feb 22, 2023
A lambda that implements a SAM type desugars (either at compile-time or runtime
via invokedynamic) into a class that extends the SAM type, therefore we need to
register an inheritance relationship to get the proper invalidation logic.

Fixes sbt/zinc#830.
smarter added a commit to dotty-staging/dotty that referenced this issue Feb 22, 2023
A lambda that implements a SAM type desugars (either at compile-time or runtime
via invokedynamic) into a class that extends the SAM type, therefore we need to
register an inheritance relationship to get the proper invalidation logic.

Fixes sbt/zinc#830.
bishabosha added a commit to scala/scala3 that referenced this issue Feb 23, 2023
A lambda that implements a SAM type desugars (either at compile-time or
runtime via invokedynamic) into a class that extends the SAM type,
therefore we need to register an inheritance relationship to get the
proper invalidation logic.

Fixes sbt/zinc#830.
@smarter
Copy link
Contributor

smarter commented Feb 24, 2023

Fixed in Scala 3 with scala/scala3#16996.

@smarter
Copy link
Contributor

smarter commented May 25, 2023

Interesting, this got closed from a commit in another repo, but should be kept open since it's still an issue in scala 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment